:root {
  --bg: #070812;
  --glass: rgba(255, 255, 255, .055); --glass2: rgba(255, 255, 255, .09); --glass3: rgba(255, 255, 255, .14);
  --line: rgba(255, 255, 255, .11); --line-hi: rgba(255, 255, 255, .22);
  --text: #f1f2f7; --muted: rgba(225, 228, 240, .6);
  --accent: #8b5cf6; --accent2: #22d3ee; --good: #34d399; --warn: #fbbf24; --bad: #f87171;
  --blur: blur(22px) saturate(160%);
  --shadow: 0 8px 32px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .08);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text); display: flex; min-height: 100vh; font-size: 14px;
  background:
    radial-gradient(40vw 40vw at 10% 10%, rgba(139, 92, 246, .45), transparent 70%),
    radial-gradient(35vw 35vw at 90% 20%, rgba(34, 211, 238, .28), transparent 70%),
    radial-gradient(45vw 45vw at 70% 100%, rgba(236, 72, 153, .28), transparent 70%),
    radial-gradient(30vw 30vw at 20% 90%, rgba(59, 130, 246, .25), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
h1 { font-size: 24px; margin: 0 0 18px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 14px; font-weight: 600; }
code { background: var(--glass2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: var(--glass3); border-radius: 8px; } ::-webkit-scrollbar-track { background: transparent; }

/* glass surfaces */
.nav, .card, .kpi, .conv-list, .chat, dialog, #toast {
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}

button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--glass2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 13px; cursor: pointer;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background .15s, border-color .15s, transform .1s;
}
button:hover { background: var(--glass3); border-color: var(--line-hi); }
button:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: default; }
a.btn { display: inline-flex; align-items: center; padding: 7px 13px; border-radius: 10px; text-decoration: none; color: #fff; border: 1px solid var(--line); white-space: nowrap; }
a.btn.primary { background: linear-gradient(135deg, rgba(139, 92, 246, .85), rgba(99, 102, 241, .75)); border-color: rgba(167, 139, 250, .6); }
button.primary { background: linear-gradient(135deg, rgba(139, 92, 246, .85), rgba(99, 102, 241, .75)); border-color: rgba(167, 139, 250, .6); color: #fff; box-shadow: 0 4px 18px rgba(139, 92, 246, .35); }
button.good { background: linear-gradient(135deg, rgba(52, 211, 153, .85), rgba(16, 185, 129, .75)); border-color: rgba(110, 231, 183, .6); color: #032015; font-weight: 600; box-shadow: 0 4px 16px rgba(52, 211, 153, .25); }
input, select, textarea {
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; width: 100%;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: rgba(167, 139, 250, .7); box-shadow: 0 0 0 3px rgba(139, 92, 246, .2); }
input::placeholder, textarea::placeholder { color: rgba(225, 228, 240, .4); }
option { background: #1a1b2e; color: var(--text); }
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 5px; color: var(--text); font-size: 14px; }

/* sidebar */
.nav { width: 230px; margin: 14px 0 14px 14px; border-radius: 20px; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 14px; height: calc(100vh - 28px); }
.brand { font-weight: 700; font-size: 18px; padding: 4px 10px 18px; background: linear-gradient(90deg, #c4b5fd, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav > button { text-align: left; background: none; border: 1px solid transparent; box-shadow: none; backdrop-filter: none; padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.nav > button:hover { background: var(--glass2); }
.nav > button.active { background: var(--glass3); border-color: var(--line-hi); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1); }
.nav .sync { margin-top: 8px; border: 1px solid var(--line); justify-content: center; background: var(--glass2); }
.nav .sync.install { background: linear-gradient(135deg, rgba(139, 92, 246, .45), rgba(34, 211, 238, .35)); border-color: var(--line-hi); }
.badge { margin-left: auto; background: linear-gradient(135deg, #f87171, #ec4899); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 8px; font-weight: 600; box-shadow: 0 2px 10px rgba(236, 72, 153, .4); }
.badge.muted { background: var(--glass3); color: var(--text); box-shadow: none; }
.badge:empty { display: none; }
.sites { margin-top: auto; padding: 8px 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .08); }

/* layout */
main { flex: 1; padding: 28px 30px; min-width: 0; }
.tab { display: none; } .tab.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { margin: 0; }
.filters { display: flex; gap: 8px; } .filters input { width: 240px; } .filters select { width: auto; }
.card { border-radius: 18px; padding: 18px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { border-radius: 18px; padding: 16px 18px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 50%; background: linear-gradient(180deg, rgba(255, 255, 255, .06), transparent); pointer-events: none; }
.kpi .l { color: var(--muted); font-size: 12px; } .kpi .v { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .v.good { color: var(--good); text-shadow: 0 0 18px rgba(52, 211, 153, .35); } .kpi .v.bad { color: var(--bad); text-shadow: 0 0 18px rgba(248, 113, 113, .35); }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.row { display: flex; gap: 10px; align-items: center; } .row > label { flex: 1; } .row.end { justify-content: flex-end; }
.checks { display: flex; gap: 18px; margin-bottom: 12px; flex-wrap: wrap; } .checks label { display: flex; gap: 7px; align-items: center; color: var(--text); font-size: 14px; } .checks input { width: auto; margin: 0; accent-color: var(--accent); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: rgba(255, 255, 255, .03); }
tr:not(:first-child):hover td { background: rgba(255, 255, 255, .035); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
.pill { font-size: 11px; padding: 3px 9px; border-radius: 99px; background: var(--glass2); border: 1px solid var(--line); }
.pill.pending { color: var(--warn); background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); }
.pill.completed, .pill.sold { color: var(--good); background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .3); }
.sitetag { display: inline-flex; align-items: center; font-size: 12px; }
.empty { color: var(--muted); padding: 28px; text-align: center; }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 7px; height: 190px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bar i { display: block; width: 100%; background: linear-gradient(180deg, rgba(167, 139, 250, .95), rgba(34, 211, 238, .45)); border: 1px solid rgba(255, 255, 255, .18); border-radius: 7px 7px 3px 3px; min-height: 3px; box-shadow: 0 0 14px rgba(139, 92, 246, .3); transition: filter .15s; }
.bar span { font-size: 10px; color: var(--muted); }
.bar:hover i { filter: brightness(1.3); }
.siterow { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); } .siterow:last-child { border: none; }
.siterow small { color: var(--muted); display: block; }

/* inbox */
.inbox { display: grid; grid-template-columns: 310px 1fr; gap: 18px; height: calc(100vh - 116px); }
.conv-list { border-radius: 18px; overflow-y: auto; }
.conv { padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .15s; }
.conv:hover { background: rgba(255, 255, 255, .05); }
.conv.active { background: rgba(255, 255, 255, .1); box-shadow: inset 3px 0 0 var(--accent); }
.conv .top { display: flex; justify-content: space-between; gap: 8px; } .conv b { font-weight: 600; }
.conv .prev { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.conv.unread b::after { content: ""; display: inline-block; width: 7px; height: 7px; background: #ec4899; border-radius: 50%; margin-left: 6px; vertical-align: middle; box-shadow: 0 0 8px #ec4899; }
.chat { border-radius: 18px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; background: rgba(255, 255, 255, .03); }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 9px; }
.msg { max-width: 70%; padding: 9px 13px; border-radius: 16px 16px 16px 5px; background: var(--glass2); border: 1px solid var(--line); align-self: flex-start; white-space: pre-wrap; word-wrap: break-word; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.msg.me { background: linear-gradient(135deg, rgba(139, 92, 246, .75), rgba(99, 102, 241, .6)); border-color: rgba(167, 139, 250, .5); color: #fff; align-self: flex-end; border-radius: 16px 16px 5px 16px; }
.msg small { display: block; font-size: 10px; opacity: .6; margin-top: 3px; }
.msg.out { opacity: .75; border-style: dashed; }
.msg.out small { opacity: .9; }
.msg.out.failed { background: rgba(248, 113, 113, .18); border-color: rgba(248, 113, 113, .5); opacity: 1; }
.out-actions { display: flex; gap: 6px; margin-top: 6px; }
.out-actions button { padding: 3px 9px; font-size: 12px; }
.ext-note { padding: 8px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.ext-note.warn { color: var(--warn); background: rgba(251, 191, 36, .06); }
.ext-note a, .composer a { color: #c4b5fd; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .03); }

.pill.delivered { color: #67e8f9; background: rgba(34, 211, 238, .1); border-color: rgba(34, 211, 238, .3); }
.pill.cancelled { color: var(--muted); background: rgba(255, 255, 255, .04); }
.pill.disputed { color: var(--bad); background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .35); }
tr.clickable { cursor: pointer; }
.steps { padding-left: 20px; line-height: 1.8; }
#history-table td:nth-child(3), #orders-table td:nth-child(2), #dash-pending td:nth-child(2) { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }

/* order detail */
#order-dialog { padding: 0; width: min(620px, 94vw); }
#order-dialog form { padding: 22px; }
.od-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.od-head h2 { margin: 0 0 6px; text-transform: none; letter-spacing: 0; }
.od-head h3 { margin: 0 0 8px; font-size: 19px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.facts > div { background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; min-width: 0; }
.facts small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.facts b { font-weight: 600; overflow-wrap: anywhere; }
.facts code { font-size: 11px; }
.timeline { list-style: none; margin: 0 0 16px; padding: 0 0 0 6px; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(139, 92, 246, .25); }
.timeline li.good::before { background: var(--good); box-shadow: 0 0 0 3px rgba(52, 211, 153, .25); }
.timeline li.bad::before { background: var(--bad); box-shadow: 0 0 0 3px rgba(248, 113, 113, .25); }
.timeline span { color: var(--muted); font-size: 13px; text-align: right; }
.note { border-radius: 12px; padding: 10px 13px; margin-bottom: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); }
.note.bad { border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .08); }
.note.good { border-color: rgba(52, 211, 153, .35); background: rgba(52, 211, 153, .08); }
@media (max-width: 600px) { .facts { grid-template-columns: repeat(2, 1fr); } }

/* dialog + toast */
dialog { color: var(--text); border-radius: 20px; width: min(560px, 92vw); padding: 22px; background: rgba(30, 30, 52, .55); }
dialog::backdrop { background: rgba(5, 6, 15, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#toast { position: fixed; bottom: 20px; right: 20px; padding: 11px 17px; border-radius: 14px; opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; pointer-events: none; max-width: 420px; }
#toast.show { opacity: 1; transform: none; }

[hidden] { display: none !important; }
.cb-alert { display: block; width: 100%; text-align: left; margin-bottom: 16px; padding: 11px 16px; border-radius: 14px;
  color: var(--warn); background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .4); }

/* sign-in */
.login-page { align-items: center; justify-content: center; padding: 16px; }
.login-card .brand { display: block !important; }
.login-card { width: min(380px, 100%); padding: 26px; border-radius: 22px; }
.login-card .brand { padding: 0 0 14px; }
.login-card h1 { font-size: 20px; margin-bottom: 8px; }
.login-card button { width: 100%; margin-top: 4px; padding: 10px; }
.error { color: var(--bad); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* team + activity */
.me { padding: 8px 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.me button { padding: 4px 9px; font-size: 12px; }
.perm-checks { display: flex; gap: 12px; flex-wrap: wrap; }
.perm-checks label { display: flex; gap: 5px; align-items: center; margin: 0; color: var(--text); font-size: 13px; white-space: nowrap; }
.perm-checks input { width: auto; margin: 0; accent-color: var(--accent); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--glass2); border: 1px solid var(--line); color: var(--muted); }
.tag.off { color: var(--bad); border-color: rgba(248, 113, 113, .35); }
.msg .by { font-weight: 600; }
.uname { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: #c4b5fd; }
button.copy { padding: 1px 6px; font-size: 11px; border-radius: 6px; margin-left: 2px; }
.uname-edit { display: flex; gap: 6px; }
.facts > div:has(.uname-edit) { grid-column: span 2; }
.uname-edit button { white-space: nowrap; flex: none; }
.uname-edit input { padding: 5px 8px; font-size: 13px; }
.uname-edit button { padding: 5px 9px; font-size: 12px; }

@media (max-width: 860px) {
  body { flex-direction: column; }
  .nav { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; margin: 12px 12px 0; }
  .sites, .brand { display: none; }
  main { padding: 16px; }
  .grid2, .inbox { grid-template-columns: 1fr; }
  .inbox { height: auto; } .conv-list { max-height: 260px; } .chat { height: 70vh; }
  .filters { flex-wrap: wrap; } .filters input { width: 100%; }
}
.qr { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 12px; width: fit-content; margin: 4px auto 10px; }
