/* ==========================================================================
   آی‌لاین — سیستم طراحی (ساده، فارسی، RTL)
   ========================================================================== */
:root {
  --navy: #0f2544;
  --navy-2: #17335c;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eaf1ff;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --success: #16a34a;
  --success-soft: #e9f8ef;
  --warn: #d97706;
  --warn-soft: #fff6e5;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 37, 68, .06), 0 8px 24px rgba(15, 37, 68, .06);
  --shadow-lg: 0 20px 45px rgba(15, 37, 68, .16);
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.45; font-weight: 700; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .45); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; right: -999px; top: 8px; background: #fff; padding: 8px 14px; border-radius: 8px; z-index: 99; }
.skip:focus { right: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), #3b82f6);
  display: grid; place-items: center; font-size: 1rem; color: #fff;
}
.brand small { display: block; font-size: .68rem; color: #a9c0e6; font-weight: 400; }
.topnav { display: flex; gap: 4px; margin-inline-start: auto; align-items: center; }
.topnav a {
  color: #d7e3f7; padding: 8px 10px; border-radius: 8px; font-size: .9rem;
}
.topnav a:hover, .topnav a.active { background: rgba(255, 255, 255, .1); color: #fff; text-decoration: none; }
.icon-btn {
  background: rgba(255, 255, 255, .1); border: 0; color: #fff; width: 38px; height: 38px;
  border-radius: 10px; display: grid; place-items: center; cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { background: rgba(255, 255, 255, .18); }
.menu-btn { display: none; }
.user-chip {
  display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .1);
  border-radius: 999px; padding: 4px 12px 4px 4px; color: #fff; font-size: .85rem;
}
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700;
}

/* ------------------------------------------------------------------ layout */
.main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 16px 48px; }
.main:focus { outline: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin: 0; }
.crumbs { color: var(--muted); font-size: .82rem; margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card.tight { padding: 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2, .card-title h3 { margin: 0; }
.hero {
  background: radial-gradient(1200px 400px at 90% -10%, rgba(37, 99, 235, .35), transparent 60%), var(--navy);
  color: #fff; border-radius: 20px; padding: 34px 26px; margin-bottom: 22px;
}
.hero h1 { font-size: 1.9rem; margin-bottom: .3em; }
.hero p { color: #cfdcf1; max-width: 620px; margin-bottom: 1.2em; }
.hero .row { gap: 10px; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat.accent .stat-value { color: var(--blue); }
.stat.ok .stat-value { color: var(--success); }
.stat.warn .stat-value { color: var(--warn); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px;
  font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
  background: var(--blue); color: #fff; transition: background .15s, box-shadow .15s, transform .05s;
  min-height: 42px;
}
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--navy); border-color: var(--line-strong); }
.btn.secondary:hover { background: #f8fafc; }
.btn.ghost { background: transparent; color: var(--blue); }
.btn.ghost:hover { background: var(--blue-soft); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.success { background: var(--success); }
.btn.success:hover { background: #15803d; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: .84rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: .86rem; font-weight: 600; color: var(--navy); }
.field .hint { font-size: .76rem; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  font: inherit; font-size: .93rem; background: #fff; color: var(--text); min-height: 44px;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); outline: none;
}
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); background: #fffafa; }
.field .err { color: var(--danger); font-size: .78rem; }
.req { color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.alert { border-radius: 10px; padding: 10px 14px; font-size: .88rem; margin-bottom: 14px; border: 1px solid transparent; }
.alert.info { background: var(--blue-soft); color: #1e3a8a; border-color: #c7d9ff; }
.alert.warn { background: var(--warn-soft); color: #92400e; border-color: #fbd99a; }
.alert.danger { background: var(--danger-soft); color: #991b1b; border-color: #f6c4c4; }
.alert.success { background: var(--success-soft); color: #14532d; border-color: #bce3ca; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; background: #fff; }
thead th {
  text-align: right; font-weight: 600; color: var(--muted); background: #f8fafc;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-cards { display: none; }

/* ------------------------------------------------------------------ badges */
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: #eef2f7; color: #334155; white-space: nowrap;
}
.tag.blue { background: var(--blue-soft); color: #1d4ed8; }
.tag.green { background: var(--success-soft); color: #15803d; }
.tag.amber { background: var(--warn-soft); color: #b45309; }
.tag.red { background: var(--danger-soft); color: #b91c1c; }
.tag.gray { background: #f1f5f9; color: #475569; }

/* ------------------------------------------------------------------ lists */
.option-list { display: grid; gap: 10px; }
.option {
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; cursor: pointer; background: #fff;
}
.option:hover { border-color: var(--blue); background: #fbfdff; }
.option input { accent-color: var(--blue); width: 18px; height: 18px; margin: 0; }
.option.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); background: #f8fbff; }
.option .o-title { font-weight: 600; }
.option .o-meta { color: var(--muted); font-size: .8rem; }
.option .o-price { margin-inline-start: auto; font-weight: 700; color: var(--navy); white-space: nowrap; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .e-icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.timeline li { padding-inline-start: 14px; border-inline-start: 2px solid var(--line); }
.timeline li:first-child { border-color: var(--blue); }
.timeline .t-meta { font-size: .78rem; color: var(--muted); }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pagination button { min-width: 36px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters .field { margin: 0; min-width: 140px; }

/* ------------------------------------------------------------------ drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 45; border: 0;
}
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 272px; background: var(--navy);
  color: #fff; z-index: 46; transform: translateX(100%); transition: transform .22s ease;
  overflow-y: auto; padding: 14px; display: grid; align-content: start; gap: 4px;
}
.drawer.open { transform: translateX(0); }
.drawer .d-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.drawer .d-group { color: #8fa9cf; font-size: .74rem; margin: 14px 8px 4px; letter-spacing: .02em; }
.drawer a {
  color: #d7e3f7; padding: 9px 10px; border-radius: 9px; display: flex; align-items: center; gap: 9px;
  font-size: .9rem;
}
.drawer a:hover, .drawer a.active { background: rgba(255, 255, 255, .1); color: #fff; text-decoration: none; }
.drawer a .badge { margin-inline-start: auto; }

/* --------------------------------------------------------------- admin shell */
.admin-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); gap: 20px; align-items: start; }
.sidebar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; position: sticky; top: 76px; box-shadow: var(--shadow);
}
.sidebar .s-group { color: var(--muted); font-size: .72rem; padding: 10px 10px 4px; }
.sidebar a {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 9px;
  color: #334155; font-size: .89rem; font-weight: 500;
}
.sidebar a:hover { background: #f1f5f9; text-decoration: none; }
.sidebar a.active { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }
.admin-content { min-width: 0; }
.admin-topbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.admin-mnav { display: none; margin-bottom: 14px; }
.admin-mnav select { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; background: #fff; }

/* ------------------------------------------------------------------- toast */
.toast {
  position: fixed; inset-inline: 0; bottom: 18px; margin: auto; width: max-content; max-width: 90vw;
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 999px;
  box-shadow: var(--shadow-lg); z-index: 80; font-size: .88rem;
}
.toast.error { background: #7f1d1d; }
.toast.success { background: #14532d; }

/* ------------------------------------------------------------------- modal */
[hidden] { display: none !important; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 70;
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 16px; width: min(560px, 100%); padding: 20px; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 4px; }
.modal .m-body { margin: 12px 0 16px; }
.modal .m-actions { display: flex; gap: 10px; justify-content: flex-start; }

/* --------------------------------------------------------------- utilities */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.embed { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; background: #000; margin: 10px 0; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; direction: ltr; unicode-bidi: embed; }

.footer {
  border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: .83rem;
  padding: 18px 16px; text-align: center;
}
.footer a { color: var(--muted); }

@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .admin-mnav { display: block; }
  .menu-btn { display: grid; }
  .topnav { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .brand small { display: none; }
  .brand { font-size: .98rem; gap: 8px; }
  .topbar-inner { gap: 8px; padding: 8px 12px; }
  .admin-entry { display: none; }
  .user-chip span:first-child { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-chip { padding: 3px 10px 3px 3px; font-size: .8rem; }
  .main { padding: 16px 12px 40px; }
  .hero { padding: 24px 18px; border-radius: 16px; }
  .hero h1 { font-size: 1.5rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 6px; }
  .card { padding: 14px; }
  h1 { font-size: 1.35rem; }
  .table-wrap { display: none; }
  .table-cards { display: grid; gap: 10px; }
  .table-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
  .table-card .tc-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
  .table-card .tc-row { display: flex; justify-content: space-between; gap: 8px; font-size: .82rem; padding: 3px 0; }
  .table-card .tc-row span:first-child { color: var(--muted); }
  .filters .field { flex: 1 1 100%; min-width: 0; }
  .btn { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
