:root {
  --ink: #111827; --muted: #6b7280; --line: #e5e7eb; --soft: #f9fafb; --bg: #f0f2f5;
  --side: #0f1923; --amber: #f59e0b; --amber-dk: #d97706; --red: #dc2626; --green: #16a34a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg);
       color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: #b45309; text-decoration: none; }
a:hover { text-decoration: underline; }
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; min-width: 220px; background: var(--side); display: flex; flex-direction: column;
           position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { padding: 18px 16px 10px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; gap: 8px; align-items: center; }
.logo-icon { width: 28px; height: 28px; background: var(--amber); border-radius: 6px; display: flex; align-items: center;
             justify-content: center; font-weight: 700; color: var(--side); font-size: 13px; }
.logo-text { color: #fff; font-weight: 600; font-size: 15px; }
.logo-sub { color: rgba(255,255,255,.35); font-size: 9px; letter-spacing: 1.5px; }
.inbox-shortcut { display: inline-flex; align-items: center; gap: 10px; background: var(--amber); color: var(--side); border: 1px solid #fbbf24; border-radius: 10px; font-weight: 700; text-decoration: none; flex-shrink: 0; }
.inbox-shortcut:hover { background: #fbbf24; color: var(--side); text-decoration: none; }
.inbox-shortcut:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
.inbox-shortcut-icon { width: 22px; height: 22px; flex-shrink: 0; }
.inbox-shortcut-sidebar { margin: 16px 12px 4px; padding: 14px 12px; min-height: 68px; box-shadow: 0 4px 14px rgba(245,158,11,.18); }
.inbox-shortcut-sidebar strong { display: block; font-size: 16px; line-height: 1.25; }
.inbox-shortcut-sidebar small { display: block; font-size: 11px; font-weight: 500; margin-top: 3px; }
.inbox-shortcut-sidebar.active { box-shadow: inset 0 0 0 2px var(--side), 0 0 0 2px var(--amber); }
.inbox-shortcut-header { min-height: 40px; padding: 8px 12px; font-size: 13px; white-space: nowrap; }
.inbox-shortcut-header[aria-current="page"] { box-shadow: inset 0 0 0 2px var(--side); }
@media (max-width: 860px) {
  .topbar .inbox-shortcut-header { order: 0; min-height: 44px; }
  .topbar > .btn-row { flex-basis: 100%; }
  .topbar > .btn-row:empty { display: none; }
  .topbar > .topsearch { order: 1; }
}
.nav-label { font-size: 9px; letter-spacing: 1.2px; color: rgba(255,255,255,.3); padding: 14px 18px 4px; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin: 1px 8px; border-radius: 6px;
         color: rgba(255,255,255,.55); font-size: 13px; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.9); }
.nav a.active { background: rgba(245,158,11,.15); color: var(--amber); }
.nav .count { margin-left: auto; background: var(--amber); color: var(--side); font-size: 10px; font-weight: 700;
              padding: 1px 6px; border-radius: 10px; }
.side-bottom { margin-top: auto; padding: 10px 8px; border-top: 1px solid rgba(255,255,255,.08); }
.side-bottom .who { color: rgba(255,255,255,.8); font-size: 12px; padding: 4px 10px; }
.side-bottom .who small { display: block; color: rgba(255,255,255,.35); font-size: 10px; }
.side-bottom form { margin: 0; }
.side-link { display: block; color: rgba(255,255,255,.55); font-size: 13px; padding: 7px 10px; border-radius: 6px; }
.side-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.side-bottom button { background: none; border: 0; color: rgba(255,255,255,.55); font: inherit; font-size: 13px; padding: 7px 10px;
                      cursor: pointer; width: 100%; text-align: left; border-radius: 6px; }
.side-bottom button:hover { background: rgba(255,255,255,.06); color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 0 24px; min-height: 54px; display: flex;
          align-items: center; gap: 12px; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 20px 24px 60px; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; font-size: 16px; cursor: pointer; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 6px; font: inherit; font-size: 13px;
       cursor: pointer; border: 1px solid #d1d5db; background: #fff; color: #374151; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--side); font-weight: 600; }
.btn.primary:hover { background: var(--amber-dk); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.halves { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.card > h2, .card-head { font-size: 13px; font-weight: 600; margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line);
                         display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-body { padding: 12px 16px; }
.card-body.flush { padding: 0; }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 11px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 650; margin-top: 4px; }
.kpi .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi.alert .value { color: var(--red); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #f1f2f4; vertical-align: top; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; background: var(--soft); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; background: var(--soft); }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); padding: 18px 16px; text-align: center; }
.pre { white-space: pre-wrap; }

.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.badge-grey { background: #f3f4f6; color: #4b5563; } .badge-blue { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; } .badge-amber { background: #fef3c7; color: #92400e; }
.badge-green { background: #dcfce7; color: #166534; } .badge-red { background: #fee2e2; color: #991b1b; }
.badge-teal { background: #ccfbf1; color: #115e59; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.tabs { display: flex; gap: 2px; background: #e5e7eb; padding: 3px; border-radius: 8px; }
.tabs a { padding: 4px 12px; border-radius: 6px; color: #374151; font-size: 12px; text-decoration: none; }
.tabs a.on { background: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.input, input[type=text], input[type=search], input[type=number], input[type=email], input[type=password], select, textarea {
  font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; width: 100%; color: var(--ink); }
input[type=search] { width: 240px; }
select[multiple] { min-height: 90px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: #374151; }
.field .help { font-size: 11px; color: var(--muted); margin-top: 3px; }
.field .err { font-size: 12px; color: var(--red); margin-top: 3px; }
.field.wide { grid-column: 1 / -1; }
.field.check label { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.field.check input { width: auto; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .input, .inline-form select, .inline-form input { width: auto; }
.inline-form .grow { flex: 1; min-width: 180px; }

.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li { padding: 9px 14px; border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.messages .success { background: #dcfce7; color: #14532d; } .messages .error { background: #fee2e2; color: #7f1d1d; }
.messages .info, .messages .warning { background: #fef3c7; color: #78350f; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #e9ebef; border-radius: 10px; padding: 10px; min-height: 160px; }
.col h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #4b5563; margin: 0 0 8px; display: flex; justify-content: space-between; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 7px; font-size: 12px; }
.tile .t { font-weight: 600; font-size: 13px; color: var(--ink); }
.tile select { margin-top: 6px; font-size: 12px; padding: 3px 6px; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 11px; color: var(--muted); }
.bar span { width: 100%; background: var(--amber); border-radius: 4px 4px 0 0; min-height: 2px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 16px; border-bottom: 1px solid #f3f4f6; font-size: 12px; }
.feed li:last-child { border-bottom: 0; }
.secret { font-family: ui-monospace, Menlo, monospace; background: #fff7ed; border: 1px dashed #fdba74; padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; }
.status-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.status-buttons .btn.on { background: var(--side); color: #fff; border-color: var(--side); }
.option-tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.option-tabs .btn.on { border-color: var(--amber); background: #fffbeb; font-weight: 600; }
.totals { margin-left: auto; width: 280px; max-width: 100%; }
.totals td { padding: 4px 12px; }
.pager { display: flex; gap: 8px; align-items: center; padding: 10px 16px; font-size: 12px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--side); padding: 16px; }
.login .box { background: #fff; border-radius: 12px; padding: 28px; width: 360px; max-width: 100%; }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.login .field { margin-bottom: 12px; }
.login .btn { width: 100%; justify-content: center; padding: 9px; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -240px; z-index: 20; transition: left .2s; }
  body.nav-open .sidebar { left: 0; }
  .menu-btn { display: inline-block; }
  .two { grid-template-columns: 1fr; }
  .content { padding: 14px 12px 60px; }
  .topbar { padding: 8px 12px; }
  input[type=search] { width: 100%; }
  .hide-sm { display: none; }
}

.topsearch { margin: 0 8px 0 0; }
.topsearch input[type=search] { width: 220px; }
.staging-banner { background: #fef3c7; color: #92400e; border-bottom: 1px solid #fcd34d; padding: 6px 24px; font-size: 13px; font-weight: 600; }
@media (max-width: 760px) { .topsearch { display: none; } }
