/* Zebuck Connect - lightweight UI (no build step needed) */
:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --brand: #0f9d58;
    --brand-dark: #0b7a44;
    --brand-soft: #e7f6ee;
    --side: #0f1f17;
    --side-ink: #cfe3d8;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --info: #2563eb;
    --info-soft: #e8efff;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 1px 3px rgba(0, 0, 0, .06);
    --chat-in: #ffffff;
    --chat-out: #dcf8c6;
    --chat-bg: #efeae2;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; word-break: break-all; }
pre { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; background: linear-gradient(to right, var(--side) 236px, var(--bg) 236px); }
.sidebar {
    width: 236px; flex-shrink: 0; background: var(--side); color: var(--side-ink);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 18px 18px 10px; font-weight: 700; font-size: 1.05rem; color: #fff; display: flex; align-items: center; gap: 8px; }
.sidebar .brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: #fff; font-weight: 800; }
.sidebar .ws { margin: 4px 12px 10px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.06); font-size: 12.5px; }
.sidebar .ws strong { display: block; color: #fff; font-size: 13.5px; }
.sidebar nav { padding: 4px 8px 16px; display: flex; flex-direction: column; gap: 1px; }
.sidebar nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; margin: 14px 10px 4px; }
.sidebar nav a {
    color: var(--side-ink); padding: 8px 10px; border-radius: 7px; display: flex; align-items: center; gap: 9px; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar nav a .count { margin-left: auto; background: #ef4444; color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; }
.sidebar .foot { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.sidebar .foot button { background: none; border: 0; color: var(--side-ink); cursor: pointer; padding: 0; font: inherit; }
.ico { width: 18px; text-align: center; opacity: .9; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 56px; background: var(--panel); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; padding: 0 22px; gap: 12px;
}
.topbar .title { font-weight: 600; font-size: 1rem; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark);
    display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.content { padding: 22px; max-width: 1280px; width: 100%; }
.content.full { max-width: none; padding: 0; flex: 1; min-height: 0; }
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 0; }

/* ---------- Components ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 2px; }
.stat .hint { font-size: 12px; color: var(--muted); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
    border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
    white-space: nowrap; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.btn-fb:hover { background: #0f63d6; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-link { background: none; border: 0; color: var(--brand-dark); padding: 0; cursor: pointer; font: inherit; }
.inline { display: inline; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fcfdfd; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #f1f5f9; color: #334155; white-space: nowrap; }
.badge.green { background: var(--brand-soft); color: var(--brand-dark); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.tag { display: inline-block; background: #eef2ff; color: #4338ca; border-radius: 5px; padding: 1px 7px; font-size: 11.5px; margin: 1px 2px 1px 0; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--brand-soft); border-color: #bfe6cf; color: #0b5d35; }
.alert-error { background: var(--danger-soft); border-color: #fbcaca; color: #991b1b; }
.alert-warn { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.alert-info { background: var(--info-soft); border-color: #c7d7fe; color: #1e3a8a; }
.alert ul { margin: 4px 0 0 18px; padding: 0; }

.field { margin-bottom: 14px; }
.field label, .label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.field .err { color: var(--danger); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search],
input[type=datetime-local], input[type=date], input[type=tel], select, textarea {
    width: 100%; padding: 8px 11px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,157,88,.25); border-color: var(--brand); }
textarea { resize: vertical; min-height: 80px; }
input[type=file] { font: inherit; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 160px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--brand-dark); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.progress { height: 8px; background: #eef0f3; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.progress.red > span { background: var(--danger); }

.bars { display: flex; align-items: flex-end; gap: 14px; height: 160px; padding-top: 10px; }
.bars .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bars .pair { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.bars .bar { width: 40%; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar.in { background: #93c5fd; }
.bars .bar.out { background: var(--brand); }
.bars .lbl { font-size: 11.5px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 12px; }
.w-full { width: 100%; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 34px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; display: grid; place-items: center; font-size: 12px; }

.pagination { display: flex; gap: 4px; padding: 12px 18px; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; font-size: 13px; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled { opacity: .45; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .dlg-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .dlg-body { padding: 18px; max-height: 70vh; overflow-y: auto; }
dialog .dlg-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--muted); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #0f1f17 0%, #0f9d58 140%); }
.auth .box { width: min(420px, 100%); background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; margin-bottom: 18px; }
.auth .brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; }

/* ---------- Inbox ---------- */
.inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr) 300px; height: calc(100vh - 56px); background: var(--panel); }
.inbox .col { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.inbox .col:last-child { border-right: 0; }
.inbox .list-head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.inbox .filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.inbox .filter-tabs a { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: #f1f5f9; color: #334155; font-weight: 600; }
.inbox .filter-tabs a.active { background: var(--brand); color: #fff; }
.inbox .filter-tabs a:hover { text-decoration: none; }
.conv-list { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 11px 12px; border-bottom: 1px solid #f1f3f5; color: var(--ink); }
.conv:hover { background: #f8faf9; text-decoration: none; }
.conv.active { background: var(--brand-soft); }
.conv .meta { flex: 1; min-width: 0; }
.conv .row { display: flex; justify-content: space-between; gap: 6px; }
.conv .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.conv .preview { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .unread { background: var(--brand); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; font-weight: 700; }

.chat-head { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chat-body { flex: 1; overflow-y: auto; background: var(--chat-bg); padding: 16px 6%; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 72%; padding: 7px 10px 5px; border-radius: 9px; background: var(--chat-in); box-shadow: 0 1px 1px rgba(0,0,0,.08); align-self: flex-start; word-wrap: break-word; }
.bubble .text { white-space: pre-wrap; }
.bubble.out { background: var(--chat-out); align-self: flex-end; }
.bubble.failed { background: #fde2e2; }
.bubble .foot { font-size: 10.5px; color: #667085; text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.bubble .src { font-size: 10.5px; color: #475467; font-weight: 600; margin-bottom: 2px; }
.bubble img, .bubble video { max-width: 260px; max-height: 260px; border-radius: 6px; display: block; margin-bottom: 4px; }
.bubble .err { color: var(--danger); font-size: 11.5px; margin-top: 3px; }
.bubble .btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.bubble .btns span { border: 1px solid #b7d7c4; border-radius: 6px; padding: 1px 8px; font-size: 12px; color: var(--brand-dark); background: rgba(255,255,255,.6); }
.tick { font-weight: 700; }
.tick.read { color: #34b7f1; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; background: #fafafa; }
.composer form { display: flex; flex-direction: column; gap: 8px; }
.composer textarea { min-height: 42px; max-height: 160px; width: 100%; }
.composer-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.composer-tools select { width: auto; max-width: 170px; }
.composer-tools .spacer { flex: 1; }
.window-note { font-size: 12px; padding: 6px 12px; background: var(--warn-soft); color: #92400e; border-top: 1px solid #fde68a; }
.side-panel { padding: 16px; overflow-y: auto; }
.side-panel .field { margin-bottom: 12px; }
.no-chat { flex: 1; display: grid; place-items: center; background: var(--chat-bg); color: var(--muted); text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .inbox { grid-template-columns: 290px minmax(0, 1fr); }
    .inbox .col.details { display: none; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .app { background: var(--bg); }
    .sidebar { position: fixed; left: -250px; z-index: 50; transition: left .2s; }
    body.nav-open .sidebar { left: 0; }
    .menu-toggle { display: inline-block; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .content { padding: 14px; }
    .inbox { grid-template-columns: 1fr; }
    .inbox.has-chat .col.list { display: none; }
    .inbox:not(.has-chat) .col.chat { display: none; }
    .bubble { max-width: 88%; }
}
@media (max-width: 520px) {
    .grid-4 { grid-template-columns: 1fr; }
    .topbar { padding: 0 12px; }
}
.menu-back { display: none; }
@media (max-width: 820px) { .menu-back { display: inline-flex; } }
