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

:root {
  --bg: #f4f5f2; --surface: #ffffff; --surface-2: #f8f9f6; --line: #e3e6df; --text: #1d2420; --muted: #66706a;
  --brand: #1f6f5c; --brand-soft: #e3f1ec; --accent: #b7791f;
  --ok: #2f855a; --ok-soft: #e6f4ec; --warn: #b7791f; --warn-soft: #fbf1df; --bad: #c0392b; --bad-soft: #fbe9e7;
  --idle: #6b5bb5; --idle-soft: #eeebf9; --off: #8a9590; --off-soft: #eef0ee;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 14px rgba(20, 30, 25, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --surface: #1a201d; --surface-2: #1f2622; --line: #2c3530; --text: #e6ebe8; --muted: #9aa59f;
    --brand: #4fb39a; --brand-soft: #1d3029; --accent: #e0a64a;
    --ok: #5cc28b; --ok-soft: #1c2f24; --warn: #e0a64a; --warn-soft: #33291a; --bad: #ef7f72; --bad-soft: #3a2220;
    --idle: #a99bf0; --idle-soft: #26223b; --off: #7f8a85; --off-soft: #232a26;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.7 Vazirmatn, Tahoma, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ───── layout ───── */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-inline-start: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; padding: 4px 8px 16px; }
.brand img { width: 30px; height: 30px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.who { margin-top: 18px; padding: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.main { padding: 22px 26px 60px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.top h1 { font-size: 21px; margin: 0; }
.menu-btn { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 0 0 auto; width: 250px; z-index: 20; transform: translateX(110%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 14px 16px 60px; }
}

/* ───── components ───── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.card h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .g2, .g3 { grid-template-columns: 1fr; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .k { color: var(--muted); font-size: 13px; }
.tile .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.4; }
.tile .s { color: var(--muted); font-size: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

input[type=text], input[type=tel], input[type=number], input:not([type]), select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input.date { width: 120px; direction: ltr; text-align: center; }
input.qty { width: 100px; direction: ltr; text-align: center; }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.f > * { color: var(--text); }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }

.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; background: var(--surface-2); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.n, th.n { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; }

.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.p-ok { background: var(--ok-soft); color: var(--ok); }
.p-warn { background: var(--warn-soft); color: var(--warn); }
.p-bad { background: var(--bad-soft); color: var(--bad); }
.p-idle { background: var(--idle-soft); color: var(--idle); }
.p-off { background: var(--off-soft); color: var(--off); }
.p-brand { background: var(--brand-soft); color: var(--brand); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; }

/* تقویم ماه */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .h { text-align: center; color: var(--muted); font-size: 12px; }
.cal .d { border-radius: 9px; padding: 6px 4px; min-height: 52px; text-align: center; font-size: 13px; border: 1px solid var(--line); background: var(--surface-2); cursor: default; }
.cal .d b { display: block; font-size: 15px; }
.cal .d.work { background: var(--ok-soft); border-color: transparent; color: var(--ok); cursor: pointer; }
.cal .d.idle { background: var(--idle-soft); border-color: transparent; color: var(--idle); cursor: pointer; }
.cal .d.holiday { background: var(--off-soft); border-color: transparent; color: var(--off); cursor: pointer; }
.cal .d.draft { border: 1px dashed var(--warn); color: var(--warn); cursor: pointer; }
.cal .d.missing { border-color: var(--bad-soft); color: var(--bad); }
.cal .d.future { opacity: .45; }
.cal .d.today { outline: 2px solid var(--brand); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* نمودار میله‌ای ساده */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.bars .b { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; position: relative; }
.bars .b:hover { opacity: 1; }
.bars .b.zero { background: var(--line); }
.bars-x { display: flex; gap: 3px; font-size: 10px; color: var(--muted); }
.bars-x span { flex: 1; text-align: center; }

.photo { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: flex; align-items: center; justify-content: center; z-index: 50; cursor: zoom-out; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; }

.login { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.login .card { padding: 26px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 22px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--brand); border-color: var(--brand); font-weight: 700; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
details summary { cursor: pointer; color: var(--brand); }
.setting { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.setting:last-child { border-bottom: 0; }
.setting .t { font-weight: 600; }
.setting .h { grid-column: 1; color: var(--muted); font-size: 13px; }
.setting .c { grid-row: 1 / span 2; grid-column: 2; }
@media (max-width: 600px) { .setting { grid-template-columns: 1fr; } .setting .c { grid-row: auto; grid-column: 1; } }
