/* فونت self-host (spec A5، AS-18): Vazirmatn 33.0.3، مجوز OFL در static/vendor/vazirmatn/OFL.txt */
@font-face {
  font-family: "Vazirmatn";
  src: url("../vendor/vazirmatn/Vazirmatn-Variable.f6d31671339d.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   سیستم طراحی (راهنما: docs/design-system.md)
   ۱. توکن‌ها  ۲. پایه  ۳. چیدمان (نوار بالا، منوی کاربر، زیرمنو)  ۴. اجزا (دکمه، فرم، کارت، جدول، ...)
   ۵. صفحه‌های خاص  ۶. واکنش‌گرا و چاپ
   ========================================================================== */

/* ===== ۱. توکن‌ها (پالت لوگوی مدرسه: بنفش، زرد، فیروزه‌ای؛ زمینه‌ی صورتی خیلی کم‌رنگ) ===== */
:root {
  --bg: #fff6fa;
  --surface: #ffffff;
  --pink-100: #ffeaf3;
  --pink-200: #f9d5e5;
  --pink-300: #eeb4cf;
  --primary: #8a4a88;          /* کنتراست روی سفید حدود ۶ به ۱ */
  --primary-dark: #6f3a6d;
  --teal: #1f7a83;
  --teal-soft: #dff3f5;
  --yellow: #fff126;
  --fg: #2a2230;
  --muted: #655c6d;
  --line: #d9cde0;
  --err: #b3261e;
  --warn: #8a5a00;
  --ok: #1d6f55;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;   /* مقیاس فاصله */
  --radius: 12px;
  --shadow: 0 1px 2px rgba(111, 58, 109, .08), 0 4px 14px rgba(111, 58, 109, .06);
  --focus: 0 0 0 3px #fff, 0 0 0 5px var(--teal);
  --w-narrow: 760px;
  --w-wide: 1100px;
}

/* ===== ۲. پایه ===== */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif; line-height: 1.75; font-size: 16px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.45em; color: var(--primary-dark); }
h2 { font-size: 1.15em; color: var(--primary-dark); }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
.skip-link { position: absolute; inset-inline-start: var(--s2); top: -100px; z-index: 100; padding: var(--s2) var(--s4);
  background: var(--primary-dark); color: #fff; border-radius: 0 0 var(--s2) var(--s2); }
.skip-link:focus { top: 0; }
.ltr { direction: ltr; unicode-bidi: embed; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 1.1em; letter-spacing: .05em; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hint { color: var(--muted); font-size: .9em; }
.small { font-size: .8em; }
.err { color: var(--err); }
.ok { color: var(--ok); }
.actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* ===== ۳. چیدمان ===== */
.topbar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s4);
  padding: var(--s2) var(--s4); background: var(--surface); border-bottom: 3px solid var(--pink-200); }
.brand { display: inline-flex; align-items: center; gap: var(--s3); font-weight: 700; text-decoration: none; color: var(--primary-dark); }
.brand img { height: 44px; width: auto; display: block; }
.topnav { display: flex; gap: var(--s1); flex-wrap: wrap; flex: 1; }
.topnav a, .subnav a { padding: var(--s1) var(--s3); border-radius: 999px; text-decoration: none; color: var(--fg);
  border: 1.5px solid transparent; white-space: nowrap; }
.topnav a:hover, .subnav a:hover { background: var(--pink-100); border-color: var(--pink-200); }
.topnav a[aria-current="page"], .subnav a[aria-current="page"] { background: var(--pink-100); border-color: var(--primary);
  color: var(--primary-dark); font-weight: 600; }
.topbar-end { display: flex; align-items: center; gap: var(--s2); margin-inline-start: auto; }
.chip { display: inline-flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s3); border-radius: 999px;
  border: 1.5px solid var(--teal); color: var(--teal); background: var(--teal-soft); text-decoration: none; font-weight: 600; }
.chip:hover { background: var(--teal); color: #fff; }
.chip small { font-weight: 400; opacity: .9; }

/* منوی کاربر (details؛ باز و بسته با مرورگر، بیرون‌کلیک و Esc در app.js) */
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: inline-flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s3) 0 var(--s2);
  border: 1.5px solid var(--pink-300); border-radius: 999px; cursor: pointer; font-weight: 500; background: #fff; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary::after { content: ""; width: 7px; height: 7px; border: solid var(--primary); border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-2px); margin-inline-start: var(--s1); }
.usermenu[open] summary, .usermenu summary:hover { background: var(--pink-100); border-color: var(--primary); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: .9em; }
.usermenu-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-panel { position: absolute; z-index: 40; inset-inline-end: 0; top: calc(100% + var(--s2)); min-width: 200px; padding: var(--s2);
  background: #fff; border: 1.5px solid var(--pink-200); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(42, 34, 48, .18);
  display: flex; flex-direction: column; gap: var(--s1); }
