@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #fcfcfb;
  --surface-2: #f0efea;
  --line: #e3e1da;
  --text: #1c1b18;
  --text-2: #57554f;
  --muted: #8a877e;
  --accent: #0f6b5c;
  --accent-soft: #e2f0ec;
  --s-in: #2a78d6;         /* guest in the unit */
  --s-res: #4a3aa7;        /* reserved */
  --s-out: #c9c7c0;        /* finished stay */
  --s-out-text: #3a3935;
  --c-income: #2a78d6;
  --c-expense: #eb6834;
  --good: #0c7a0c;
  --good-bg: #e6f4e6;
  --warn: #9a6400;
  --warn-bg: #fdf2d8;
  --bad: #c03030;
  --bad-bg: #fbe9e9;
  --weekend: rgba(15, 107, 92, 0.05);
  --today: #0f6b5c;
  --shadow: 0 1px 2px rgba(28, 27, 24, 0.04), 0 4px 16px rgba(28, 27, 24, 0.04);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --line: #2f2f2c;
    --text: #f4f3ee;
    --text-2: #c3c2b7;
    --muted: #8f8d84;
    --accent: #4fc2a9;
    --accent-soft: #17312b;
    --s-in: #3987e5;
    --s-res: #9085e9;
    --s-out: #45443f;
    --s-out-text: #e4e2da;
    --c-income: #3987e5;
    --c-expense: #d95926;
    --good: #4cc24c;
    --good-bg: #16301a;
    --warn: #f0b43c;
    --warn-bg: #362a10;
    --bad: #ef7171;
    --bad-bg: #3a1a1a;
    --weekend: rgba(79, 194, 169, 0.06);
    --today: #4fc2a9;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2f2f2c;
  --text: #f4f3ee; --text-2: #c3c2b7; --muted: #8f8d84; --accent: #4fc2a9; --accent-soft: #17312b;
  --s-in: #3987e5; --s-res: #9085e9; --s-out: #45443f; --s-out-text: #e4e2da;
  --c-income: #3987e5; --c-expense: #d95926;
  --good: #4cc24c; --good-bg: #16301a; --warn: #f0b43c; --warn-bg: #362a10; --bad: #ef7171; --bad-bg: #3a1a1a;
  --weekend: rgba(79, 194, 169, 0.06); --today: #4fc2a9; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.num { font-feature-settings: "tnum"; white-space: nowrap; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--surface);
  border-inline-start: 0;
  border-inline-end: 1px solid var(--line);
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent);
  display: grid; place-items: center; color: #fff;
}
.brand b { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 8px 12px; color: var(--muted); font-size: 12px; }
.side-foot a { color: var(--text-2); }

