/* Defterdar v2 — shared stylesheet
   Palette: deep teal/ink primary on a warm paper neutral.
   Mobile-first, dark mode via prefers-color-scheme, WCAG AA contrast. */

:root {
  /* Brand */
  --ink: #142a2b;            /* deep teal-ink, primary text/brand */
  --teal: #0f5e5a;           /* primary action */
  --teal-strong: #0b4744;    /* hover */
  --teal-soft: #e3efed;      /* tinted surfaces */
  --amber: #a85c17;          /* warm accent for highlights */
  --amber-soft: #f6ecdf;

  /* Neutrals (warm paper) */
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #fbfaf6;
  --border: #e3ddd1;
  --border-strong: #d2cab9;

  /* Text */
  --text: #1d2b2a;
  --text-muted: #5c6967;
  --text-faint: #7d8a87;

  /* Status */
  --ok: #1f7a4d;
  --ok-bg: #e4f2e8;
  --warn: #9a6400;
  --warn-bg: #f8eed4;
  --danger: #a4302a;
  --danger-bg: #f7e2e0;
  --info: #1f5f86;
  --info-bg: #e2eef5;

  /* Shape */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 42, 43, 0.06), 0 1px 3px rgba(20, 42, 43, 0.05);
  --shadow: 0 2px 6px rgba(20, 42, 43, 0.07), 0 8px 24px rgba(20, 42, 43, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --font-num: "SF Mono", "Segoe UI Mono", "Roboto Mono", ui-monospace, monospace;

  --maxw: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7efed;
    --teal: #4fb3a9;
    --teal-strong: #6fc5bc;
    --teal-soft: #15302e;
    --amber: #d79a52;
    --amber-soft: #2c2318;

    --bg: #0f1716;
    --surface: #16201f;
    --surface-2: #121b1a;
    --border: #26322f;
    --border-strong: #35433f;

    --text: #e7efed;
    --text-muted: #a3b1ad;
    --text-faint: #7f8f8b;

    --ok: #58c285;        --ok-bg: #122a1e;
    --warn: #e0b256;      --warn-bg: #2b2411;
    --danger: #e98a82;    --danger-bg: #2d1917;
    --info: #78b4dc;      --info-bg: #13242e;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 28px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --ink: #e7efed;
  --teal: #4fb3a9;
  --teal-strong: #6fc5bc;
  --teal-soft: #15302e;
  --amber: #d79a52;
  --amber-soft: #2c2318;
  --bg: #0f1716;
  --surface: #16201f;
  --surface-2: #121b1a;
  --border: #26322f;
  --border-strong: #35433f;
  --text: #e7efed;
  --text-muted: #a3b1ad;
  --text-faint: #7f8f8b;
  --ok: #58c285; --ok-bg: #122a1e;
  --warn: #e0b256; --warn-bg: #2b2411;
  --danger: #e98a82; --danger-bg: #2d1917;
  --info: #78b4dc; --info-bg: #13242e;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { line-height: 1.2; color: var(--ink); margin: 0 0 0.4em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 11px 20px; border-radius: var(--radius-sm);
  border: 1px solid transparent; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-strong); text-decoration: none; }
:root[data-theme="dark"] .btn-primary,
.btn-primary { color: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { color: #06201e; }
}
:root[data-theme="dark"] .btn-primary { color: #06201e; }
.btn-ghost { background: transparent; color: var(--teal); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--teal-soft); text-decoration: none; }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; font-weight: 650; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: 999px; text-transform: uppercase;
}
.badge-dev { background: var(--amber-soft); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-info { background: var(--info-bg); color: var(--info); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }

/* ---------- Top brand bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); font-size: 1.12rem; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(145deg, var(--teal), var(--teal-strong));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 0.95rem;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-mark { color: #06201e; } }
:root[data-theme="dark"] .logo-mark { color: #06201e; }

/* visually-hidden for a11y */
.vh { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; font-family: var(--font-num); }

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }

/* =========================================================
   LANDING
   ========================================================= */
.hero { padding: 56px 0 40px; }
.hero-grid { display: grid; gap: 32px; }
.eyebrow { font-size: 0.8rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--teal); margin-bottom: 14px; }
.hero h1 { font-size: 2.1rem; max-width: 16ch; }
.hero-lead { font-size: 1.12rem; color: var(--text-muted); max-width: 46ch; margin-bottom: 24px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-note { margin-top: 16px; font-size: 0.85rem; color: var(--text-faint); }

.hero-visual {
  background: linear-gradient(160deg, var(--teal-soft), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}
.mini-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; }
.mini-row:last-child { margin-bottom: 0; }
.mini-ico { width: 38px; height: 38px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); }
.mini-row b { display: block; font-size: 0.92rem; color: var(--ink); }
.mini-row span { font-size: 0.8rem; color: var(--text-muted); }

.section { padding: 40px 0; }
.section-head { margin-bottom: 24px; }
.section-head h2 { margin-bottom: 6px; }

.value-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.value-card { padding: 22px; }
.value-ico { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); margin-bottom: 14px; }
.value-card h3 { margin-bottom: 6px; }
.value-card p { margin: 0; color: var(--text-muted); font-size: 0.94rem; }