.usermenu-panel a, .usermenu-panel button { display: flex; width: 100%; min-height: 40px; align-items: center; justify-content: flex-start;
  padding: var(--s2) var(--s3); border-radius: 8px; border: 0; background: none; box-shadow: none; color: var(--fg);
  font-weight: 500; text-decoration: none; cursor: pointer; text-align: start; }
.usermenu-panel a:hover, .usermenu-panel button:hover { background: var(--pink-100); color: var(--primary-dark); }
.usermenu-panel hr { border: 0; border-top: 1px solid var(--pink-200); margin: var(--s1) 0; width: 100%; }

.subbar { background: var(--surface); border-bottom: 1.5px solid var(--pink-200); }
.subnav { display: flex; gap: 2px; max-width: var(--w-wide); margin: 0 auto; padding: var(--s2) var(--s4); overflow-x: auto; scrollbar-width: thin; }

main { display: flex; flex-direction: column; gap: var(--s4); max-width: var(--w-narrow); margin: 0 auto; padding: var(--s5) var(--s4); }
main.wide { max-width: var(--w-wide); }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.page-head h1 { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.section-title { margin-top: var(--s2); display: flex; align-items: center; gap: var(--s2); }

/* ===== ۴. اجزا ===== */
/* کارت */
.card { background: var(--surface); border: 1.5px solid var(--pink-200); border-radius: var(--radius);
  padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); box-shadow: var(--shadow); }
fieldset.card { min-width: 0; margin: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s3); }
.stat .stat-value { font-size: 1.8em; font-weight: 700; color: var(--primary-dark); line-height: 1.3; }
.stat .stat-title { color: var(--muted); }
.stats { flex-direction: row; gap: var(--s5); flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; padding: var(--s4); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s5); margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }
.balance { font-size: 1.3em; color: var(--primary-dark); }

/* فرم */
label { font-weight: 500; }
input, select, textarea { font: inherit; color: var(--fg); background: #fff; min-height: 44px; padding: var(--s2) var(--s3);
  border-radius: 10px; border: 1.5px solid var(--line); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--err); }
