:root {
  --ink: #15201D; --ink2: #3A4743; --muted: #55615D; --line: #DDE3E0; --line2: #C9D3CF;
  --bg: #EEF2F0; --panel: #FFFFFF; --soft: #F3F5F4; --green: #0E6656; --green-dk: #094A3E; --green-bg: #E3F0EC;
  --red: #B3261E; --red-bg: #F8E6E3; --amber-ink: #6B3304; --amber-bg: #FCEFD9; --amber-line: #E7C9A0;
  --ig: #E1306C; --fb: #1877F2; --wa: #25D366; --wa-ink: #0B3D24;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
a { color: var(--green); } a:hover { color: var(--green-dk); }
.boot { padding: 40px; color: var(--muted); }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* buttons */
.btn { min-height: 40px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line2); background: var(--panel); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover:not(:disabled) { background: var(--soft); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--green-dk); }
.btn.danger { color: var(--red); border-color: #E3B7B2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 34px; font-size: 13px; padding: 0 10px; }

/* sign in */
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.signin form { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.signin h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
input[type=email], input[type=password], input[type=text], input[type=number], select, textarea { min-height: 42px; padding: 8px 12px; border: 1px solid var(--line2); border-radius: 9px; background: #fff; font-weight: 400; }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.error { color: var(--red); font-size: 14px; }

/* shell */
.topbar { background: var(--ink); color: #F3F5F4; font-size: 13px; padding: 8px 20px; display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.topbar button { background: transparent; border: 1px solid #3A4743; color: #F3F5F4; border-radius: 8px; min-height: 30px; padding: 0 10px; font-size: 13px; }
.banner { background: var(--amber-bg); color: var(--amber-ink); border-bottom: 1px solid var(--amber-line); padding: 10px 20px; font-size: 14px; }
.shell { display: flex; flex-wrap: wrap; min-height: calc(100vh - 40px); }
nav.side { flex: 1 1 220px; max-width: 100%; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; }
@media (min-width: 900px) { nav.side { flex: 0 0 240px; } }
.brand { font-size: 22px; font-weight: 700; letter-spacing: -.02em; padding: 0 6px; }
.navlabel { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 6px 4px; }
.navgroup { display: flex; flex-direction: column; gap: 2px; }
.navbtn { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px 0 12px; border: 0; border-left: 3px solid transparent; border-radius: 0 8px 8px 0; background: transparent; text-align: left; font-size: 14px; }
.navbtn.sub { padding-left: 24px; }
.navbtn[aria-current=page] { background: var(--green-bg); border-left-color: var(--green); font-weight: 600; }
.navbtn:hover { background: var(--soft); }
.count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.soon { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line2); border-radius: 6px; padding: 1px 6px; }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 600; font-size: 14px; width: 100%; }
.track { width: 40px; height: 22px; border-radius: 11px; background: #B9C4C0; display: inline-flex; align-items: center; padding: 2px; }
.track span { width: 18px; height: 18px; border-radius: 9px; background: #fff; }
.track.on { background: var(--green); justify-content: flex-end; }
select.biz { width: 100%; }

main.content { flex: 999 1 640px; min-width: 0; padding: 18px clamp(12px, 2vw, 24px) 32px; display: flex; flex-direction: column; gap: 14px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.pagehead h1 { margin: 0; font-size: 24px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line2); background: #fff; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.tab[aria-selected=true] { background: var(--ink); color: #fff; border-color: var(--ink); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.cols { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) minmax(220px, 280px); gap: 14px; align-items: start; }
@media (max-width: 1180px) { .cols { grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); } .cols .side3 { grid-column: 1 / -1; } }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
.list { display: flex; flex-direction: column; max-height: calc(100vh - 210px); overflow: auto; }
.row { display: flex; gap: 10px; padding: 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; width: 100%; }
.row:hover { background: var(--soft); }
.row[aria-current=true] { background: var(--green-bg); }
.avatar { position: relative; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 20px; background: #DCE6E2; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--ink2); overflow: visible; }
.avatar img { width: 40px; height: 40px; border-radius: 20px; object-fit: cover; }
.badge { position: absolute; right: -6px; bottom: -4px; font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 5px; border: 2px solid #fff; line-height: 1.2; }
.badge.IG { background: var(--ig); color: #fff; } .badge.FB { background: var(--fb); color: #fff; } .badge.WA { background: var(--wa); color: var(--wa-ink); }
.rowmain { flex: 1 1 auto; min-width: 0; }
.rowtop { display: flex; justify-content: space-between; gap: 8px; }
.rowname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: 12px; font-weight: 600; border-radius: 6px; padding: 1px 7px; background: var(--soft); color: var(--ink2); }
.chip.person { background: var(--amber-bg); color: var(--amber-ink); }
.chip.ready { background: var(--green-bg); color: var(--green-dk); }
.chip.auto { background: #EDE3F5; color: #4F2C6E; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }

.thread { display: flex; flex-direction: column; min-height: 420px; }
.threadhead { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.msgs { padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow: auto; }
.msg { max-width: 78%; padding: 9px 12px; border-radius: 14px; background: var(--soft); white-space: pre-wrap; word-wrap: break-word; }
.msg.out { align-self: flex-end; background: var(--green-bg); }
.msgmeta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.att { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.att img { max-width: 240px; max-height: 240px; border-radius: 8px; border: 1px solid var(--line); }
.att audio { max-width: 260px; }
.att .read { font-size: 13px; background: #fff; border: 1px dashed var(--line2); border-radius: 8px; padding: 6px 8px; }
.draft { margin: 0 16px 12px; border: 1px solid #9CC7BA; background: #F6FBF9; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.draft.person { border-color: var(--amber-line); background: #FFF8EE; }
.draft h3 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--green-dk); }
.draft.person h3 { color: var(--amber-ink); }
.draft ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.composer { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.window { font-size: 13px; padding: 6px 10px; border-radius: 8px; background: var(--soft); }
.window.warn { background: var(--amber-bg); color: var(--amber-ink); }
.window.stop { background: var(--red-bg); color: var(--red); }
.card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.card h2 { margin: 0; font-size: 17px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.post { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.post img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; }
.comment { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.comment.hiddenc { opacity: .6; }
.ok { color: var(--green); font-weight: 700; } .bad { color: var(--red); font-weight: 700; }
table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple th, table.simple td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tablebox { overflow-x: auto; }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; max-width: 520px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(21, 32, 29, .45); }
dialog .card { gap: 12px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 14px; }
.checkgrid label { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