.footer { border-top: 1px solid var(--border); margin-top: 24px; padding: 28px 0; color: var(--text-faint); font-size: 0.86rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: space-between; align-items: center; }

/* =========================================================
   APP SHELL (dashboard / mukellef)
   ========================================================= */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink); color: #cfe0dd;
  padding: 18px 14px; display: none;
}
.sidebar .brand { color: #fff; margin-bottom: 24px; }
.sidebar .logo-mark { background: rgba(255,255,255,.14); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #b9cdc9; font-weight: 550; font-size: 0.94rem;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav a.active { background: var(--teal); color: #fff; }
.nav-ico { width: 20px; height: 20px; flex: none; }
.sidebar-foot { margin-top: auto; padding-top: 18px; font-size: 0.78rem; color: #7f9792; }

.main { min-width: 0; padding: 20px 16px 48px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.page-head .sub { color: var(--text-muted); font-size: 0.92rem; margin-top: 2px; }

/* mobile top nav for app pages */
.appbar { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.appbar-links { display: flex; gap: 4px; }
.appbar-links a { font-size: 0.82rem; padding: 7px 11px; border-radius: 999px; color: var(--text-muted); font-weight: 600; }
.appbar-links a.active { background: var(--teal-soft); color: var(--teal); }

/* stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 22px; }
.stat { padding: 16px; }
.stat .label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.stat .value { font-size: 1.7rem; font-weight: 700; color: var(--ink); margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 0.78rem; margin-top: 4px; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); } .delta.flat { color: var(--text-faint); }
.stat-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); float: right; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }

/* table */
.panel-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; padding: 16px 16px 0; }
.panel-title h2 { font-size: 1.05rem; margin: 0; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-faint); font-weight: 650; padding: 12px 16px; border-bottom: 1px solid var(--border); }
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 11px; }
.avatar { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; font-weight: 650; font-size: 0.82rem; background: var(--amber-soft); color: var(--amber); }
.who b { color: var(--ink); font-weight: 600; }
.who span { display: block; font-size: 0.78rem; color: var(--text-faint); }

/* calendar / deadline list */
.deadline { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.deadline:last-child { border-bottom: 0; }
.date-box { flex: none; width: 46px; text-align: center; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); padding: 5px 0; }
.date-box .d { font-size: 1.15rem; font-weight: 700; color: var(--ink); line-height: 1; }
.date-box .m { font-size: 0.66rem; text-transform: uppercase; color: var(--text-faint); letter-spacing: 0.04em; }
.deadline .meta { min-width: 0; }
.deadline .meta b { color: var(--ink); font-weight: 600; display: block; }
.deadline .meta span { font-size: 0.82rem; color: var(--text-muted); }

/* ---- mukellef view ---- */
.mk-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.cta-row { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 18px; }
.cta-big {
  display: flex; align-items: center; gap: 14px; padding: 18px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-sm); cursor: pointer; text-align: left;
  font: inherit; color: var(--text); width: 100%;
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.cta-big:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.cta-big:active { transform: translateY(1px); }
.cta-big.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.cta-big .ico { width: 44px; height: 44px; border-radius: 11px; flex: none; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); }
.cta-big.primary .ico { background: rgba(255,255,255,.18); color: #fff; }
.cta-big b { display: block; font-size: 1.02rem; }
.cta-big span { font-size: 0.84rem; color: var(--text-muted); }
.cta-big.primary span { color: rgba(255,255,255,.85); }

/* bar chart */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding: 10px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; }
.bars { width: 100%; display: flex; gap: 4px; align-items: flex-end; height: 130px; justify-content: center; }
.bar { width: 42%; border-radius: 4px 4px 0 0; min-height: 3px; }
.bar.in { background: var(--teal); }
.bar.out { background: var(--amber); }
.bar-col .lab { font-size: 0.72rem; color: var(--text-faint); }
.legend { display: flex; gap: 16px; font-size: 0.8rem; color: var(--text-muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

.kv { display: flex; justify-content: space-between; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-muted); font-size: 0.9rem; }
.kv .v { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.kv .v.big { font-size: 1.25rem; }

.doc-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.doc-item:last-child { border-bottom: 0; }
.doc-ico { width: 36px; height: 36px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.doc-item .t { min-width: 0; flex: 1; }
.doc-item .t b { color: var(--ink); font-weight: 600; font-size: 0.92rem; display: block; }
.doc-item .t span { font-size: 0.8rem; color: var(--text-faint); }

/* ---------- responsive ---------- */
@media (min-width: 680px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .value-grid { grid-template-columns: repeat(2, 1fr); }
  .cta-row { grid-template-columns: 1fr 1fr; }
  .mk-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .hero-grid { grid-template-columns: 1.1fr 0.9fr; align-items: center; }
  .hero h1 { font-size: 2.6rem; }
  .value-grid { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1.6fr 1fr; }
}
@media (min-width: 980px) {
  .shell { grid-template-columns: 248px 1fr; }
  .sidebar { display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; }
  .appbar { display: none; }
  .main { padding: 26px 30px 56px; }
  .mk-grid.span-wide { grid-template-columns: 1fr 1fr; }
}