input[type="radio"], input[type="checkbox"] { min-height: auto; accent-color: var(--primary); }
form.inline { display: inline; }
.field { display: flex; flex-direction: column; gap: var(--s1); }
.field.check { flex-direction: row; align-items: center; gap: var(--s2); }
.stack-form { display: flex; flex-direction: column; gap: var(--s4); }
.field-error { color: var(--err); font-size: .92em; }
.row-form { flex-direction: row; flex-wrap: wrap; align-items: end; gap: var(--s3); }
.check { display: flex; gap: var(--s2); align-items: center; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.price-input { width: 130px; }
.weekdays ul, .weekdays div { display: flex; flex-wrap: wrap; gap: var(--s3); list-style: none; padding: 0; margin: 0; }
.weekdays label { display: flex; gap: var(--s1); align-items: center; }

/* دکمه: همه حاشیه‌دار */
button, .button { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: var(--s2) 18px; border-radius: 10px; cursor: pointer; text-decoration: none; font-weight: 600;
  background: var(--primary); color: #fff; border: 2px solid var(--primary-dark);
  box-shadow: 0 2px 0 var(--primary-dark); transition: background-color .15s, transform .15s, box-shadow .15s; }
button:hover, .button:hover { background: var(--primary-dark); color: #fff; }
button:active, .button:active { transform: translateY(2px); box-shadow: 0 0 0 var(--primary-dark); }
button:focus-visible, .button:focus-visible, a:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus); }
.secondary { background: #fff; color: var(--primary-dark); border: 2px solid var(--primary); box-shadow: 0 2px 0 var(--pink-300); }
.secondary:hover { background: var(--pink-100); color: var(--primary-dark); }
button.danger, .button.danger { background: var(--err); border: 2px solid #8c1d18; box-shadow: 0 2px 0 #8c1d18; color: #fff; }
button.danger:hover, .button.danger:hover { background: #8c1d18; }
button.link { background: none; color: var(--primary-dark); min-height: 36px; padding: var(--s1) var(--s3); box-shadow: none;
  border: 1.5px solid var(--pink-300); border-radius: 999px; font-weight: 500; }
button.link:hover { background: var(--pink-100); }
button[disabled], .button.disabled { opacity: .45; cursor: not-allowed; box-shadow: none; pointer-events: none; }
.sticky-submit { position: sticky; bottom: 10px; width: 100%; box-shadow: 0 6px 18px rgba(111, 58, 109, .35); }

/* پیام */
.msg { padding: 10px 14px; border-radius: 10px; background: var(--teal-soft); border: 1.5px solid #a9dce0; }
.msg-error { background: #fdecea; color: var(--err); border-color: #f0b8b3; }
.msg-warning { background: #fff4e0; color: var(--warn); border-color: #f2d49b; }
.msg-success { background: #e6f5ee; color: var(--ok); border-color: #b5dfca; }

/* آیکون i: توضیح با هاور، فوکوس یا کلیک */
.info { position: relative; display: inline-block; vertical-align: middle; margin-inline: var(--s1); font-size: 1rem; font-weight: 400; }
.info-btn { min-height: 24px; width: 24px; padding: 0; border-radius: 50%; font: italic 700 .85rem/1 Georgia, serif;
  background: #fff; color: var(--teal); border: 1.5px solid var(--teal); box-shadow: none; }
.info-btn:hover, .info.open .info-btn { background: var(--teal); color: #fff; }
.info-text { position: absolute; z-index: 30; top: calc(100% + 8px); inset-inline-start: -8px; width: max-content; max-width: min(280px, 78vw);
  padding: 10px 12px; border-radius: 10px; background: var(--fg); color: #fff; font-size: .88rem; font-weight: 400; line-height: 1.7;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); display: none; text-align: start; }
.info-text.flip { inset-inline-start: auto; inset-inline-end: -8px; }
.info:hover .info-text, .info:focus-within .info-text, .info.open .info-text { display: block; }

/* برچسب و نشان */
.tag { display: inline-block; padding: 0 10px; border-radius: 999px; background: var(--teal-soft); color: var(--teal); font-size: .88em; font-weight: 500; }
.tag-bank_refund { background: #fdecea; color: var(--err); }
.tag-manual_topup, .tag-manual_refund { background: #fff4e0; color: var(--warn); }
.badge { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--yellow); color: var(--fg);
  font-size: .8em; font-weight: 700; text-align: center; }

/* جدول و صفحه‌بندی */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); font-size: .95em;
  border: 1.5px solid var(--pink-200); border-radius: var(--radius); overflow: hidden; }
.table th { background: var(--pink-100); color: var(--primary-dark); font-weight: 600; }
.table th, .table td { padding: 10px; border-bottom: 1px solid var(--pink-200); text-align: right; vertical-align: top; overflow-wrap: break-word; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fffafc; }
tr.muted { color: var(--muted); }
tr.row-error { background: #fdecea; }
tr.row-warning { background: #fff8e8; }
tr.delivered { background: var(--teal-soft); }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s3); }
.pager .button { min-height: 40px; padding: 6px var(--s4); }
.pager-info { color: var(--muted); }

/* نوار هفته: بازه‌ی تاریخ + امروز/هفته‌ی قبل/هفته‌ی بعد + دکمه‌ی هر روز (با تعداد زیرش) */
.week-bar { padding: var(--s3); gap: var(--s3); }
.week-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.week-range { font-weight: 700; color: var(--primary-dark); flex: 1; text-align: center; min-width: 12ch; }
.week-top .button { min-height: 40px; padding: 6px var(--s3); }
.day-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--s2); }
.day-tab { display: flex; flex-direction: column; align-items: center; gap: 0; padding: var(--s2) var(--s1); min-height: 64px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; color: var(--fg); text-decoration: none; line-height: 1.4; }
.day-tab:hover { border-color: var(--primary); background: #fffafc; color: var(--fg); }
.day-tab .day-name { font-weight: 600; }
.day-tab .day-count { font-size: 1.25em; font-weight: 700; color: var(--primary-dark); }
.day-tab[aria-current="page"] { background: var(--primary); border-color: var(--primary-dark); color: #fff; }
.day-tab[aria-current="page"] .day-count { color: #fff; }
.day-tab.today:not([aria-current="page"]) { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }

/* ===== ۵. صفحه‌های خاص ===== */
.day-card h2, .day-card legend { font-size: 1.05em; display: flex; align-items: center; gap: var(--s1); }
.day-card.muted { opacity: .7; }
.meal-option { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1.5px solid var(--line);
  border-radius: 10px; min-height: 48px; cursor: pointer; background: #fff; transition: border-color .15s, background-color .15s; }
.meal-option:hover { border-color: var(--primary); background: #fffafc; }
.meal-option:has(input:checked) { border-color: var(--primary); background: var(--pink-100); box-shadow: inset 0 0 0 1px var(--primary); }
.meal-option input { width: 20px; height: 20px; }
.meal-option .grow { flex: 1; }
.meal-option .price { white-space: nowrap; font-weight: 600; color: var(--primary-dark); }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.offer-row { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: center; padding: 6px 0; border-bottom: 1px solid var(--pink-200); }
.reservation { flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.kitchen-list button { min-width: 110px; }
.notification.unread { border-right: 5px solid var(--primary); }
.slips { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s2); }
.slip { border: 1.5px dashed #999; padding: var(--s3); background: #fff; break-inside: avoid; border-radius: 10px; }
.slip-title { font-weight: bold; margin-bottom: var(--s1); }

/* ===== ۶. واکنش‌گرا و چاپ ===== */
@media (max-width: 720px) {
  .topnav { order: 3; flex-basis: 100%; }
  .topbar-end { margin-inline-start: auto; }
  .chip small { display: none; }
}
@media (max-width: 560px) {
  main { padding: var(--s4) var(--s3); }
  .table { font-size: .88em; display: block; overflow-x: auto; white-space: nowrap; }
  .table th, .table td { padding: var(--s2) 10px; }
  .usermenu-name { display: none; }
  .week-range { order: -1; flex-basis: 100%; }
  .week-top .button { flex: 1; }
  .day-tab { min-height: 58px; font-size: .88em; }
  .dl { grid-template-columns: 1fr; gap: 0; }
  .dl dd { margin-bottom: var(--s2); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .no-print, .kitchen-list button { display: none !important; }
  body { background: #fff; }
  tr.delivered { background: none; }
  main, main.wide { max-width: none; padding: 0; }
  .slips { grid-template-columns: repeat(2, 1fr); }
  .card, .table { box-shadow: none; }
}

/* ===== افزوده‌ها: عکس پروفایل، رزرو، اعلان، داشبورد ===== */
:root {
  --green-line: #5bf29a;        /* سبز فسفری کم‌رنگ برای روز رزروشده */
  --green-glow: rgba(91, 242, 154, .35);
  --green-bg: #f2fff7;
  --green-dark: #1d6f55;
  --red-bg: #fff1f0;
  --red-line: #f0a8a3;
}
.avatar { object-fit: cover; flex: none; }
img.avatar { display: inline-block; }
.name-cell { display: inline-flex; align-items: center; gap: var(--s2); }
.photo { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 3px solid var(--pink-200); background: var(--pink-100); flex: none; }
.photo.placeholder { display: inline-flex; align-items: center; justify-content: center; font-size: 2.4rem; font-weight: 700; color: #fff; background: var(--primary); }
.profile-head { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; padding-bottom: var(--s3); margin-bottom: var(--s2); border-bottom: 1px solid var(--pink-200); }
.profile-head h2 { margin-bottom: 0; }
.photo-edit { display: flex; align-items: center; gap: var(--s3); }
.photo-edit .photo { width: 96px; height: 96px; font-size: 2rem; }

.tag-ok { background: #dcfbe8; color: var(--green-dark); }
.day-card.reserved { border: 2.5px solid var(--green-line); background: var(--green-bg); box-shadow: 0 0 0 3px var(--green-glow), var(--shadow); }

.notification.ok { border-color: var(--green-line); background: var(--green-bg); }
.notification.bad { border-color: var(--red-line); background: var(--red-bg); }
.notification.unread { border-right-width: 5px; }
.notification.ok.unread { border-right-color: #2fbf71; }
.notification.bad.unread { border-right-color: var(--err); }

.day-tab.off:not([aria-current="page"]) { background: #faf6fa; color: var(--muted); }
.day-tab.off:not([aria-current="page"]) .day-count { color: var(--muted); }
.day-tab .short { display: none; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s3); }
.dash-section { display: flex; flex-direction: column; gap: var(--s3); }
.stat { border-top-width: 5px; }
.stat-head { display: flex; align-items: center; gap: var(--s2); }
.stat-title { font-size: 1.1em; color: var(--fg); margin: 0; }
.stat-icon { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.stat .button { align-self: flex-start; }
.tone-meal { border-top-color: var(--primary); }
.tone-meal .stat-icon { background: var(--pink-100); color: var(--primary-dark); }
.tone-next { border-top-color: var(--teal); }
.tone-next .stat-icon { background: var(--teal-soft); color: var(--teal); }
.tone-money { border-top-color: #e0a400; }
.tone-money .stat-icon { background: #fff4cf; color: var(--warn); }
.tone-wallet { border-top-color: #2fbf71; }
.tone-wallet .stat-icon { background: #dcfbe8; color: var(--green-dark); }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.holidays-card { border-style: dashed; }

@media (max-width: 560px) {
  .day-tab .full { display: none; }
  .day-tab .short { display: inline; font-weight: 700; }
  .day-tab { padding-inline: 2px; }
  .photo { width: 96px; height: 96px; }
}
