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

:root {
  --bg: #F3F5F7;
  --card: #FFFFFF;
  --ink: #16202A;
  --ink-2: #3F4A55;
  --muted: #55616C;
  --line: #DDE2E7;
  --line-2: #EEF0F2;
  --field: #C5CDD5;
  --brand: #1D4ED8;
  --brand-soft: #EEF3FF;
  --ok: #166534; --ok-bg: #E7F4EC; --ok-line: #B7DEC4;
  --warn: #9A3412; --warn-bg: #FFEDD5; --warn-line: #F5B98A;
  --amber: #92400E; --amber-bg: #FEF3C7; --amber-line: #F3D27A;
  --bad: #991B1B; --bad-bg: #FEE2E2; --bad-line: #F3B4B4;
  --info: #3730A3; --info-bg: #E0E7FF;
  --radius: 14px;
  --font: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.7; }
body { direction: rtl; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.4; }
h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 700; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 16px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
.wrap.narrow { max-width: 1180px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.row.center { align-items: center; }
.row.tight { gap: 8px; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.grow { flex: 999 1 520px; min-width: 0; }
.side { flex: 1 1 320px; min-width: 0; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* Header */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1400px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; flex: none; }
.logo-fallback { width: 40px; height: 40px; border-radius: 10px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; flex: none; }
.partner-logo { height: 40px; max-width: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; padding: 2px 6px; background: #fff; }
.brand-name { font-weight: 800; font-size: 16px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card.soft { background: var(--brand-soft); border-color: #C9D6F8; }
.card.warn { background: #FFF7ED; border-color: var(--warn-line); }
.card.bad { border-color: var(--bad-line); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 800; }

/* Buttons & chips */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--field); background: var(--card); font-weight: 700; font-size: 14px; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ok { background: var(--ok-bg); border-color: var(--ok-line); color: #14532D; }
.btn.danger { background: var(--bad-bg); border-color: var(--bad-line); color: #7F1D1D; }
.btn.amber { background: var(--amber-bg); border-color: var(--amber-line); color: #78350F; }
.btn.orange { background: var(--warn-bg); border-color: var(--warn-line); color: #7C2D12; }
.btn.sm { min-height: 34px; padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--brand); }
.btn.block { width: 100%; }
.chip { display: inline-flex; align-items: center; min-height: 38px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--field); background: var(--card); font-size: 13px; font-weight: 700; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.gray { background: var(--line-2); color: var(--ink-2); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 700; }
.input, select.input, textarea.input { border: 1px solid var(--field); border-radius: 10px; padding: 9px 10px; background: var(--card); min-height: 42px; width: 100%; }
textarea.input { resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.8; }
.check input { margin-top: 6px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row > .field { flex: 1 1 160px; }
.error { background: var(--bad-bg); border: 1px solid var(--bad-line); color: #7F1D1D; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.notice { background: var(--ok-bg); border: 1px solid var(--ok-line); color: #14532D; padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr.sel td { background: var(--brand-soft); }
table.t tr.flag td { background: #FFF8F1; }

/* Tabs / nav */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }

/* Toasts */
.toasts { position: fixed; bottom: 16px; left: 16px; right: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; max-width: 560px; width: 100%; box-shadow: 0 8px 24px rgba(0,0,0,.18); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.toast.ok { background: #14532D; }
.toast.bad { background: #7F1D1D; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 32, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.modal { background: var(--card); border-radius: 16px; padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; }

/* Bars */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; border-bottom: 1px solid var(--field); }
.bars > button, .bars > div { flex: 1 1 0; min-width: 0; border: 0; padding: 0; border-radius: 4px 4px 0 0; background: #9DB4E8; }
.bars > .on { background: var(--brand); }
.meter { height: 10px; background: #E6EAEE; border-radius: 5px; overflow: hidden; }
.meter > div { height: 10px; background: var(--brand); border-radius: 5px; }

/* Video tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; padding: 0; text-align: right; background: var(--card); border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.tile.sel { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, .3); }
.tile .vid { position: relative; width: 100%; aspect-ratio: 4 / 3; background: #2B3540; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.tile .seat { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; border-radius: 6px; padding: 1px 6px; }
.tile .dur { position: absolute; top: 6px; left: 6px; color: #fff; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.tile .nocam { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #A9B4BE; font-size: 12px; }
.tile .meta { padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 2px; }
.tile .nm { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.focus-video { width: 100%; aspect-ratio: 4 / 3; background: #2B3540; border-radius: 12px; overflow: hidden; }
.focus-video video { width: 100%; height: 100%; object-fit: contain; transform: scaleX(-1); }

/* Timer ring */
.ring { position: relative; width: 210px; height: 210px; }
.ring .c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .t { font-size: 42px; font-weight: 800; letter-spacing: 1px; }

/* Day cards in shift calendar */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }

/* Admin layout */
.admin { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.admin-nav { flex: 1 1 220px; max-width: 260px; display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.admin-nav button { text-align: right; border: 0; background: none; padding: 10px 12px; border-radius: 10px; font-weight: 700; font-size: 14px; }
.admin-nav button.on { background: var(--ink); color: #fff; }
.admin-main { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 760px) {
  .admin-nav { max-width: none; flex-direction: row; overflow-x: auto; }
  .admin-nav button { white-space: nowrap; }
  .ring { width: 180px; height: 180px; }
  .ring .t { font-size: 36px; }
}

.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.big-logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto; object-fit: contain; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Segmented control (login method, etc.) */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #EEF0F2; border-radius: 10px; padding: 4px; gap: 4px; }
.seg button { min-height: 38px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
/* Contacts / SMS tables */
.subs { display: flex; flex-wrap: wrap; gap: 6px; }
.subs label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 8px; border: 1px solid var(--field); border-radius: 999px; cursor: pointer; }
.subs label.on { background: #EEF4FF; border-color: #BFD3FE; color: #1E3A8A; }
.subs input { margin: 0; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #EEF0F2; color: #374151; }
.pill.ok { background: #DCFCE7; color: #166534; } .pill.bad { background: #FEE2E2; color: #991B1B; } .pill.warn { background: #FEF3C7; color: #92400E; } .pill.info { background: #DBEAFE; color: #1E40AF; }
.vars { display: flex; flex-wrap: wrap; gap: 4px; }
.vars button { font: inherit; font-size: 12px; border: 1px dashed #93A3B8; background: #F8FAFC; border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.smsprev { background: #F1F5F9; border-radius: 12px 12px 12px 2px; padding: 10px 12px; font-size: 13px; line-height: 1.9; white-space: pre-wrap; max-width: 420px; }
