/* ==========================================================================
   Sapa's dashboard: what admin.css does not have.
   Colour only for status (tones below). Nothing here redefines admin.css;
   it only adds. The flat paper-and-pine look itself is in theme.css.
   ========================================================================== */

/* ---- permissions: body gets can-<perm> classes; elements opt in with data-perm */
body:not(.can-read) [data-perm="read"],
body:not(.can-write) [data-perm="write"],
body:not(.can-qa) [data-perm="qa"],
body:not(.can-manage) [data-perm="manage"],
body:not(.can-team) [data-perm="team"],
body:not(.can-database) [data-perm="database"],
body:not(.can-desk) [data-perm="desk"] { display: none !important; }

.view[hidden], .cp-sub[hidden] { display: none !important; }

/* ---- status tones (Kelar's names) */
.badge.tone-info { background: #f1eefa; color: #422082; }
.badge.tone-violet { background: var(--info-bg); color: var(--info); }
.badge.tone-ok { background: var(--ok-bg); color: var(--ok); }
.badge.tone-warn { background: var(--warn-bg); color: var(--warn); }
.badge.tone-danger { background: var(--danger-bg); color: var(--danger); }
.badge.tone-teal { background: #f1fad9; color: #3a4f00; }
.badge.tone-neutral { background: #e5e7eb; color: #1f1633; }
.badge.tone-brand { background: var(--grad-soft); color: #b0124f; border: 1px solid rgba(176, 18, 79, 0.14); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.badge-sm { padding: 2px 8px; font-size: 12px; }

/* ---- sidebar: two-line campaign items */
.sidebar .nav-item .nav-text { display: grid; min-width: 0; flex: 1; }
.sidebar .nav-item .nav-name { font-weight: 600; }
.sidebar .nav-item .nav-sub { font-size: 12px; color: #5f5870; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
.sidebar .nav-item.active .nav-sub { color: rgba(255, 255, 255, 0.78); }
.sidebar .nav-item .nav-status { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: #5f5870; }
.sidebar .nav-item .nav-status.active { background: #4a6500; box-shadow: 0 0 0 3px rgba(74, 101, 0, 0.18); }
.sidebar .nav-item .nav-status.paused { background: #5e4a72; }
.sidebar .nav-item .nav-status.draft { background: #5f5870; }
.sidebar .nav-item .nav-status.done { background: #422082; }
.sidebar .nav-item.is-done:not(.active) { color: #5f5870; }
.nav-search { position: relative; margin: 0 0 8px; }
.nav-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #5f5870; pointer-events: none; }
.nav-search input { width: 100%; min-height: 38px; padding: 8px 10px 8px 32px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.06); color: #fff; font-size: 13px; }
.nav-search input::placeholder { color: #5f5870; }
.nav-search input:focus { outline: none; border-color: rgba(176, 18, 79, 0.7); background: rgba(255, 255, 255, 0.1); }
.sidebar .nav-group .nav-more { width: 100%; border: none; background: none; color: #b0124f; font-size: 12px; font-weight: 600; padding: 6px 12px; text-align: left; cursor: pointer; }
.sidebar .nav-group .nav-more:hover { color: #fff; }

/* ---- topbar */
.topbar-text { min-width: 0; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.saving-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--info); background: var(--info-bg); padding: 6px 12px; border-radius: 4px; }
.saving-pill::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.topbar .sub.is-stale::before { background: #5e4a72; box-shadow: 0 0 0 3px rgba(94, 74, 114, 0.18); animation: none; }

/* ---- overview */
.ov-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 28px 30px; margin-bottom: 22px; border-radius: var(--r-xl); color: #fff; background: linear-gradient(135deg, #2f1760 0%, #2f1760 55%, #2f1760 100%); border: 1px solid rgba(255, 255, 255, 0.08); box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.ov-hero .hero-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-top: 18px; }
.ov-hero .hero-num { padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1); }
.ov-hero .hero-num b { display: block; font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: 0; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ov-hero .hero-num span { display: block; font-size: 12px; color: rgba(255, 255, 255, 0.7); margin-top: 4px; font-weight: 500; }
@media (max-width: 1100px) { .ov-hero { grid-template-columns: 1fr; } }

.cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; margin-bottom: 20px; }
.cp-card { position: relative; display: grid; gap: 12px; padding: 18px; border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-md); cursor: pointer; transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), border-color var(--t-fast); }
.cp-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: rgba(176, 18, 79, 0.35); }
.cp-card:focus-visible { outline: none; box-shadow: var(--ring); }
.cp-card.is-done { background: rgba(255, 255, 255, 0.55); }
.cp-card .cc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cp-card .cc-name { font-family: var(--font-display); font-size: 15.5px; font-weight: 700; letter-spacing: 0; line-height: 1.3; }
.cp-card .cc-sub { font-size: 13px; color: var(--ink-3); margin-top: 3px; }
.cp-card .cc-dates { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-3); font-weight: 500; flex-wrap: wrap; }
.cp-card .cc-dates b { color: var(--ink-2); font-weight: 700; }
.cp-targets { display: grid; gap: 10px; }
.tgt { display: grid; gap: 5px; }
.tgt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; }
.tgt-head .tgt-label { font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tgt-head .tgt-num { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tgt-head .tgt-num small { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.tgt-bar { height: 7px; border-radius: 4px; background: rgba(0, 0, 0, 0.08); overflow: hidden; }
.tgt-bar i { display: block; height: 100%; border-radius: inherit; background: var(--grad-bright); width: 0; transition: width 0.7s var(--ease-out); }
.tgt-bar i.behind { background: linear-gradient(90deg, #5e4a72, #b0124f); }
.tgt-bar i.done { background: linear-gradient(90deg, #4a6500, #3a4f00); }
.tgt-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); flex-wrap: wrap; }
.pace { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.pace.on { background: var(--ok-bg); color: var(--ok); }
.pace.behind { background: var(--warn-bg); color: var(--warn); }
.pace.done { background: var(--ok-bg); color: var(--ok); }
.pace.na { background: #e5e7eb; color: var(--ink-3); }

.funnel { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }
.funnel .fn { flex: 1 1 88px; min-width: 88px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.7); border: 1px solid var(--line); display: grid; align-content: start; gap: 2px; position: relative; }
.funnel .fn b { font-family: var(--font-display); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.funnel .fn span { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.3; }
.funnel .fn.hi { background: var(--grad-soft); border-color: rgba(176, 18, 79, 0.18); }
.funnel.lg .fn { flex: 1 1 120px; padding: 14px 16px; }
.funnel.lg .fn b { font-size: 24px; }
.funnel.lg .fn span { font-size: 12px; }
.funnel.lg .fn small { font-size: 12px; color: var(--ink-3); }

.ov-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.ov-filters .toolbar-spacer { flex: 1; }
.ov-table td.col-targets { white-space: normal; min-width: 220px; }
.ov-table .mini-tgt { display: grid; grid-template-columns: minmax(80px, 1fr) 60px auto; gap: 8px; align-items: center; font-size: 12px; }
.ov-table .mini-tgt .tgt-bar { height: 5px; }
.clickable-row { cursor: pointer; }

/* ---- campaign head */
.cp-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.cp-head .chip { cursor: default; }
.cp-head .chip.chip-pill::before { display: none; }

/* ---- dashboard tab */
.tgt-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tgt-card { padding: 18px 20px; border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-md); display: grid; gap: 10px; position: relative; overflow: hidden; }
.tgt-card::before { content: ""; position: absolute; left: 20px; right: 20px; top: -1px; height: 3px; border-radius: 0 0 3px 3px; background: var(--grad-bright); }
.tgt-card.behind::before { background: linear-gradient(90deg, #5e4a72, #b0124f); }
.tgt-card.done::before { background: linear-gradient(90deg, #4a6500, #3a4f00); }
.tgt-card .tc-label { font-size: 13px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.tgt-card .tc-num { font-family: var(--font-display); font-size: 32px; font-weight: 700; letter-spacing: 0; line-height: 1; font-variant-numeric: tabular-nums; }
.tgt-card .tc-num small { font-size: 16px; color: var(--ink-3); font-weight: 600; }
.tgt-card .tc-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; color: var(--ink-3); }
.tgt-card .tc-facts b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.kpi { padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.75); border: 1px solid var(--line); }
.kpi b { display: block; font-family: var(--font-display); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi span { display: block; font-size: 12px; color: var(--ink-3); margin-top: 3px; font-weight: 600; }
.lvl-list { display: grid; gap: 6px; }
.lvl-list .lvl { display: grid; grid-template-columns: 110px 1fr 36px; gap: 10px; align-items: center; font-size: 13px; }
.lvl-list .lvl .tgt-bar { height: 8px; }
.lvl-list .lvl b { text-align: right; font-variant-numeric: tabular-nums; }
.sla-list { display: grid; gap: 8px; }
.sla-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.8); cursor: pointer; }
.sla-item:hover { border-color: rgba(176, 18, 79, 0.35); }
.sla-item.overdue { border-color: rgba(176, 18, 79, 0.25); background: #fee8f0; }
.sla-item strong { font-size: 14px; }
.sla-item small { display: block; color: var(--ink-3); font-size: 12px; }

/* ---- tables: two-line cells, sticky first bits */
.t2 { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; margin-top: 1px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
td.wrap { white-space: normal; min-width: 180px; max-width: 360px; }
td.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.star-btn { border: none; background: none; padding: 4px; color: #422082; cursor: pointer; line-height: 0; border-radius: 8px; }
.star-btn.on { color: #5e4a72; }
.star-btn:hover { background: rgba(0, 0, 0, 0.05); }
.flags { display: flex; gap: 4px; flex-wrap: wrap; }
.check-col { width: 36px; }
.check-col input, .row-check { width: 16px; height: 16px; accent-color: var(--violet); margin: 0; }
.num-col { text-align: right; font-variant-numeric: tabular-nums; }
.result-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); margin: 10px 0; }
.toolbar .btn { min-height: 40px; }
.bulk-bar { position: sticky; top: 72px; z-index: 5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; margin: 10px 0; border-radius: 12px; border: 1px solid rgba(176, 18, 79, 0.25); background: var(--glass-strong); box-shadow: var(--shadow-md); }
.bulk-bar select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--field-line); background: #fff; font-size: 13px; min-height: 36px; }

/* ---- leads */
.lead-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.lead-strip .ls { flex: 1 1 110px; min-width: 110px; padding: 10px 12px; border-radius: 12px; background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-sm); cursor: pointer; display: grid; gap: 2px; text-align: left; font: inherit; }
.lead-strip .ls b { font-family: var(--font-display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.lead-strip .ls span { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.lead-strip .ls.on { border-color: rgba(176, 18, 79, 0.55); box-shadow: 0 0 0 2px rgba(176, 18, 79, 0.15); }
.lead-strip .ls:hover { border-color: rgba(176, 18, 79, 0.35); }
.sla-txt { font-size: 12px; font-weight: 600; white-space: nowrap; }
.sla-txt.overdue { color: var(--danger); }
.sla-txt.due-soon { color: var(--warn); }
.sla-txt.waiting { color: var(--ink-2); }
.sla-txt.answered { color: var(--ink-3); font-weight: 500; }

/* ---- drawer (right sheet; full screen on phones) */
.drawer-back { position: fixed; inset: 0; z-index: 250; background: rgba(31, 22, 51, 0.35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade-only 0.2s ease both; }
@keyframes fade-only { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 251; width: min(600px, 100vw); overflow-y: auto; background: var(--ground); box-shadow: -30px 0 80px -30px rgba(0, 0, 0, 0.5); animation: drawer-in 0.32s var(--ease-out) both; display: grid; grid-template-rows: auto 1fr auto; }
.drawer.wide { width: min(760px, 100vw); }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; gap: 14px; align-items: flex-start; padding: 18px 22px; background: rgba(229, 231, 235, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-family: var(--font-display); font-size: 18px; line-height: 1.25; }
.drawer-head p { margin: 3px 0 0; font-size: 13px; color: var(--ink-3); }
.drawer-head .modal-close { margin-left: auto; flex-shrink: 0; }
.drawer-body { padding: 18px 22px 24px; display: grid; gap: 16px; align-content: start; }
.drawer-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 22px; background: rgba(229, 231, 235, 0.94); border-top: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.drawer-foot:empty { display: none; }
.drawer .panel { margin-bottom: 0; padding: 16px 18px; }
.drawer .panel h3 { margin: 0 0 10px; font-family: var(--font-display); font-size: 14px; font-weight: 700; }
.kv { display: grid; grid-template-columns: minmax(110px, 150px) 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd a { color: var(--info); }
.pre { white-space: pre-wrap; font-family: inherit; font-size: 13px; line-height: 1.6; margin: 0; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.85); border: 1px solid var(--line); overflow-wrap: anywhere; }
.pre:empty::before { content: "Nothing written yet."; color: var(--ink-3); }
.facts { display: flex; gap: 6px; flex-wrap: wrap; }
.timeline { display: grid; gap: 0; }
.tl-item { position: relative; display: grid; gap: 3px; padding: 0 0 14px 22px; border-left: 2px solid rgba(176, 18, 79, 0.2); margin-left: 6px; }
.tl-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #422082; }
.tl-item strong { font-size: 13px; }
.tl-item small { font-size: 12px; color: var(--ink-3); }
.tl-item .tl-note { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.action-grid .btn { justify-content: center; }

/* ---- forms outside modals (Set up tab) */
.fg .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.fg .toggle { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.fg .toggle input { width: 18px; height: 18px; accent-color: var(--violet); }
.editor-rows { display: grid; gap: 10px; }
.ed-row { display: grid; gap: 8px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.8); }
.ed-row .ed-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.ed-row .ed-tools { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.ed-row .ed-tools .ed-idx { margin-right: auto; font-size: 12px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.ed-row input[type="text"], .ed-row input[type="number"], .ed-row select, .ed-row textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--field-line); border-radius: 8px; background: #fff; font-size: 13px; }
.ed-row textarea { min-height: 54px; resize: vertical; line-height: 1.5; }
.ed-row label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.ed-row .check-inline { font-size: 13px; }
.ed-section { display: grid; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid rgba(176, 18, 79, 0.18); background: rgba(255, 255, 255, 0.6); }
.ed-section > .ed-head { display: flex; gap: 8px; align-items: center; }
.ed-section > .ed-head input { flex: 1; font-weight: 700; }
.ed-section .ed-row { background: #fff; }
.chk-row { display: flex; gap: 10px; flex-wrap: wrap; }
.chk-row label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chk-row input { width: 15px; height: 15px; accent-color: var(--violet); margin: 0; }
.setup-grid { display: grid; gap: 20px; }
.setup-grid .panel { margin-bottom: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.panel-head .note { margin: 4px 0 0; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-top: 14px; }
.panel-actions .dirty { font-size: 13px; color: var(--warn); font-weight: 700; margin-right: auto; }
.danger-panel { border-color: rgba(176, 18, 79, 0.2); }

/* ---- agents */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.agent-card { padding: 16px 18px; border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-md); display: grid; gap: 12px; }
.agent-card.is-revoked { opacity: 0.7; background: rgba(255, 255, 255, 0.5); }
.agent-card .ag-top { display: flex; align-items: flex-start; gap: 12px; }
.agent-card .ag-avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.agent-card .ag-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.agent-card .ag-sub { font-size: 12px; color: var(--ink-3); }
.agent-card .ag-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.agent-card .ag-nums div { padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.75); border: 1px solid var(--line); }
.agent-card .ag-nums b { display: block; font-family: var(--font-display); font-size: 17px; font-variant-numeric: tabular-nums; }
.agent-card .ag-nums span { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.agent-card .ag-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- import dialog */
.import-parts { display: grid; gap: 6px; max-height: 220px; overflow-y: auto; padding: 4px 0; }
.import-part { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.85); font-size: 13px; }
.import-part input { width: 16px; height: 16px; accent-color: var(--violet); margin: 0; }
.import-part .ip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-part .ip-rows { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.detected { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.detected span { font-size: 12px; padding: 2px 8px; border-radius: 4px; background: #e5e7eb; color: var(--ink-2); }
.detected span b { color: var(--ink); }
.file-drop.is-over { border-color: var(--violet); background: var(--info-bg); }

/* ---- database */
.db-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; align-items: start; }
.db-stats .chart-card { grid-column: 1 / -1; }
@media (max-width: 760px) { .db-stats .chart-card { grid-column: span 1; } }
.link-like { background: none; border: none; padding: 0; color: var(--info); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(176, 18, 79, 0.3); text-underline-offset: 3px; }
.link-like:hover { text-decoration-color: currentColor; }

/* ---- misc */
.muted { color: var(--ink-3); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.empty-box { padding: 28px 16px; text-align: center; color: var(--ink-3); font-size: 14px; border: 1px dashed var(--line-2); border-radius: 12px; background: rgba(255, 255, 255, 0.5); }
.empty-box strong { display: block; color: var(--ink-2); margin-bottom: 4px; }
.inline-note { font-size: 13px; color: var(--ink-3); }
.modal-panel.modal-wide { max-width: 820px; }
.modal-form .fg { padding: 0; }
.menu-popover .menu-sep { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.wa-btn { background: #f1fad9; border-color: rgba(58, 79, 0, 0.25); color: var(--ok); }
.cp-sub > .panel:last-child { margin-bottom: 0; }

/* ---- phones */
@media (max-width: 860px) {
  .sidebar .nav-item .nav-sub, .sidebar .nav-item .nav-status { display: none; }
  .nav-search { display: none; }
  .content { padding: 16px 14px 70px; }
  .bulk-bar { top: 58px; }
}
@media (max-width: 760px) {
  .drawer, .drawer.wide { width: 100vw; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
  .tgt-card .tc-facts { grid-template-columns: 1fr; }
  .fg .row3 { grid-template-columns: 1fr; }
  .ov-hero { padding: 20px; }
  .cp-grid { grid-template-columns: 1fr; }
  .lead-strip .ls { flex-basis: 45%; }
  .bulk-bar { position: static; }
  .action-grid { grid-template-columns: 1fr 1fr; }
  .agent-card .ag-nums { grid-template-columns: repeat(3, 1fr); }
  .modal-panel { max-height: 100dvh; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer-back { animation: none; }
  .tgt-bar i { transition: none; }
  .cp-card { transition: none; }
}

/* dialogs open above drawers (a drawer's action opens a dialog) */
.modal-backdrop { z-index: 400; }
.fg .row2, .fg .row3, .modal-form .row2 { align-items: start; }

/* ==========================================================================
   Decision-first view: Perlu ditindak, Beranda's totals, Ringkasan
   Red only for danger. A status never rests on colour alone: the tag says it too.
   ========================================================================== */
.ov-line { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 14px; font-size: 14px; color: var(--ink-3); }
.ov-line b { color: var(--ink); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

.att { margin-bottom: 16px; padding: 16px 20px; border-radius: var(--r-lg); background: var(--surface); }
.att-h { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 16px; }
.att-n { min-width: 22px; padding: 1px 7px; border-radius: 4px; background: var(--well-hover); color: var(--ink-2); font-size: 12px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.att-list { display: grid; margin: 0; padding: 0; list-style: none; }
.att-list li + li { border-top: 1px solid var(--line); }
.att-row { display: grid; grid-template-columns: 88px 64px minmax(0, 1fr) 16px; align-items: center; gap: 4px 12px; margin: 0 -10px; padding: 10px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; }
.att-row:hover { background: var(--sunken); }
.att-tag { justify-self: start; padding: 2px 9px; border-radius: 4px; background: var(--muted-fill); color: var(--ink-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.att-count { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: 0; text-align: right; font-variant-numeric: tabular-nums; }
.att-text { display: grid; gap: 1px; min-width: 0; }
.att-label { font-size: 14px; font-weight: 500; line-height: 1.35; }
.att-camp { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-go { color: var(--ink-3); }
.att-row.is-warn .att-tag { background: var(--warn-bg); color: var(--warn); }
.att-row.is-danger .att-tag { background: var(--danger-bg); color: var(--danger); }
.att-row.is-danger .att-count { color: var(--danger); }
.att-more { margin-top: 6px; }
.att-note { margin: 6px 0 2px; font-size: 14px; color: var(--ink-2); }
.att-note.is-ok::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--ok); vertical-align: 1px; }
.att-note.is-err { color: var(--warn); }

.fr { margin-bottom: 16px; }
.fr h2 { margin: 0 0 12px; font-size: 16px; }
.fr-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: fr; }
.fr-steps li { display: flex; align-items: center; gap: 12px; counter-increment: fr; }
.fr-tick { display: grid; place-items: center; flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; background: var(--well); color: var(--ink-3); font-size: 13px; font-weight: 600; }
.fr-tick:empty::before { content: counter(fr); }
.fr-steps .is-done .fr-tick { background: var(--ok-bg); color: var(--ok); }
.fr-steps .is-next .fr-tick { background: var(--warm-tint); color: var(--warm-hover); }
.fr-body { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
.fr-body small { font-size: 13px; color: var(--ink-3); }
.fr-body .btn { min-height: 34px; padding: 6px 14px; text-decoration: none; }
.fr-link { color: var(--ink-2); font-weight: 500; }

.rk-today { margin-bottom: 16px; }
.rk-h { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 12px; }
.rk-h h2 { margin: 0; font-size: 16px; }
.rk-team { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 8px; }
.rk-stat { display: grid; align-content: start; gap: 3px; padding: 12px 14px; border-radius: var(--r-md); background: var(--well); }
.rk-stat b { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.rk-stat b small { font-size: 15px; font-weight: 500; color: var(--ink-3); }
.rk-stat span { font-size: 12px; color: var(--ink-3); }
.rk-stat .tgt-bar { margin-top: 5px; }
.rk-agents { width: 100%; border-collapse: collapse; font-size: 14px; }
.rk-agents th, .rk-agents td { padding: 9px 12px; text-align: left; vertical-align: middle; border: 0; }
.rk-agents thead th { white-space: nowrap; }
.rk-agents tbody tr + tr, .rk-agents tbody tr:first-child { border-top: 1px solid var(--line); }
.rk-agents tbody tr:hover { background: none; }
.rk-agents tbody th { background: none; color: var(--ink); font-size: 14px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.rk-agents .num-col { text-align: right; }
.rk-name { display: inline-block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.rk-dials { min-width: 150px; }
.rk-num { display: block; margin-bottom: 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.rk-dials .tgt-bar { height: 5px; }
.rk-last { white-space: nowrap; }

.rk-detail { margin-bottom: 16px; }
.rk-detail > summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; padding: 13px 20px 13px 40px; position: relative; border-radius: var(--r-lg); background: var(--surface); cursor: pointer; list-style: none; }
.rk-detail > summary::-webkit-details-marker { display: none; }
.rk-detail > summary::before { content: ""; position: absolute; left: 20px; top: 19px; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(-45deg); transition: transform var(--t-fast); }
.rk-detail[open] > summary::before { transform: rotate(45deg); }
.rk-detail > summary:hover { background: var(--sunken); }
.rk-detail > summary span { font-family: var(--font-display); font-size: 15px; font-weight: 600; }
.rk-detail > summary small { font-size: 13px; color: var(--ink-3); }
.rk-detail[open] > summary { margin-bottom: 14px; }
#rk-detail-body > * { margin-bottom: 14px; }
#rk-detail-body > *:last-child { margin-bottom: 0; }
#rk-targets:focus { outline: none !important; }

/* cards on Beranda are real links */
a.cp-card { color: var(--ink); text-decoration: none; }
.funnel.cc-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.funnel.cc-three .fn { min-width: 0; }

/* real links and buttons where rows act like links */
a.nav-item { text-decoration: none; }
.row-link { display: inline; max-width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.row-link:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.row-link .clip { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }
button.sla-item { width: 100%; font: inherit; color: inherit; text-align: left; }
button.list-row { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.th-sort { padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.th-sort:hover { color: var(--ink); }
th[aria-sort] .th-sort { color: var(--ink); }
th[aria-sort] .th-sort::after { margin-left: 4px; font-size: 9px; }
th[aria-sort="ascending"] .th-sort::after { content: "\25B2"; }
th[aria-sort="descending"] .th-sort::after { content: "\25BC"; }

/* empty states: what to do next, with one button */
.empty-act { margin-top: 12px; }
.empty-act .btn { text-decoration: none; }
td > .empty-box { margin: 6px 0; white-space: normal; }

.ct-result { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
#ct-chips { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
#ct-chips:empty { display: none; }
.filter-chip { padding: 2px 10px; border-radius: 4px; background: var(--warm-tint); color: var(--warm-hover); font-size: 12px; font-weight: 600; }

/* the List's toolbar: search gets the room, filters stay on one line */
#sub-contacts .toolbar input[type="search"] { flex: 1 1 200px; min-width: 170px; }
#sub-contacts .toolbar select { flex: 0 1 158px; min-width: 120px; }
#sub-contacts .toolbar-spacer { flex: 0 0 0; }
.ct-outcome { display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.due-tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--warn-bg); color: var(--warn); font-size: 12px; font-weight: 600; }
.due-tag.is-late { background: var(--danger-bg); color: var(--danger); }

.tool-select { max-width: 100%; min-width: 0; box-sizing: border-box; }
.tool-select select { min-width: 0; max-width: 100%; }

/* destructive actions sit apart from the rest */
.act-danger { margin-right: auto; }
.ag-gap { flex: 1 1 8px; }
.agent-card .ag-actions { align-items: center; }

@media (max-width: 860px) {
  .topbar { position: static; } /* a sticky title would take a quarter of a phone */
  .rk-team { grid-template-columns: 1fr 1fr; }
  .rk-team .rk-stat:first-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .cp-head { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; } /* the decision comes first, the chips scroll */
  .cp-head .chip { flex: 0 0 auto; white-space: nowrap; }
  .att { padding: 14px 16px; }
  .att-row { grid-template-columns: 52px minmax(0, 1fr) 16px; grid-template-areas: "count tag go" "count text go"; }
  .att-tag { grid-area: tag; } .att-count { grid-area: count; font-size: 24px; text-align: left; } .att-text { grid-area: text; } .att-go { grid-area: go; }
  .rk-agents, .rk-agents tbody, .rk-agents tr, .rk-agents th, .rk-agents td { display: block; }
  .rk-agents thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .rk-agents tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 0; }
  .rk-agents tbody th { grid-column: 1 / -1; padding: 0; }
  .rk-agents th, .rk-agents td { padding: 0; }
  .rk-agents .rk-dials { grid-column: 1 / -1; }
  .rk-agents .num-col { text-align: left; }
  .rk-agents td[data-l] { font-weight: 500; }
  .rk-agents td[data-l]::before { content: attr(data-l); display: block; font-size: 12px; font-weight: 400; color: var(--ink-3); }
  .rk-last { white-space: normal; }
  .rk-name { max-width: 180px; }
  .act-danger { margin-right: 0; }
}
