/* ============================================================
   Techtonic Admin — light minimalist design system
   Palette: light surface + slate text + electric-cyan accent
   (cyan #00E5FF is decorative only; interactive = teal-600 for
    WCAG 4.5:1 contrast on white)
   ============================================================ */
:root {
  --bg: #F7F9FC;
  --surface: #FFFFFF;
  --border: #E6EAF2;
  --border-strong: #D2D9E7;
  --text: #0F172A;
  --text-2: #55617A;
  --text-3: #8A94AB;
  --accent: #00E5FF;          /* brand glow — decorative */
  --accent-ink: #0E7490;      /* interactive cyan — accessible */
  --accent-soft: #E6FBFF;
  --navy: #0A0E27;
  --green: #16A34A;  --green-soft: #EAF8EF;
  --red: #DC2626;    --red-soft: #FDECEC;
  --amber: #B45309;  --amber-soft: #FEF4E2;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .07);
  --font: 'Heebo', 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font); line-height: 1.55;
  min-height: 100dvh;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }
.sidebar {
  background: var(--surface); border-inline-end: 1px solid var(--border);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--navy);
  display: grid; place-items: center; color: var(--accent);
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.brand-name .t { color: var(--accent-ink); }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px; color: var(--text-2);
  font-weight: 500; font-size: 14.5px; min-height: 44px;
  transition: background .18s ease, color .18s ease;
}
.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-badge {
  margin-inline-start: auto; background: var(--accent-ink); color: #fff;
  font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 1px 8px;
}
.sidebar-footer { margin-top: auto; padding: 12px; }
.mode-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 5px 12px;
}
.mode-pill.dry { background: var(--amber-soft); color: var(--amber); }
.mode-pill.live { background: var(--green-soft); color: var(--green); }
.mode-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- main ---------- */
.main { padding: 32px 44px 64px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.page-sub { color: var(--text-2); font-size: 14px; margin-top: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px; font-weight: 600; font-size: 14px;
  padding: 11px 20px; min-height: 44px; border: 1px solid transparent;
  transition: filter .18s ease, background .18s ease, transform .12s ease;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { filter: brightness(1.25); }
.btn-accent { background: var(--accent-ink); color: #fff; }
.btn-accent:hover { filter: brightness(1.12); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(1.08); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn-outline:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.btn-danger-outline { background: var(--surface); border-color: #F3C4C4; color: var(--red); }
.btn-danger-outline:hover { background: var(--red-soft); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- cards / KPI ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi { padding: 20px 22px; position: relative; overflow: hidden; }
.kpi::after {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; inset-inline-end: auto; width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-ink));
  opacity: 0; transition: opacity .2s ease;
}
.kpi:hover::after { opacity: 1; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .8px; }
.kpi-value { font-family: var(--font-display); font-size: 32px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

/* ---------- approval / post preview ---------- */
.draft-grid { display: grid; gap: 20px; }
.draft-card { display: grid; grid-template-columns: 340px 1fr; }
.draft-card .visual { padding: 20px; border-inline-end: 1px solid var(--border); }
.draft-card .visual img { width: 100%; border-radius: 10px; border: 1px solid var(--border); display: block; }
.draft-card .body { padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.draft-meta { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.score-chip { background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 2px 10px; font-weight: 700; }
.field-label { font-size: 11.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); }
textarea.post-text {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--bg); color: var(--text); padding: 12px 14px;
  font-size: 14px; font-family: inherit; line-height: 1.6;
  min-height: 130px; resize: vertical; transition: border-color .18s ease;
}
textarea.post-text:focus { border-color: var(--accent-ink); outline: none; background: var(--surface); }
textarea.post-text[dir="rtl"] { text-align: right; }
.draft-actions { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; }

/* ---------- approval block + facebook preview ---------- */
.approval-block { overflow: hidden; }
.approval-head { padding: 16px 24px; border-bottom: 1px solid var(--border); }
.score-reason { font-size: 12.5px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }
.approval-body { display: grid; grid-template-columns: 1fr 420px; }
.edit-col { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.preview-col { padding: 20px 24px; background: #EDF0F5; border-inline-start: 1px solid var(--border); }
.preview-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.ptab {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 7px 16px; font-size: 12.5px; font-weight: 600;
  transition: all .15s ease;
}
.ptab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.hidden { display: none; }
.device-toggle {
  margin-inline-start: auto; display: flex; gap: 2px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 3px;
}
.dtab {
  background: none; border: none; border-radius: 999px; padding: 5px 11px;
  color: var(--text-3); display: grid; place-items: center; transition: all .15s ease;
}
.dtab svg { width: 15px; height: 15px; }
.dtab.active { background: var(--accent-ink); color: #fff; }

/* authentic-ish Facebook post mock */
.fb-post {
  background: #fff; border-radius: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.15);
  font-family: 'Heebo', 'Segoe UI', Helvetica, Arial, sans-serif;
  max-width: 400px; margin: 0 auto;
  transition: max-width .25s ease;
}
/* desktop feed view — FB desktop post column is ~590px */
.preview-col.desktop .fb-post { max-width: 590px; }
.preview-col.desktop .fb-text { font-size: 15px; }
.fb-head { display: flex; align-items: center; gap: 9px; padding: 12px 14px 6px; }
.fb-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--navy);
  color: var(--accent); display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 19px; flex: none;
}
.fb-name { font-weight: 700; font-size: 14.5px; color: #050505; }
.fb-sub { font-size: 12.5px; color: #65676B; display: flex; align-items: center; gap: 4px; }
.fb-dots { margin-inline-start: auto; color: #65676B; font-weight: 700; letter-spacing: 1px; }
.fb-text {
  padding: 6px 14px 10px; font-size: 14.5px; line-height: 1.45; color: #050505;
  white-space: pre-wrap; word-wrap: break-word;
}
.fb-hashtag { color: #1877F2; }
.fb-img { width: 100%; display: block; }
.fb-stats {
  display: flex; justify-content: space-between; padding: 9px 14px;
  font-size: 13px; color: #65676B; border-bottom: 1px solid #E4E6EB;
}
.fb-actions { display: flex; padding: 3px 8px; }
.fb-actions span {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 0; font-size: 13.5px; font-weight: 600; color: #65676B;
  border-radius: 6px; cursor: default;
}
.fb-actions span:hover { background: #F2F2F2; }
.fb-actions svg { width: 17px; height: 17px; }

@media (max-width: 1100px) {
  .approval-body { grid-template-columns: 1fr; }
  .preview-col { border-inline-start: none; border-top: 1px solid var(--border); }
}

/* ---------- sources page ---------- */
.source-row { overflow: hidden; }
.source-off { opacity: .55; }
.source-main {
  display: grid; grid-template-columns: 1fr auto auto; gap: 20px;
  align-items: center; padding: 16px 20px;
}
.source-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.src-kind-badge {
  flex: none; font-size: 11px; font-weight: 700; border-radius: 7px; padding: 5px 9px;
}
.src-kind-badge.rss { background: var(--accent-soft); color: var(--accent-ink); }
.src-kind-badge.tg { background: #E7F1FD; color: #1D6FC2; }
.source-name { font-weight: 700; font-size: 14.5px; }
.source-url { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-stats { display: flex; gap: 20px; }
.sstat { text-align: center; min-width: 44px; }
.sstat-v { font-family: var(--font-display); font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.sstat-l { font-size: 11px; color: var(--text-3); }
.source-controls { display: flex; align-items: center; gap: 10px; }
.rating { display: flex; gap: 1px; }
.star {
  background: none; border: none; font-size: 21px; line-height: 1;
  color: var(--border-strong); padding: 2px; transition: color .12s ease, transform .12s ease;
}
.star.on { color: #F5A623; }
.star:hover { transform: scale(1.15); color: #F5A623; }
.btn-sm { padding: 7px 13px; min-height: 36px; font-size: 12.5px; }
.source-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 20px; border-top: 1px solid var(--border); background: var(--bg);
  font-size: 12.5px; color: var(--text-3);
}
.scan-status.err { color: var(--red); font-weight: 600; }
.link-btn {
  background: none; border: none; color: var(--accent-ink); font-weight: 600;
  font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px;
}
.link-btn svg { width: 14px; height: 14px; }
.source-log { border-top: 1px solid var(--border); max-height: 340px; overflow-y: auto; }
.log-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 20px;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.log-item:last-child { border-bottom: none; }
.log-title { color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-time { color: var(--text-3); font-size: 12px; flex: none; }
@media (max-width: 1000px) {
  .source-main { grid-template-columns: 1fr; gap: 12px; }
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: start; padding: 12px 16px; color: var(--text-3);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px;
  border-bottom: 1px solid var(--border);
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--bg); }
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 11px;
}
.status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.published, .status.approved { background: var(--green-soft); color: var(--green); }
.status.pending { background: var(--amber-soft); color: var(--amber); }
.status.rejected, .status.failed { background: var(--red-soft); color: var(--red); }
.status.dry { background: #EDF0F7; color: var(--text-2); }

/* ---------- forms / settings ---------- */
.form-grid { display: grid; gap: 20px; }
.form-row label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.form-row .help { font-size: 12.5px; color: var(--text-3); margin-top: 5px; }
input.field, select.field {
  width: 100%; min-height: 46px; border: 1px solid var(--border-strong);
  border-radius: 10px; background: var(--surface); color: var(--text);
  padding: 10px 14px; font-size: 14.5px; font-family: inherit;
  transition: border-color .18s ease;
}
input.field:focus, select.field:focus { border-color: var(--accent-ink); outline: none; }
.section-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 36px 0 14px; }
.card-pad { padding: 24px; }

/* ---------- flash / empty ---------- */
.flash { border-radius: 12px; padding: 14px 18px; font-size: 14px; font-weight: 500; margin-bottom: 20px; display: flex; gap: 10px; align-items: center; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.err { background: var(--red-soft); color: var(--red); }
.empty {
  text-align: center; padding: 56px 24px; color: var(--text-3);
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
}
.empty svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .5; }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(600px 400px at 85% 10%, rgba(0,229,255,.10), transparent 60%),
    radial-gradient(500px 350px at 10% 90%, rgba(14,116,144,.08), transparent 60%),
    var(--bg);
}
.login-card { width: 100%; max-width: 400px; padding: 44px 40px; text-align: center; box-shadow: var(--shadow-md); }
.login-card .brand-mark { width: 52px; height: 52px; font-size: 25px; border-radius: 14px; margin: 0 auto 14px; }
.login-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.login-sub { color: var(--text-2); font-size: 13.5px; margin: 4px 0 26px; }
.login-card form { display: grid; gap: 14px; text-align: start; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px 16px; }
  .brand { padding: 0 12px 0 0; }
  .sidebar-footer { margin: 0; margin-inline-start: auto; padding: 0; }
  .main { padding: 20px 16px 48px; }
  .draft-card { grid-template-columns: 1fr; }
  .draft-card .visual { border-inline-end: none; border-bottom: 1px solid var(--border); }
}
