@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Variable.woff2') format('woff2 supports variations'),
       url('/assets/fonts/Vazirmatn-Variable.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f7f9;
  --bg-2: #ffffff;
  --bg-3: #f0f2f5;
  --text: #1a1d23;
  --text-2: #626a76;
  --border: #e3e6ea;
  --accent: #2f6f4f;
  --accent-2: #388a61;
  --accent-text: #ffffff;
  --danger: #b54545;
  --danger-bg: #fbeaea;
  --warn: #b5852f;
  --ok: #2f8a54;
  --radius: 12px;
  --radius-s: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.18);
}
[data-theme="dark"] {
  --bg: #14161a;
  --bg-2: #1d2026;
  --bg-3: #23262e;
  --text: #e8eaed;
  --text-2: #99a1ac;
  --border: #2c313a;
  --accent: #4f9e74;
  --accent-2: #5cb083;
  --accent-text: #0f1114;
  --danger: #d76b6b;
  --danger-bg: #2a1c1c;
  --warn: #d1a24f;
  --ok: #5cb083;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-weight: 400;
  transition: background .25s, color .25s;
  -webkit-font-smoothing: antialiased;
}
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
a { color: var(--accent); }
button { font-family: inherit; }
::selection { background: var(--accent); color: var(--accent-text); }

/* ---------- splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  background: var(--bg); transition: opacity .35s;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash .mark { width: 84px; height: 84px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; transform: scale(.93); } }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand svg { width: 30px; height: 30px; color: var(--accent); }
.spacer { flex: 1; }
.container { max-width: 1120px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 16px; border-radius: var(--radius-s);
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  font-size: .92rem; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--bg-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-icon { padding: 7px; width: 34px; height: 34px; }
.btn-sm { padding: 6px 11px; font-size: .82rem; }

/* ---------- cards / stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--text-2); font-size: .85rem; }
.stat .value { font-size: 1.7rem; font-weight: 700; margin-top: 4px; }
.stat .value.small { font-size: 1.05rem; font-weight: 600; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab { padding: 10px 16px; cursor: pointer; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- panel ---------- */
.panel { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 1.05rem; }

/* ---------- table ---------- */
.table-scroll { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 720px; }
th, td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; font-size: .82rem; background: var(--bg-3); }
tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--text-2); }
.row-actions { display: flex; gap: 6px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge.on { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.off { background: var(--bg-3); color: var(--text-2); }
.badge.exp { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .86rem; color: var(--text-2); margin-bottom: 6px; }
.input, select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: inherit; font-size: .92rem;
}
.input:focus, select:focus { outline: none; border-color: var(--accent); }
.input.ltr { direction: ltr; text-align: left; }
.hint { font-size: .8rem; color: var(--text-2); margin-top: 5px; }
.amount-words { font-size: .8rem; color: var(--text-2); min-height: 1.2em; margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- switch ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; height: 18px; width: 18px; inset-inline-end: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(-18px); }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 200; padding: 16px; }
.modal { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-start; padding: 14px 18px; border-top: 1px solid var(--border); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 380px; padding: 30px 26px; }
.login-card .brand { justify-content: center; margin-bottom: 6px; font-size: 1.15rem; }
.login-sub { text-align: center; color: var(--text-2); font-size: .9rem; margin-bottom: 22px; }

/* ---------- persian datepicker ---------- */
.exp-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.exp-row .switch { flex-shrink: 0; }
.exp-row label { margin: 0; color: var(--text); font-size: .9rem; cursor: pointer; }
.pdp { position: relative; }
.pdp-field { position: relative; }
.pdp-input { cursor: pointer; }
.pdp-clear { position: absolute; inset-inline-start: 8px; top: 50%; transform: translateY(-50%); display: none; place-items: center; width: 22px; height: 22px; border: none; border-radius: 50%; background: var(--bg-3); color: var(--text-2); cursor: pointer; font-size: .7rem; }
.pdp-clear:hover { color: var(--danger); }
.pdp-disabled { opacity: .45; pointer-events: none; }
.pdp-pop { position: absolute; z-index: 300; top: calc(100% + 6px); inset-inline-end: 0; width: 288px; max-width: calc(100vw - 40px); background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px; }
.pdp-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.pdp-nav { flex-shrink: 0; width: 32px; height: 32px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: var(--radius-s); cursor: pointer; font-size: 1.1rem; line-height: 1; }
.pdp-nav:hover { background: var(--bg-3); }
.pdp-title { flex: 1; padding: 7px; border: none; background: none; color: var(--text); font-family: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; border-radius: var(--radius-s); }
.pdp-title:hover { background: var(--bg-3); }
.pdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.pdp-wd span { color: var(--text-2); font-size: .74rem; padding: 4px 0; font-weight: 600; }
.pdp-days span { padding: 0; }
.pdp-day { aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--radius-s); font-size: .85rem; cursor: pointer; }
.pdp-day:hover { background: var(--bg-3); }
.pdp-day.today { border: 1px solid var(--accent); }
.pdp-day.sel { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.pdp-months, .pdp-years { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 4px; }
.pdp-cell { padding: 11px 4px; border-radius: var(--radius-s); font-size: .85rem; cursor: pointer; }
.pdp-cell:hover { background: var(--bg-3); }
.pdp-cell.sel { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.pdp-foot { margin-top: 8px; text-align: center; border-top: 1px solid var(--border); padding-top: 8px; }
.pdp-tbtn { border: none; background: none; color: var(--accent); font-family: inherit; font-size: .85rem; cursor: pointer; padding: 4px 12px; border-radius: var(--radius-s); }
.pdp-tbtn:hover { background: var(--bg-3); }

/* ---------- misc ---------- */
.toast { position: fixed; inset-block-end: 22px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 999px; font-size: .88rem; z-index: 500; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: var(--danger); color: #fff; }
.err-msg { color: var(--danger); font-size: .86rem; min-height: 1.2em; margin-top: 4px; }
.empty { text-align: center; color: var(--text-2); padding: 40px 20px; }
.copy-key { display: flex; gap: 8px; align-items: center; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 10px 12px; }
.copy-key code { flex: 1; word-break: break-all; direction: ltr; text-align: left; font-size: .82rem; }
.hidden { display: none !important; }
