/* opendott.in WhatsApp API - shared admin + client dashboard styles.
   Plain CSS, no build step - matches the rest of the Opendott PHP apps. */

:root {
    --brand: #128C7E;       /* WhatsApp-adjacent teal, matches the product */
    --brand-dark: #0b6a5f;
    --ink: #1b1f23;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f6f7f9;
    --card: #ffffff;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: var(--ink);
    color: #fff;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.topbar .brand { font-weight: 700; color: #fff; letter-spacing: .2px; }
.topbar .brand span { color: #6ee7db; }
.topbar nav a { color: #d1d5db; margin-left: 20px; font-size: 14px; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar .who { color: #9ca3af; font-size: 13px; margin-right: 16px; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}
.container.narrow { max-width: 460px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
}

.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
    .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; }
}

.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }

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

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.active, .badge.sent, .badge.delivered, .badge.read, .badge.credit { background: var(--success-bg); color: var(--success); }
.badge.suspended, .badge.failed, .badge.debit { background: var(--danger-bg); color: var(--danger); }
.badge.queued, .badge.received { background: var(--warn-bg); color: var(--warn); }

form .field { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; }
.help { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

.btn {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f3f4f6; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.flash.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.flash.info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

code, pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: #f3f4f6;
    border-radius: 6px;
}
code { padding: 2px 6px; font-size: 13px; }
pre { padding: 14px; overflow-x: auto; font-size: 13px; line-height: 1.5; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.actions { display: flex; gap: 10px; align-items: center; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key-reveal {
    background: #0b1220;
    color: #6ee7db;
    padding: 14px 16px;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    word-break: break-all;
    margin: 10px 0;
}

/* ------------------------------------------------------------------ portal
   Sidebar shell for the WhatsApp Business portal (portal_start/portal_end).
   Reuses the teal brand colour as the sidebar ground. */
.portal { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
    width: 248px; flex: 0 0 248px;
    background: linear-gradient(180deg, var(--brand), var(--brand-dark));
    color: #eafaf6; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { font-weight: 800; font-size: 20px; letter-spacing: .3px; padding: 20px 20px 14px; color: #fff; }
.sidebar-brand span { color: #bff3e7; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 12px; overflow-y: auto; flex: 1; }
.side-link {
    display: flex; align-items: center; justify-content: space-between;
    color: #d7f5ee; text-decoration: none; padding: 10px 12px; border-radius: 9px;
    font-size: 14.5px; transition: background .15s, color .15s;
}
.side-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.side-link.active { background: #fff; color: var(--brand-dark); font-weight: 700; }
.side-link.small { font-size: 13px; color: #b7e6db; padding: 8px 12px; }
.side-link .soon-tag {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
    background: rgba(255,255,255,.18); color: #eafaf6; padding: 2px 7px; border-radius: 999px;
}
.sidebar-divider { height: 1px; background: rgba(255,255,255,.16); margin: 10px 6px; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.14); }
.plan-card { background: rgba(0,0,0,.16); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.plan-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: #bff3e7; }
.plan-balance { font-size: 22px; font-weight: 800; color: #fff; margin-top: 2px; }
.plan-sub { font-size: 12px; color: #9fded0; }

.portal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.portal-topbar {
    display: flex; align-items: center; gap: 14px;
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: 14px 24px; position: sticky; top: 0; z-index: 5;
}
.portal-title { font-weight: 700; font-size: 17px; flex: 1; }
.portal-topbar .who { color: var(--muted); font-size: 13.5px; }
.portal-burger { display: none; font-size: 22px; cursor: pointer; line-height: 1; user-select: none; }
.portal-body { padding: 24px; max-width: 1100px; width: 100%; }

/* mobile: sidebar slides in via the hidden checkbox toggle */
@media (max-width: 860px) {
    .portal-burger { display: inline-block; }
    .sidebar {
        position: fixed; z-index: 40; left: 0; top: 0; height: 100vh;
        transform: translateX(-100%); transition: transform .25s ease;
        box-shadow: 0 20px 60px rgba(0,0,0,.35);
    }
    .portal-nav-toggle:checked ~ .portal .sidebar { transform: none; }
}

/* ------------------------------------------------------------------ portal pages
   Everything below is for the full WhatsApp Business portal (Phases 1-6). */
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
h3 { font-size: 14.5px; margin: 16px 0 8px; }
form.inline { display: inline; margin: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.linkish { background: none; border: none; color: var(--brand-dark); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 6px 0; font-size: 14px; }
.check input { width: auto; margin: 0; }
.errlist { margin: 6px 0 0 18px; padding: 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 3px 0; }
pre.code { background: #0b1220; color: #d1fae5; padding: 12px; border-radius: 8px; font-size: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; }
pre.tpl-text { background: #f8fafc; border: 1px solid var(--border); padding: 12px; border-radius: 8px; white-space: pre-wrap; font-family: inherit; font-size: 13.5px; margin: 0 0 12px; }
a.link-stat { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
a.link-stat:hover { border-color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px; background: #fff; border: 1px solid var(--border); color: var(--ink); font-size: 13px; text-decoration: none; cursor: pointer; }
.chip input { width: auto; margin: 0; }
.chip.active, .chip:hover { border-color: var(--brand); color: var(--brand-dark); text-decoration: none; }
.chip.active { background: #e7f6f3; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 150px; }
.bulk-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.bulk-bar select, .bulk-bar input[type=text] { width: auto; }
.kv-row { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-bottom: 8px; }

.progress { height: 8px; background: #eef2f5; border-radius: 999px; overflow: hidden; }
.progress.big { height: 14px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--brand), #34d399); border-radius: 999px; transition: width .4s; }

.map-row { display: grid; grid-template-columns: 1.1fr 1.2fr 1fr; gap: 8px; }
.sample { margin-bottom: 10px; }
.review { border-color: var(--brand); }

.hours-grid { display: grid; gap: 8px; margin-top: 8px; }
.hours-row { display: grid; grid-template-columns: 110px 130px 30px 130px auto; gap: 8px; align-items: center; }
.hours-row input[type=time] { width: 100%; }

/* ---- daily chart (pure CSS, no chart library) */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 190px; padding-top: 10px; overflow-x: auto; }
.bar-col { flex: 1 0 14px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-stack { position: relative; flex: 1; width: 100%; max-width: 34px; }
.bar { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 4px 4px 0 0; }
.bar.out { background: #d1f0ea; }
.bar.del { background: var(--brand); left: 20%; right: 20%; }
.bar.fail { background: var(--danger); left: 38%; right: 38%; }
.bar-label { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.legend { display: flex; gap: 6px; align-items: center; margin-top: 8px; color: var(--muted); }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.lg.out { background: #d1f0ea; }
.lg.del { background: var(--brand); }
.lg.fail { background: var(--danger); }

/* ---- sidebar extras */
.count-tag { background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; min-width: 20px; text-align: center; }
.side-link.sub { font-size: 13px; padding: 6px 12px 6px 26px; color: #c8efe6; }
.side-link.as-button { width: 100%; background: none; border: none; cursor: pointer; font: inherit; text-align: left; }
.plan-card.low { background: rgba(185, 28, 28, .35); }
.plan-topup { color: #fff; text-decoration: underline; }
.act-banner { background: #fef3c7; color: #92400e; border-bottom: 1px solid #fde68a; padding: 9px 24px; font-size: 13.5px; }

/* ---- template builder */
.tpl-builder { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.tpl-preview { position: sticky; top: 84px; }
@media (max-width: 1100px) { .tpl-builder { grid-template-columns: 1fr; } .tpl-preview { position: static; } }
.btn-row { display: grid; grid-template-columns: 150px 1fr 1.4fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.btn-row [hidden] { display: none; }
.wa-phone { border-radius: 22px; border: 8px solid #1b1f23; overflow: hidden; background: #efe7dc; box-shadow: 0 20px 40px rgba(0,0,0,.15); }
.wa-top { background: #075e54; color: #fff; padding: 12px 14px; font-weight: 600; font-size: 14px; }
.wa-chat { padding: 14px 10px 18px; min-height: 380px; background: #efe7dc radial-gradient(#e3d9cc 1px, transparent 1px) 0 0 / 14px 14px; }
.wa-bubble { background: #fff; border-radius: 8px 8px 8px 2px; padding: 8px 10px 18px; font-size: 13.5px; line-height: 1.45; position: relative; max-width: 100%; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.wa-bubble.static { padding-bottom: 8px; border: 1px solid var(--border); }
.wa-header { font-weight: 700; margin-bottom: 4px; }
.wa-header .media-ph { background: #cfd8dc; border-radius: 6px; height: 120px; display: flex; align-items: center; justify-content: center; color: #546e7a; font-size: 12px; font-weight: 600; margin: -2px -4px 6px; }
.wa-footer { color: #8696a0; font-size: 12px; margin-top: 4px; }
.wa-time { position: absolute; right: 8px; bottom: 3px; font-size: 10.5px; color: #8696a0; }
.wa-buttons { display: grid; gap: 4px; margin-top: 4px; }
.wa-btn { background: #fff; border-radius: 8px; text-align: center; padding: 8px; color: #00a5f4; font-size: 13.5px; font-weight: 500; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.var-chip { background: #dcf8c6; border-radius: 4px; padding: 0 3px; }

/* ---- inbox */
.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - 140px); min-height: 520px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.conv-pane { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.conv-search, .conv-new { display: flex; gap: 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); }
.conv-new input, .conv-search input[type=text] { flex: 1; }
.conv-list { overflow-y: auto; flex: 1; }
.conv-item { display: block; padding: 11px 14px; border-bottom: 1px solid #f1f3f5; color: inherit; text-decoration: none; }
.conv-item:hover { background: #f8fafb; text-decoration: none; }
.conv-item.active { background: #e7f6f3; }
.conv-top, .conv-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv-preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-window { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.conv-window.open { color: var(--success); }
.thread-pane { display: flex; flex-direction: column; min-height: 0; background: #efe7dc radial-gradient(#e3d9cc 1px, transparent 1px) 0 0 / 14px 14px; }
.thread-empty { display: flex; align-items: center; justify-content: center; flex: 1; }
.thread-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--border); }
.window-pill { font-size: 12.5px; padding: 5px 11px; border-radius: 999px; background: #fef2f2; color: var(--danger); font-weight: 600; white-space: nowrap; }
.window-pill.open { background: var(--success-bg); color: var(--success); }
.thread { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.day-sep { text-align: center; margin: 8px 0; }
.day-sep span { background: #e1f3fb; color: #54656f; font-size: 11.5px; padding: 3px 10px; border-radius: 6px; }
.msg { max-width: 70%; padding: 7px 10px 5px; border-radius: 8px; font-size: 14px; line-height: 1.45; box-shadow: 0 1px 1px rgba(0,0,0,.08); word-wrap: break-word; }
.msg.in { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.msg.out { align-self: flex-end; background: #d9fdd3; border-top-right-radius: 2px; }
.msg.failed { background: #fee2e2; }
.msg-img { max-width: 260px; max-height: 260px; border-radius: 6px; display: block; margin-bottom: 4px; }
.msg-doc { display: inline-block; padding: 6px 0; font-weight: 600; }
.msg-meta { font-size: 11px; color: #667781; text-align: right; margin-top: 2px; }
.msg-meta .read { color: #53bdeb; }
.msg-error { font-size: 11.5px; color: var(--danger); margin-top: 2px; }
.composer { background: #f0f2f5; padding: 10px 14px; border-top: 1px solid var(--border); }
.composer-form textarea { min-height: 46px; resize: vertical; }
.composer-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.attach { cursor: pointer; font-size: 20px; }
.quick-replies { margin-bottom: 8px; width: auto; }
.tpl-pick { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.tpl-pick select { width: auto; }
@media (max-width: 860px) {
    .inbox { grid-template-columns: 1fr; height: auto; }
    .inbox:not([data-phone=""]) .conv-pane { display: none; }
    .inbox[data-phone=""] .thread-pane { display: none; }
    .thread { max-height: 60vh; }
    .msg { max-width: 88%; }
    .map-row, .btn-row, .hours-row { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ admin
   The admin panel uses the portal's sidebar shell in dark colours, so it is
   always obvious whether you're in admin or inside a client's portal. */
.sidebar.admin { background: linear-gradient(180deg, #1f2937, #111827); }
.sidebar.admin .side-link.active { color: #111827; }
.sidebar.admin .sidebar-brand span { color: #6ee7db; }
.sidebar-mode { font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: #9ca3af; margin-top: 2px; }
.side-who { color: #d1d5db; font-size: 13px; padding: 4px 12px 8px; }

.back-link { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.align-start { align-items: start; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.card.reveal { border: 2px solid var(--brand); background: #f3fbf9; }

/* stat cards with a small line underneath */
.stats { margin-bottom: 20px; }
.stat .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.stat .value-sm { font-size: 16px; padding: 4px 0 2px; }
.stat.warn { border-color: #fcd34d; background: var(--warn-bg); }
@media (max-width: 480px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* setup checklist */
.card.setup { border-color: #99e0d3; }
.card.setup .progress { margin-bottom: 8px; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.step:last-child { border-bottom: none; padding-bottom: 0; }
.step-dot { flex: 0 0 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: #eef2f5; color: var(--muted); }
.step.done .step-dot { background: var(--success-bg); color: var(--success); }
.step.done strong { color: var(--muted); font-weight: 500; }
.step-body { flex: 1; min-width: 0; }
.step-do { flex: 0 0 auto; }

/* key/value lists */
dl.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 9px 14px; margin: 14px 0 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.number-hero { padding: 4px 0 2px; }
.number-big { font-size: 24px; font-weight: 700; letter-spacing: .3px; }
details.tech { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
details.tech summary { cursor: pointer; color: var(--muted); font-size: 13.5px; font-weight: 600; }
details.tech dl.kv { font-size: 13px; }

/* rows of "thing + what you can do about it" */
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.access-row:last-child { border-bottom: none; }
.card > h2 + .access-row { padding-top: 0; }
.notes { margin-top: 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-size: 14px; }
.card.danger-zone { border-color: #fecaca; }
.card.danger-zone .access-row { padding: 0; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -6px 0 12px; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 12px 10px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* clickable table rows (clients list) */
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #f8fafb; }
.cell-sub { color: var(--muted); font-size: 12.5px; }

/* "needs attention" list on the admin overview */
.attention { list-style: none; margin: 0; padding: 0; }
.attention li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.attention li:last-child { border-bottom: none; }
.attention .why { color: var(--muted); font-size: 13px; }
.empty-ok { color: var(--success); font-weight: 600; }
@media (max-width: 860px) { dl.kv { grid-template-columns: 1fr; gap: 2px; } dl.kv dd { margin-bottom: 8px; } }
.badge.neutral { background: #f1f3f5; color: #4b5563; }
.dir { display: inline-block; min-width: 30px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.crumbs a { color: var(--muted); font-weight: 500; }

/* ---- Opendott logo (dark wordmark, so it sits on a white tile) */
.logo-tile { display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 12px; line-height: 0; }
.logo-tile img { display: block; width: auto; }
.topbar .brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.topbar .logo-tile { padding: 3px 10px; border-radius: 8px; }
.topbar .logo-tile img { height: 44px; }
.topbar { height: 64px; }
.brand-label { color: #d1d5db; font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.sidebar-brand { padding: 18px 16px 12px; }
.sidebar-brand .logo-tile { padding: 10px 12px; }
.sidebar-brand .logo-tile img { height: 78px; }
.sidebar-brand .sidebar-mode { margin-top: 10px; text-align: center; }
.sidebar:not(.admin) .sidebar-mode { color: #bff3e7; }
.login-logo { text-align: center; margin: 4px 0 14px; }
.login-logo img { height: 96px; width: auto; }
.login-wrap .card h1 { text-align: center; }
.login-wrap .card h1 + .subtitle { text-align: center; }

/* ---- users & roles */
.side-role { display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; background: rgba(255,255,255,.14); color: #e5e7eb; padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.update-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #fee2e2; color: #991b1b; border-bottom-color: #fecaca; }
.badge.role-owner { background: #ede9fe; color: #6d28d9; }
.badge.role-manager { background: #e0f2fe; color: #0369a1; }
.role-help { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.role-help li { padding: 4px 0; color: var(--muted); }
.role-help strong { color: var(--ink); display: inline-block; min-width: 72px; }
.user-form { display: grid; grid-template-columns: 1fr 1.2fr 1fr auto; gap: 10px; align-items: end; }
.user-form .field { margin-bottom: 0; }
@media (max-width: 860px) { .user-form { grid-template-columns: 1fr; } }
.log-lines { background: #0b1220; color: #d1fae5; padding: 12px 14px; border-radius: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; white-space: pre-wrap; }
.side-link.small.active { color: var(--brand-dark); font-weight: 700; }

/* ---- cost report */
.range-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; }
.range-bar .chips { margin: 0; }
.range-custom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range-custom input[type=date] { width: auto; }
.range-custom label { margin: 0; font-weight: 500; }
.stat.highlight { border-color: var(--brand); background: #f3fbf9; }
tr.total-row td { font-weight: 700; border-top: 2px solid var(--border); background: #fafbfc; }
tr.quiet td { color: #9ca3af; }
.chips.mb-0 { margin-bottom: 0; }

/* ---- modal popup (admin Cost report) */
body.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(17, 24, 39, .55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: var(--bg); border-radius: 14px; width: min(1180px, 100%); height: min(92vh, 1000px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--border); }
.modal-tools { display: flex; gap: 8px; }
.modal-frame { flex: 1; width: 100%; border: 0; background: var(--bg); }
@media (max-width: 720px) { .modal-backdrop { padding: 0; } .modal { height: 100vh; border-radius: 0; } }

/* page rendered inside the modal */
body.embed { background: var(--bg); }
.embed-body { padding: 20px 24px 40px; }
.rates-card { border-color: #c7d2fe; background: #f8f9ff; }
.rates-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 14px; align-items: start; }
.rates-row .btn { margin-top: 25px; }
.rates-row .field { margin-bottom: 0; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: flex; align-items: center; padding: 0 10px; background: #eef0f4; border: 1px solid var(--border); border-right: 0; border-radius: 8px 0 0 8px; color: var(--muted); }
.input-prefix input { border-radius: 0 8px 8px 0; }
.stat .value-md { font-size: 20px; }
@media (max-width: 860px) { .rates-row { grid-template-columns: 1fr; } .rates-row .btn { margin-top: 0; } }
.price-lines { display: flex; flex-wrap: wrap; gap: 4px 12px; font-weight: 400; font-size: 14px; }
