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

:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --border: #e3e6e1;
  --text: #1c2420;
  --muted: #69736d;
  --primary: #0f766e;
  --primary-2: #115e59;
  --primary-soft: #e3f3f0;
  --on-primary: #ffffff;
  --ok: #15803d;   --ok-soft: #e4f5e9;
  --warn: #b45309; --warn-soft: #fdf1dd;
  --bad: #b91c1c;  --bad-soft: #fde6e6;
  --info: #1d4ed8; --info-soft: #e5edff;
  --leave: #7c3aed; --leave-soft: #efe7fd;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 4px 16px rgba(16, 24, 20, .05);
  --radius: 14px;
  --sidebar: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101513;
    --surface: #171d1a;
    --surface-2: #1e2622;
    --border: #2a332e;
    --text: #e7ece9;
    --muted: #9aa49e;
    --primary: #2dd4bf;
    --primary-2: #5eead4;
    --primary-soft: #133a35;
    --on-primary: #062420;
    --ok: #4ade80;   --ok-soft: #14301f;
    --warn: #fbbf24; --warn-soft: #362a10;
    --bad: #f87171;  --bad-soft: #3a1a1a;
    --info: #93b4ff; --info-soft: #1a2542;
    --leave: #c4a4ff; --leave-soft: #2b2140;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
  font-feature-settings: "ss01";
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.4; margin: 0; }
h1 { font-size: 1.35rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.nowrap { white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--surface); border-left: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 800; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.brand-mark svg { width: 20px; height: 20px; stroke-width: 2.2; }
.brand small { display: block; font-size: .72rem; font-weight: 500; color: var(--muted); margin-top: -4px; }
.nav-label { font-size: .72rem; font-weight: 700; color: var(--muted); padding: 14px 10px 4px; letter-spacing: .02em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text);
  font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav .count { margin-inline-start: auto; background: var(--bad); color: #fff; font-size: .72rem; border-radius: 99px; padding: 0 7px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; padding: 6px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; flex: none; }
.avatar.sm { width: 30px; height: 30px; font-size: .85rem; }
.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.container { max-width: 1180px; margin: 0 auto; }
.topbar { display: none; }
.tabbar { display: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stack > * + * { margin-top: 16px; }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 1.5rem; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: .78rem; color: var(--muted); }
.stat.ok .value { color: var(--ok); } .stat.bad .value { color: var(--bad); } .stat.warn .value { color: var(--warn); } .stat.info .value { color: var(--info); }

/* ---------- clock hero ---------- */
.hero { padding: 26px; display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; overflow: hidden; position: relative; }
.hero .time { font-size: 2.6rem; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero .date { color: var(--muted); margin-top: 4px; }
.hero .state { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.clock-btn {
  width: 168px; height: 168px; border-radius: 50%; border: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: 1.15rem;
  display: grid; place-items: center; align-content: center; gap: 4px; color: #fff; position: relative;
  background: radial-gradient(circle at 30% 25%, #1fb5a5, #0f766e 65%);
  box-shadow: 0 10px 30px rgba(15, 118, 110, .35), inset 0 -4px 0 rgba(0, 0, 0, .12); transition: transform .12s ease;
}
.clock-btn:active { transform: scale(.97); }
.clock-btn svg { width: 34px; height: 34px; stroke: #fff; stroke-width: 2; }
.clock-btn small { font-weight: 500; font-size: .78rem; opacity: .9; }
.clock-btn.out { background: radial-gradient(circle at 30% 25%, #f08a5d, #c2410c 65%); box-shadow: 0 10px 30px rgba(194, 65, 12, .35), inset 0 -4px 0 rgba(0, 0, 0, .12); }
.clock-btn.out::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid rgba(194, 65, 12, .35); animation: pulse 2s ease-out infinite; }
@keyframes pulse { from { transform: scale(.95); opacity: 1; } to { transform: scale(1.12); opacity: 0; } }
.clock-btn[disabled] { opacity: .6; cursor: wait; }

.timeline { display: flex; flex-direction: column; gap: 8px; }
.session { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.session .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.session.open .dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.session .range { font-weight: 700; font-variant-numeric: tabular-nums; }
.session .len { margin-inline-start: auto; color: var(--muted); font-size: .85rem; }

.progress { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.leave { background: var(--leave-soft); color: var(--leave); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; color: var(--muted); font-weight: 700; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.weekend td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); color: var(--muted); }
tr.today td { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
tr.today td:first-child { box-shadow: inset -3px 0 0 var(--primary); }
tfoot td { font-weight: 800; background: var(--surface-2); }
.t-bad { color: var(--bad); font-weight: 700; }
.t-ok { color: var(--ok); font-weight: 700; }
.t-warn { color: var(--warn); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: .78rem; padding: 0 8px; border-radius: 6px; background: var(--surface-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.pending { background: var(--warn-soft); color: var(--warn); }
.chip.open { background: var(--info-soft); color: var(--info); }
a.chip:hover { text-decoration: none; filter: brightness(.95); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; }
.field .help { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.field .err, .errorlist { color: var(--bad); font-size: .82rem; margin: 4px 0 0; padding: 0; list-style: none; }
.input, select.input, textarea.input {
  width: 100%; font: inherit; font-size: .95rem; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; min-height: 42px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=time].input, input[data-jdate].input { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.check .help { margin-top: 0; }
.switch { appearance: none; width: 40px; height: 22px; border-radius: 99px; background: var(--border); position: relative; cursor: pointer; flex: none; margin: 2px 0 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: right .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch:checked { background: var(--primary); }
.switch:checked::after { right: 21px; }
.form-errors { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 14px; font-size: .9rem; }
.form-errors ul { margin: 0; padding: 0; list-style: none; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 140px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; margin-bottom: 8px; padding: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600; font-size: .9rem;
  padding: 8px 16px; min-height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn svg.i { width: 18px; height: 18px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad-soft); }
.btn.ok { color: var(--ok); }
.btn.ok:hover { background: var(--ok-soft); }
.btn.sm { padding: 3px 10px; min-height: 30px; font-size: .82rem; border-radius: 8px; }
.btn.icon { padding: 0; width: 34px; min-height: 34px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
form.inline { display: inline; }

/* ---------- misc ---------- */
.alerts { margin-bottom: 18px; display: grid; gap: 8px; }
.alert { padding: 11px 16px; border-radius: 12px; font-weight: 500; display: flex; gap: 10px; align-items: center; }
.alert.success { background: var(--ok-soft); color: var(--ok); }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.info, .alert.warning { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty svg.i { width: 36px; height: 36px; opacity: .5; }
.month-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.month-nav .title { font-weight: 800; padding: 0 12px; min-width: 120px; text-align: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.week-grid span { text-align: center; font-size: .75rem; padding: 4px 0; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.week-grid span.on { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.day-row { display: grid; grid-template-columns: 110px 70px 1fr 1fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.day-row:last-child { border-bottom: 0; }
.day-row.off .input { opacity: .45; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(1200px 500px at 100% -10%, var(--primary-soft), transparent 60%), var(--bg); }
.auth .card { width: 100%; max-width: 400px; padding: 30px 28px; }
.auth .brand { justify-content: center; padding-bottom: 6px; font-size: 1.3rem; }

/* ---------- jalali date picker ---------- */
.jdp { position: absolute; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 10px; width: 280px; direction: rtl; }
.jdp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 800; }
.jdp-head button, .jdp-days button { font: inherit; border: 0; background: transparent; color: var(--text); cursor: pointer; border-radius: 8px; }
.jdp-head button { width: 32px; height: 32px; }
.jdp-head button:hover, .jdp-days button:hover { background: var(--surface-2); }
.jdp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.jdp-days .wd { font-size: .72rem; color: var(--muted); padding: 4px 0; }
.jdp-days button { height: 34px; font-variant-numeric: tabular-nums; }
.jdp-days button.today { color: var(--primary); font-weight: 800; }
.jdp-days button.sel { background: var(--primary); color: var(--on-primary); }
.jdp-days button.fri { color: var(--bad); }
.jdp-foot { display: flex; justify-content: space-between; margin-top: 6px; }
.jdp-foot button { font: inherit; font-size: .82rem; border: 0; background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 3px 10px; cursor: pointer; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { padding: 16px 16px 96px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .topbar .brand { padding: 0; font-size: 1rem; }
  .shell { flex-direction: column; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: .7rem; color: var(--muted); padding: 4px 0; border-radius: 10px; position: relative; }
  .tabbar a.active { color: var(--primary); font-weight: 700; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .count { position: absolute; top: 0; left: calc(50% - 20px); background: var(--bad); color: #fff; font-size: .62rem; border-radius: 99px; padding: 0 5px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .hero { grid-template-columns: 1fr; text-align: center; justify-items: center; padding: 22px 16px; }
  .hero .state { justify-content: center; }
  .hero .time { font-size: 2.3rem; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .day-row { grid-template-columns: 1fr auto; }
  .day-row .input { grid-column: span 1; }
  .hide-sm { display: none !important; }
  .mobile-menu { display: block; }
}
@media (min-width: 901px) { .show-sm { display: none !important; } }

@media print {
  .sidebar, .topbar, .tabbar, .no-print, .actions, .alerts { display: none !important; }
  body { background: #fff; color: #000; font-size: 11px; }
  .main { padding: 0; }
  .card { box-shadow: none; border-color: #ccc; }
  th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  th, td { padding: 4px 6px; }
  .table-wrap { overflow: visible; }
}
