/* HOIV contact dashboard — dark, amber-accented, no framework. */
:root {
  --bg: #0f1115; --panel: #161a21; --panel2: #1d222c; --border: #262b36;
  --text: #e6e9ef; --muted: #8b93a7; --accent: #f59e0b; --accent-dim: #b45309;
  --green: #2ecc71; --red: #e74c3c; --blue: #3b82f6; --grey: #95a5a6;
  --radius: 10px; --font: -apple-system, 'Segoe UI', Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ── login ── */
.login-wrap { display: grid; place-items: center; height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 40px 48px; text-align: center; max-width: 420px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; }
.btn-discord { display: inline-block; background: #5865f2; color: #fff; padding: 10px 22px; border-radius: 8px; font-weight: 600; }
.btn-discord:hover { filter: brightness(1.1); }

/* ── shell ── */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 14px; letter-spacing: .2px; }
.brand .amber { color: var(--accent); }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; color: var(--text); cursor: pointer; }
.nav-item:hover { background: var(--panel2); }
.nav-item.active { background: var(--panel2); color: var(--accent); font-weight: 600; }
.nav-item .badge { margin-left: auto; background: var(--accent); color: #000; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; }
.side .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-top: 1px solid var(--border); }
.userchip img { width: 28px; height: 28px; border-radius: 50%; }
.userchip .who { line-height: 1.2; }
.userchip .who .name { font-weight: 600; font-size: 13px; }
.userchip .who .role { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.main { padding: 22px 28px; max-width: 1200px; width: 100%; }

.banner { border-radius: var(--radius); padding: 8px 14px; margin-bottom: 16px; font-size: 13px; border: 1px solid; }
.banner.test { background: #2a2410; border-color: #6b5310; color: #fbbf24; }
.banner.dry { background: #10222a; border-color: #155e75; color: #67e8f9; }

h2.page { margin: 4px 0 18px; font-size: 19px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ── controls ── */
button, .btn { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 13px; cursor: pointer; font: inherit; }
button:hover { border-color: var(--accent-dim); }
button.primary { background: var(--accent); border-color: var(--accent); color: #14100a; font-weight: 700; }
button.danger { border-color: #7f1d1d; color: #fca5a5; }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-dim); }
textarea { width: 100%; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
label.field { display: block; margin-bottom: 10px; }
label.field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }

/* ── chips & tables ── */
.chip { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--border); color: var(--muted); }
.chip.triage { color: var(--accent); border-color: var(--accent-dim); }
.chip.awaiting_review { color: #7fb2ff; border-color: #1d4ed8; }
.chip.replied { color: #6ee7a0; border-color: #14532d; }
.chip.spam { color: #fca5a5; border-color: #7f1d1d; }
.chip.manual, .chip.closed { color: var(--grey); }
.chip.cat { color: var(--text); background: var(--panel2); }
.chip.shared { color: #c4b5fd; border-color: #4c1d95; }
table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.list th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--panel2); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs .tab { padding: 6px 13px; border-radius: 99px; border: 1px solid var(--border); cursor: pointer; color: var(--muted); font-size: 13px; }
.tabs .tab.active { color: var(--accent); border-color: var(--accent-dim); background: var(--panel); }
.tabs .tab .n { opacity: .7; margin-left: 4px; }

/* ── panels ── */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13.5px; }
.kv .k { color: var(--muted); }

/* ── thread timeline ── */
.msg { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; background: var(--bg); }
.msg .head { display: flex; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.msg pre { margin: 0; white-space: pre-wrap; font-family: var(--font); font-size: 13.5px; }
.msg.inbound { border-left: 3px solid var(--blue); }
.msg.outbound_human { border-left: 3px solid var(--green); }
.msg.outbound_bot_ack, .msg.outbound_bot_reply { border-left: 3px solid var(--accent); }

/* ── kb editor / detail review ── */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 950px) { .split { grid-template-columns: 1fr; } }
/* Review layout: contact-form messages are short — the draft is the
   workhorse, so 1/3 message vs 2/3 editor, stacking early. */
.detail-split { grid-template-columns: minmax(280px, 1fr) 2fr; }
@media (max-width: 1100px) { .detail-split { grid-template-columns: 1fr; } }
.origbox { background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--blue); border-radius: var(--radius); padding: 12px 15px; max-height: 460px; overflow: auto; }
.msgpre { margin: 0; white-space: pre-wrap; font-family: var(--font); font-size: 13.5px; line-height: 1.55; }
.preview { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; overflow: auto; max-height: 70vh; }
.preview h1, .preview h2, .preview h3 { color: var(--accent); }
.preview blockquote { border-left: 3px solid var(--accent-dim); margin-left: 0; padding-left: 12px; color: var(--muted); }
.preview code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.preview table { border-collapse: collapse; }
.preview td, .preview th { border: 1px solid var(--border); padding: 4px 9px; }
.preview iframe { width: 100%; height: 320px; border: 0; background: #fff; border-radius: 6px; }

/* ── stats ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .v { font-size: 24px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 12px; }
.heat { display: grid; grid-template-columns: 42px repeat(24, 1fr); gap: 2px; font-size: 10.5px; }
.heat .lab { color: var(--muted); align-self: center; }
.heat .cell { aspect-ratio: 1; border-radius: 3px; background: var(--panel2); position: relative; }
.heat .cell[title] { cursor: help; }

.hint { color: var(--muted); font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }

/* ── toasts ── */
#toasts { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
.toast { background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 16px; max-width: 380px; box-shadow: 0 6px 24px rgba(0,0,0,.45); animation: slidein .18s ease-out; }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

.draft-box { border: 1px solid var(--accent-dim); border-radius: var(--radius); background: #191408; padding: 14px 16px; }
.approval-banner { border: 1px solid #4c1d95; background: #17102a; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.playcheck { font-size: 12.5px; margin-top: 8px; }
.playcheck.ok { color: #6ee7a0; }
.playcheck.warn { color: #fbbf24; }