main { padding: 26px 30px 60px; min-width: 0; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.top p { margin: 2px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 18px; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-h small { color: var(--muted); }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: 1.4fr 1fr; }
.g2e { grid-template-columns: 1fr 1fr; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: clamp(19px, 2.1vw, 24px); font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.tile .value small { font-size: 13px; font-weight: 500; color: var(--text-2); }
.tile .sub { font-size: 12.5px; color: var(--text-2); }
.tile.hero .value { font-size: clamp(22px, 2.6vw, 30px); color: var(--accent); }

/* ---------- unit cards ---------- */
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.unit { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); position: relative; }
.unit::before { content: ""; position: absolute; inset-block: 12px; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--good); }
.unit.busy::before { background: var(--s-in); }
.unit.res::before { background: var(--s-res); }
.unit h3 { display: flex; justify-content: space-between; gap: 8px; }
.unit .meta { color: var(--muted); font-size: 12.5px; }
.unit .who { margin-top: 6px; font-size: 14px; }
.unit .who small { color: var(--text-2); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-good { background: var(--good-bg); color: var(--good); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-info { background: var(--accent-soft); color: var(--accent); }
.b-mute { background: var(--surface-2); color: var(--text-2); }

/* ---------- timeline ---------- */
.tl { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.tl-inner { min-width: calc(150px + var(--days) * 34px); }
.tl-row { display: grid; grid-template-columns: 150px 1fr; border-top: 1px solid var(--line); min-height: 46px; }
.tl-row:first-child { border-top: 0; }
.tl-name { padding: 10px 12px; font-size: 13.5px; font-weight: 600; position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 2; border-inline-end: 1px solid var(--line); }
.tl-name small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; line-height: 1.3; }
.tl-track { position: relative; display: grid; grid-template-columns: repeat(var(--days), 1fr); }
.tl-day { border-inline-start: 1px solid var(--line); }
.tl-day:first-child { border-inline-start: 0; }
.tl-day.we { background: var(--weekend); }
.tl-day.today { background: var(--accent-soft); }
.tl-head .tl-day { text-align: center; font-size: 11.5px; color: var(--muted); padding: 6px 0 4px; line-height: 1.35; }
.tl-head .tl-day b { display: block; color: var(--text); font-size: 13px; }
.tl-head .tl-day.today b { color: var(--today); }
.tl-head .tl-name { color: var(--muted); font-weight: 500; }
.bar {
  position: absolute; top: 8px; bottom: 8px; border-radius: 6px; padding: 0 8px;
  font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px; margin-inline: 1px; z-index: 1;
}
.bar.in { background: var(--s-in); }
.bar.res { background: var(--s-res); }
.bar.out { background: var(--s-out); color: var(--s-out-text); }
.bar.debt { box-shadow: inset 0 -3px 0 var(--bad); }
.bar:hover { filter: brightness(1.1); color: #fff; }
.bar.out:hover { color: var(--s-out-text); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-inline-end: 5px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.amount, th.amount { text-align: end; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.void td { opacity: 0.45; text-decoration: line-through; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .sub { color: var(--muted); font-size: 12.5px; }

/* ---------- finance bars ---------- */
.hbar {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label value" "track track";
  gap: 2px 10px; padding: 6px 0; font-size: 14px;
}
.hbar > span:first-child { grid-area: label; }
.hbar > span:last-child { grid-area: value; color: var(--text-2); }
.hbar .track { grid-area: track; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; }
.fill.in { background: var(--c-income); }
.fill.out { background: var(--c-expense); }
.fill.occ { background: var(--accent); }
.cols { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin: 10px 0 6px; }
.ticks { position: relative; width: 64px; height: 200px; font-size: 11.5px; color: var(--muted); }
.ticks span { position: absolute; inset-inline-start: 0; transform: translateY(50%); white-space: nowrap; }
.plot {
  height: 200px; display: flex; align-items: stretch; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line);
  background: repeating-linear-gradient(to top, var(--line) 0 1px, transparent 1px 25%);
  margin-bottom: 24px;
}
.plot .col { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; cursor: default; }
.plot .col:hover { background: var(--surface-2); }
.plot .bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.plot .bars i { width: min(22px, 30%); border-radius: 4px 4px 0 0; min-height: 0; }
.plot .b-in { background: var(--c-income); }
.plot .b-out { background: var(--c-expense); }
.plot .lbl { position: absolute; bottom: -22px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
details summary { list-style-position: inside; }

/* ---------- forms ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input[type=text], input[type=search], input[type=password], select {
  font: inherit; font-size: 14px; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg a { padding: 6px 12px; font-size: 13.5px; color: var(--text-2); border-inline-start: 1px solid var(--line); }
.seg a:first-child { border-inline-start: 0; }
.seg a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.note { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px; }
.note small { color: var(--muted); display: block; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.docs img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.alert { border-radius: 12px; padding: 12px 14px; background: var(--warn-bg); color: var(--warn); margin-bottom: 14px; font-size: 14px; }

/* ---------- forms ---------- */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px 16px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.form .wide { grid-column: 1 / -1; }
.form input { width: 100%; }
form.inline { display: inline; }
.notice { border-radius: 12px; padding: 12px 14px; background: var(--good-bg); color: var(--good); margin-bottom: 14px; font-size: 14px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); display: grid; gap: 12px; }
.login .brand { justify-content: center; padding-bottom: 6px; }
.login .err { color: var(--bad); font-size: 13.5px; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 6px 0 10px; }
  .brand small { display: none; }
  .nav { display: flex; gap: 2px; overflow-x: auto; width: 100%; }
  .nav a { padding: 6px 10px; white-space: nowrap; font-size: 13.5px; }
  .nav svg { display: none; }
  .side-foot { display: none; }
  main { padding: 18px 16px 48px; }
  .g2, .g2e { grid-template-columns: 1fr; }
  .tile .value { font-size: 20px; }
}
@media print {
  .side, .actions, .filters { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}
