:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --brand: #1d4ed8;
  --brand-2: #1e40af;
  --accent: #38bdf8;
  --bg: #f3f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --ink: #0f172a;
  --muted: #64748b;
  --danger: #b42318;
  --warn: #b54708;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'IBM Plex Sans', system-ui, sans-serif; color: var(--ink); background: var(--bg); }
.serif { font-family: 'IBM Plex Serif', Georgia, serif; }
a { color: inherit; text-decoration: none; }
code { font-family: 'IBM Plex Mono', monospace; font-size: .85em; background: #eef2f6; padding: .1rem .35rem; border-radius: 4px; }

/* Layout */
.sidebar { background: linear-gradient(180deg, var(--navy) 0%, #0a1f3b 100%); color: #cbd5e1; width: 260px; }
.sidebar .brand { border-bottom: 1px solid rgba(255,255,255,.08); }
.nav-group { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: #7f93b2; padding: 1.1rem 1.25rem .4rem; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: .75rem; padding: .58rem 1.25rem; margin: 0 .6rem; border-radius: 6px; font-size: .9rem; color: #cbd5e1; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.on { background: rgba(56,189,248,.14); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-link i { width: 18px; text-align: center; opacity: .85; }
.nav-badge { margin-left: auto; background: var(--accent); color: #082f49; font-size: .7rem; font-weight: 700; border-radius: 999px; padding: 0 .45rem; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); height: 64px; }
.page-title { font-family: 'IBM Plex Serif', Georgia, serif; font-weight: 600; font-size: 1.35rem; color: var(--navy); }
.crumb { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* Grid children must be allowed to shrink, or charts and wide tables push the page sideways. */
.grid > * { min-width: 0; }
canvas { max-width: 100%; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-h { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-size: .98rem; font-weight: 600; color: var(--navy); }
.card-b { padding: 1.25rem; }
.kpi { padding: 1.1rem 1.25rem; }
.kpi .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi .value { font-size: 1.85rem; font-weight: 600; color: var(--navy); margin-top: .3rem; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.kpi .icon { width: 38px; height: 38px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }

/* Forms */
.inp, select.inp, textarea.inp { width: 100%; padding: .55rem .8rem; border-radius: 6px; background: #fff; border: 1px solid #cbd5e1; outline: none; color: var(--ink); font: inherit; font-size: .9rem; }
.inp:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.inp[readonly] { background: #f8fafc; }
label.l { display: block; font-size: .78rem; color: #334155; margin-bottom: .3rem; font-weight: 500; }
.hint { font-size: .75rem; color: var(--muted); margin-top: .25rem; }
.chk { display: flex; align-items: center; gap: .5rem; font-size: .88rem; }

/* Buttons */
.btn { padding: .52rem .95rem; border-radius: 6px; font-weight: 500; font-size: .87rem; display: inline-flex; align-items: center; gap: .45rem; border: 1px solid transparent; cursor: pointer; white-space: nowrap; font-family: inherit; }
.btn-p { background: var(--brand); color: #fff; } .btn-p:hover { background: var(--brand-2); }
.btn-s { background: #fff; border-color: #cbd5e1; color: #1e293b; } .btn-s:hover { background: #f8fafc; }
.btn-d { background: #fff; border-color: #fecdca; color: var(--danger); } .btn-d:hover { background: #fef3f2; }
.btn-n { background: var(--navy); color: #fff; } .btn-n:hover { background: var(--navy-2); }
.btn-sm { padding: .32rem .6rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { color: var(--muted); padding: .3rem .45rem; border-radius: 5px; } .icon-btn:hover { background: #f1f5f9; color: var(--ink); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 600; color: #475569; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; padding: .7rem 1rem; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: .7rem 1rem; border-bottom: 1px solid #eef2f6; font-size: .88rem; vertical-align: middle; }
.tbl tbody tr:hover { background: #fafbfd; }
.tbl tr.click { cursor: pointer; }

/* Badges */
.pill { font-size: .7rem; padding: .16rem .55rem; border-radius: 999px; font-weight: 600; display: inline-block; text-transform: capitalize; border: 1px solid transparent; white-space: nowrap; }
.p-green { background: #ecfdf3; color: #067647; border-color: #abefc6; }
.p-blue { background: #eff8ff; color: #175cd3; border-color: #b2ddff; }
.p-amber { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.p-red { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.p-gray { background: #f2f4f7; color: #475467; border-color: #e4e7ec; }
.p-navy { background: #eef4ff; color: #1d2e5c; border-color: #c7d7fe; }
.tag { font-size: .72rem; padding: .1rem .5rem; border-radius: 4px; background: #eef2f6; color: #334155; margin: 0 .2rem .2rem 0; display: inline-block; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .6rem 1rem; font-size: .88rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; }
.tabs a.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }

/* Progress */
.bar { height: 6px; background: #eef2f6; border-radius: 999px; overflow: hidden; display: flex; }
.bar > span { height: 100%; }

/* Modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(11,37,69,.45); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 720px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.lg { max-width: 1040px; }
.modal-h { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-h h3 { margin: 0; font-family: 'IBM Plex Serif', Georgia, serif; color: var(--navy); font-size: 1.1rem; }
.modal-b { padding: 1.25rem; }
.modal-f { padding: .9rem 1.25rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; background: #f8fafc; border-radius: 0 0 12px 12px; }
.toast { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); padding: .75rem 1rem; border-radius: 8px; font-size: .88rem; box-shadow: 0 8px 24px rgba(15,23,42,.12); max-width: 380px; }
.toast.err { border-left-color: var(--danger); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty i { font-size: 2rem; color: #cbd5e1; margin-bottom: .75rem; display: block; }
.banner { border: 1px solid #fedf89; background: #fffcf5; border-radius: 10px; padding: 1rem 1.25rem; }

/* Inbox */
.chat-list a { display: block; padding: .8rem 1rem; border-bottom: 1px solid #eef2f6; }
.chat-list a:hover { background: #f8fafc; }
.chat-list a.on { background: #eff6ff; box-shadow: inset 3px 0 0 var(--brand); }
.chat-bg { background: #f6f8fb; }
.bubble { max-width: 75%; padding: .55rem .8rem; border-radius: 12px; font-size: .9rem; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.bubble.in { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.out { background: var(--brand); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.bubble .meta { font-size: .68rem; opacity: .7; margin-top: .25rem; text-align: right; }

.inbox-grid { height: calc(100vh - 170px); min-height: 520px; display: grid; grid-template-columns: minmax(260px, 320px) 1fr; }
@media (min-width: 1024px) { .inbox-grid.with-info { grid-template-columns: minmax(260px, 320px) 1fr minmax(240px, 280px); } }
@media (max-width: 767px) { .inbox-grid { grid-template-columns: 1fr; } }

@media (max-width: 767px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
}

/* Phone */
.phone-fab { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 55; width: 58px; height: 58px; border-radius: 50%; background: var(--brand); color: #fff; border: 0; box-shadow: 0 10px 25px rgba(29,78,216,.35); font-size: 1.35rem; cursor: pointer; }
.phone-fab .dot { position: absolute; top: 4px; right: 4px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; background: #94a3b8; }
.phone-fab .dot.ready { background: #22c55e; }
.phone-fab .dot.error { background: #ef4444; }
.phone-panel { position: fixed; right: 1.25rem; bottom: 5.5rem; z-index: 56; width: 320px; max-width: calc(100vw - 2rem); background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 50px rgba(15,23,42,.25); overflow: hidden; }
.phone-head { background: linear-gradient(160deg, var(--navy), var(--navy-2)); color: #fff; padding: .9rem 1rem; }
.phone-num { width: 100%; font-size: 1.45rem; text-align: center; border: 0; outline: none; font-family: 'IBM Plex Mono', monospace; letter-spacing: .04em; padding: .5rem 0; color: var(--ink); background: transparent; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.key { height: 54px; border-radius: 12px; background: #f1f5f9; border: 0; font-size: 1.3rem; font-weight: 500; color: var(--ink); cursor: pointer; font-family: inherit; line-height: 1; }
.key small { display: block; font-size: .55rem; letter-spacing: .14em; color: var(--muted); margin-top: 2px; }
.key:hover { background: #e2e8f0; } .key:active { transform: scale(.97); }
.keypad.big .key { height: 68px; font-size: 1.6rem; }
.round { width: 56px; height: 56px; border-radius: 50%; border: 0; color: #fff; font-size: 1.25rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.round.green { background: #16a34a; } .round.red { background: #dc2626; } .round.gray { background: #e2e8f0; color: var(--ink); } .round.gray.on { background: var(--navy); color: #fff; }
.round:disabled { opacity: .45; cursor: not-allowed; }
.ring { animation: ring 1.2s infinite; }
@keyframes ring { 0%,100% { box-shadow: 0 0 0 0 rgba(22,163,74,.5); } 50% { box-shadow: 0 0 0 14px rgba(22,163,74,0); } }
audio { height: 34px; max-width: 240px; }
