/* TAMNA admin. Light working surface, the site's black + gold brand on the chrome. */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --border: #e4e1d9;
  --text: #17160f;
  --text-2: #55534c;
  --text-3: #858277;
  --gold: #c89d54;
  --gold-ink: #8a6524;
  --chart: #a07a33;
  --chart-hover: #7d5c22;
  --sidebar: #0d0d0d;
  --sidebar-text: #e9e6dd;
  --good: #1d7a46;
  --warn: #9a6400;
  --bad: #b3261e;
  --radius: 10px;
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  --display: 'Cinzel', Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
a { color: var(--gold-ink); }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- buttons & inputs ---------- */
.btn { font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 9px 16px; cursor: pointer; }
.btn:hover { border-color: var(--text-3); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--sidebar); border-color: var(--sidebar); color: #fff; }
.btn-primary:hover { background: #2a2925; border-color: #2a2925; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.btn-ghost:hover { border-color: currentColor; }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { resize: vertical; min-height: 64px; }
label { display: block; font-weight: 600; font-size: 12px; color: var(--text-2); }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); }
.check input { width: auto; margin: 0; }
.form-error { color: var(--bad); min-height: 1.2em; margin: 4px 0 12px; font-size: 13px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--sidebar); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: 14px; padding: 32px 28px; display: grid; gap: 14px; }
.login-card .brand { color: var(--text); margin-bottom: 8px; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-mark { font-family: var(--display); font-size: 24px; letter-spacing: .12em; color: var(--gold); }
.brand-sub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 0 8px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { color: var(--sidebar-text); text-decoration: none; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
#nav a:hover { background: #1d1c19; }
#nav a.active { background: #26241f; color: var(--gold); }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 8px; font-size: 13px; }
.muted-link { color: var(--sidebar-text); }
.whoami { color: #9a978d; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .btn { justify-self: start; padding-left: 0; }
.main { padding: 28px 32px 64px; min-width: 0; outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
.fields .wide { grid-column: 1 / -1; }
.empty { color: var(--text-3); padding: 24px 0; text-align: center; }
.loading { color: var(--text-3); padding: 40px 0; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button { font: inherit; font-size: 13px; font-weight: 600; border: 0; background: transparent; padding: 7px 12px; cursor: pointer; color: var(--text-2); }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--sidebar); color: #fff; }
.filters input[type="date"], .filters select { width: auto; padding: 6px 8px; font-size: 13px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-3); }

/* ---------- chart ---------- */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head h2 { margin: 0; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart .grid line { stroke: var(--border); }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--chart); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { fill: var(--chart-hover); }
.tooltip { position: absolute; pointer-events: none; background: var(--sidebar); color: #fff; border-radius: 6px; padding: 6px 9px; font-size: 12px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); }
.tooltip strong { display: block; font-size: 14px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.selected td { background: #f5eddc; }
.barcell { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.barcell .track { flex: 1; height: 8px; border-radius: 4px; background: #efece5; overflow: hidden; }
.barcell .fill { display: block; height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; }
.barcell .num { min-width: 42px; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 13px; }
.rank .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .track { display: block; grid-column: 1 / -1; height: 6px; border-radius: 3px; background: #efece5; overflow: hidden; }
.rank .fill { display: block; height: 100%; background: var(--chart); }

/* ---------- editors ---------- */
.item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.item-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; }
.pill-open { color: var(--good); }
.pill-soon { color: var(--warn); }
.savebar { position: sticky; bottom: 0; margin-top: 20px; padding: 12px 16px; background: var(--sidebar); color: #fff; border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.savebar .btn-primary { background: var(--gold); border-color: var(--gold); color: #111; }
.row-list { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 80px 1fr auto; gap: 8px; align-items: center; }

/* ---------- media ---------- */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--text-2); background: var(--surface); }
.dropzone.over { border-color: var(--gold); background: #fbf6ec; }
.uploads { display: grid; gap: 6px; margin-top: 10px; }
.upload-row { display: grid; grid-template-columns: 1fr 160px; gap: 10px; align-items: center; font-size: 13px; }
progress { width: 100%; accent-color: var(--chart); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.media { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.media-thumb { aspect-ratio: 4 / 3; background: #eeeae2; display: grid; place-items: center; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-body { padding: 10px 12px; display: grid; gap: 6px; font-size: 12px; }
.media-name { font-weight: 600; word-break: break-all; }
.media-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ---------- leads ---------- */
.status { width: auto; padding: 4px 6px; font-size: 13px; }
.lead-msg { max-width: 320px; white-space: pre-wrap; color: var(--text-2); font-size: 13px; }
.lead-notes { min-width: 180px; min-height: 38px; font-size: 13px; }

/* ---------- toast ---------- */
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--sidebar); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; max-width: calc(100vw - 40px); z-index: 10; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--bad); }

/* ---------- responsive ---------- */
.geo { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1280px) { .geo { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { min-width: 0; }
  .sidebar { position: static; height: auto; padding: 14px 16px; gap: 12px; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav a { white-space: nowrap; }
  .sidebar-foot { flex-direction: row; display: flex; align-items: center; justify-content: space-between; }
  .whoami { display: none; }
  .main { padding: 20px 16px 48px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
