/* ==========================================================================
   Hamyar Design System v1
   یک منبع واحد برای توکن‌ها، الگوهای پایه و بازنویسی سبک‌های قالب قدیمی.
   ترتیب بارگذاری: بعد از bundle.css و app.css تا بر آن‌ها غلبه کند.
   ========================================================================== */

/* فونت واحد سامانه: Ravi (FontIran، فایل‌های تأییدشده پروژه). Ravi دو وزن دارد؛ وزن‌های میانی به نزدیک‌ترین وزن نگاشت می‌شوند. */
@font-face { font-family: "Hamyar"; src: url("/assets/fonts/ravi/Ravi-Regular.woff2") format("woff2"); font-weight: 100 599; font-display: swap; }
@font-face { font-family: "Hamyar"; src: url("/assets/fonts/ravi/Ravi-Bold.woff2") format("woff2"); font-weight: 600 900; font-display: swap; }
/* fallback در صورت نبود Ravi: Vazir موجود در پروژه */
@font-face { font-family: "HamyarFallback"; src: url("/assets/fonts/vazir-400.woff2") format("woff2"); font-weight: 100 599; font-display: swap; }
@font-face { font-family: "HamyarFallback"; src: url("/assets/fonts/vazir-700.woff2") format("woff2"); font-weight: 600 900; font-display: swap; }

:root {
  --primary: #2446A8;
  --primary-hover: #1C3889;
  --primary-soft: #EEF2FC;
  --success: #0F7553;
  --success-soft: #E7F5EF;
  --warning: #9C5208;
  --warning-soft: #FDF1E3;
  --danger: #C4282F;
  --danger-soft: #FCEBEC;

  --background: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --border: #E7E9EE;
  --border-strong: #D0D5DD;

  --text-primary: #16181D;
  --text-secondary: #5D6679;
  --text-on-primary: #FFFFFF;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --font: "Hamyar", "HamyarFallback", Tahoma, system-ui, sans-serif;
  --fs-xs: 12.5px;
  --fs-sm: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 26px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .08);
  --focus: 0 0 0 3px rgba(36, 70, 168, .28);
  --tap: 44px;
  --sidebar-w: 272px;
  --topbar-h: 64px;
  --bottomnav-h: 64px;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body.hm-body { padding: 0 !important; margin: 0; }
body, body.hm-body {
  font-family: var(--font) !important;
  font-size: var(--fs-md);
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--background) !important;
  direction: rtl;
  text-align: right;
}
body *, body input, body select, body textarea, body button, .tooltip, .popover, .swal-modal, .swal2-popup {
  font-family: var(--font) !important;
}
/* آیکن‌فونت‌ها نباید فونت متن بگیرند */
body [class^="icon-"], body [class*=" icon-"], body [class^="ti-"], body [class*=" ti-"], body .fa, body [class^="fa-"], body [class*=" fa-"] {
  font-family: inherit;
}
body [class^="icon-"], body [class*=" icon-"] { font-family: 'icomoon' !important; }
body [class^="ti-"], body [class*=" ti-"] { font-family: 'themify' !important; }
body .fa { font-family: FontAwesome !important; }

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { color: var(--text-primary); font-weight: 700; line-height: 1.45; }
h1, .h1 { font-size: var(--fs-2xl); }
h2, .h2 { font-size: var(--fs-xl); }
h3, .h3 { font-size: var(--fs-lg); }
h4, .h4, h5, .h5, h6, .h6 { font-size: var(--fs-md); }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
small, .small { font-size: var(--fs-xs); }
.text-muted { color: var(--text-secondary) !important; }
img { max-width: 100%; height: auto; }
textarea, table, iframe, video, pre { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--focus) !important; border-radius: 6px; }
.hm-ltr, input[type=email], input[type=tel], input[inputmode=numeric], .hm-num { direction: ltr; unicode-bidi: isolate; }
.hm-ltr { display: inline-block; }
input[type=email], input[type=tel], input[inputmode=numeric] { text-align: right; }
.sr-only, .hm-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hm-skip { position: absolute; top: -48px; right: 16px; z-index: 2000; background: var(--primary); color: #fff; padding: 8px 16px; border-radius: var(--radius-sm); }
.hm-skip:focus { top: 8px; color: #fff; }

/* قالب قدیمی: لودر تمام‌صفحه و دکمه چرخ‌دنده سفارشی‌سازی حذف می‌شوند */
.page-loader, .layout-builder { display: none !important; }

/* ---------- App shell ---------- */
.hm-body { min-height: 100vh; }
.hm-sidebar {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 1040;
  width: var(--sidebar-w); background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform .2s ease;
}
.hm-brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-4) var(--space-3); min-height: var(--topbar-h); text-decoration: none !important; }
.hm-brand-mark { flex: 0 0 40px; width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: var(--fs-lg); overflow: hidden; }
.hm-brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.hm-brand-text { min-width: 0; }
.hm-brand-name { display: block; color: var(--text-primary); font-weight: 700; font-size: var(--fs-sm); line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-brand-sub { display: block; color: var(--text-secondary); font-size: var(--fs-xs); }
.hm-sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 var(--space-3) var(--space-6); overscroll-behavior: contain; }

.hm-nav-list, .hm-nav-list ul { list-style: none; margin: 0; padding: 0; }
.hm-nav-label { margin: var(--space-4) var(--space-3) var(--space-1); font-size: var(--fs-xs); color: var(--text-secondary); font-weight: 500; }
.hm-nav-link, .hm-nav-item > details > summary {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: var(--fs-sm); font-weight: 500;
  text-decoration: none !important; cursor: pointer; list-style: none; user-select: none;
}
.hm-nav-item > details > summary::-webkit-details-marker { display: none; }
.hm-nav-item > details > summary::after { content: ""; margin-inline-start: auto; width: 7px; height: 7px; border-left: 1.6px solid var(--text-secondary); border-bottom: 1.6px solid var(--text-secondary); transform: rotate(45deg); transition: transform .15s; }
.hm-nav-item > details[open] > summary::after { transform: rotate(-45deg); }
.hm-nav-link:hover, .hm-nav-item > details > summary:hover { background: var(--background); color: var(--text-primary); }
.hm-nav-link i, .hm-nav-item summary i { width: 20px; text-align: center; color: var(--text-secondary); font-size: 16px; }
.hm-nav-link.is-active, .hm-nav-item > details.is-active > summary { background: var(--primary-soft); color: var(--primary); }
.hm-nav-link.is-active i, .hm-nav-item > details.is-active > summary i { color: var(--primary); }
.hm-nav-item details > ul, .hm-nav-item details > ul ul { padding: var(--space-1) 0 var(--space-2); margin-inline-start: 22px; border-inline-start: 1px solid var(--border); }
.hm-nav-item details ul ul { margin-inline-start: 12px; }
.hm-nav-item details li > a { display: flex; align-items: center; min-height: 36px; padding: 4px var(--space-3); border-radius: 6px; color: var(--text-secondary); font-size: var(--fs-sm); text-decoration: none !important; }
.hm-nav-item details li > a:hover { color: var(--primary); background: var(--background); }
.hm-nav-item details li > a.is-active { color: var(--primary); font-weight: 600; }
.hm-nav-item details a > li { list-style: none; padding: 6px var(--space-3); color: var(--text-secondary); font-size: var(--fs-sm); }
.hm-nav-item details a:hover > li { color: var(--primary); }
.hm-nav-item details ul i { display: none; }
.hm-nav-sub { padding: var(--space-2) var(--space-3) 2px; font-size: var(--fs-xs); color: var(--text-secondary); }
.hm-nav-note { margin: 4px 24px; font-size: var(--fs-xs); color: var(--warning); }

.hm-shell { margin-right: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.hm-topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-6); background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.hm-topbar-title { font-weight: 700; font-size: var(--fs-md); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hm-topbar-spacer { flex: 1; }
.hm-icon-btn { position: relative; display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-primary); text-decoration: none !important; }
.hm-icon-btn:hover { background: var(--background); color: var(--text-primary); }
.hm-icon-btn svg { width: 22px; height: 22px; }
.hm-dot { position: absolute; top: 8px; left: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.hm-menu-btn { display: none; }
.hm-user { position: relative; }
.hm-user > summary { list-style: none; display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: 0 var(--space-2); border-radius: var(--radius-sm); cursor: pointer; }
.hm-user > summary::-webkit-details-marker { display: none; }
.hm-user > summary:hover { background: var(--background); }
.hm-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; font-weight: 700; flex: 0 0 36px; }
.hm-user-name { font-size: var(--fs-sm); font-weight: 500; color: var(--text-primary); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-user-menu { position: absolute; left: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: var(--space-2); z-index: 1050; }
.hm-user-menu a { display: flex; align-items: center; min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-sm); color: var(--text-primary); font-size: var(--fs-sm); text-decoration: none !important; }
.hm-user-menu a:hover { background: var(--background); }
.hm-user-menu hr { margin: var(--space-2) 0; border-color: var(--border); }
.hm-user-menu .is-danger { color: var(--danger); }

.hm-main, .hm-shell .main-content { flex: 1; padding: var(--space-6) !important; margin: 0 !important; width: auto !important; background: transparent !important; }
.hm-main > .container-fluid { padding: 0; max-width: 1360px; margin: 0 auto; }
.hm-backdrop { display: none; }
.hm-bottomnav { display: none; }

/* ---------- Search ---------- */
.hm-search { position: relative; flex: 0 1 380px; }
.hm-search input { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); padding: 0 40px 0 64px; font-size: var(--fs-sm); color: var(--text-primary); }
.hm-search input:focus { border-color: var(--primary); background: #fff; box-shadow: var(--focus); outline: 0; }
.hm-search svg { position: absolute; right: 12px; top: 10px; width: 20px; height: 20px; color: var(--text-secondary); pointer-events: none; }
.hm-search kbd { position: absolute; left: 8px; top: 8px; background: #fff; border: 1px solid var(--border); color: var(--text-secondary); font-size: 11px; border-radius: 6px; padding: 1px 6px; box-shadow: none; direction: ltr; }
.hm-search-results { position: absolute; top: calc(100% + 6px); right: 0; left: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: var(--space-2); max-height: 60vh; overflow: auto; z-index: 1060; }
.hm-search-results a { display: block; padding: 8px var(--space-3); border-radius: var(--radius-sm); color: var(--text-primary); font-size: var(--fs-sm); text-decoration: none !important; }
.hm-search-results a small { display: block; color: var(--text-secondary); }
.hm-search-results a:hover, .hm-search-results a.is-focus { background: var(--primary-soft); }
.hm-search-results .hm-empty-line { padding: 8px var(--space-3); color: var(--text-secondary); font-size: var(--fs-sm); }

/* ---------- Page header ---------- */
.hm-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.hm-page-header h1 { margin: 0; font-size: var(--fs-2xl); }
.hm-page-header p { margin: var(--space-1) 0 0; color: var(--text-secondary); font-size: var(--fs-sm); }
.hm-page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.hm-breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 var(--space-1); font-size: var(--fs-xs); color: var(--text-secondary); }
.hm-breadcrumb li + li::before { content: "/"; margin-left: 6px; color: var(--border-strong); }
.hm-breadcrumb a { color: var(--text-secondary); }
/* سربرگ‌های قدیمی قالب */
.page-header { margin-bottom: var(--space-6) !important; padding: 0 !important; background: none !important; }
.page-header h3, .page-header h4 { font-size: var(--fs-xl) !important; margin-bottom: var(--space-1); }
.breadcrumb { background: transparent !important; padding: 0 !important; margin: 0 !important; font-size: var(--fs-xs); }
.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-secondary) !important; }

/* ---------- Cards ---------- */
.card, .hm-card { background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--radius-lg) !important; box-shadow: none !important; margin-bottom: var(--space-4); }
.card-body, .hm-card-body { padding: var(--space-6) !important; }
.card-header, .card-footer { background: transparent !important; border-color: var(--border) !important; padding: var(--space-4) var(--space-6) !important; }
.card-title, .hm-card-title { font-size: var(--fs-lg) !important; font-weight: 700 !important; color: var(--text-primary) !important; margin-bottom: var(--space-4) !important; text-align: right !important; }
.hm-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.hm-card-head .hm-card-title { margin: 0 !important; }
.hm-card-link { font-size: var(--fs-sm); font-weight: 500; }
.hm-card.is-highlight { border-color: var(--primary) !important; box-shadow: 0 0 0 3px var(--primary-soft) !important; }
.bg-danger-gradient, .bg-warning-gradient, .bg-success-gradient, .bg-info-gradient, .bg-primary-gradient, .bg-secondary-gradient { background: var(--surface) !important; color: var(--text-primary) !important; border: 1px solid var(--border); }

/* ---------- Stat card ---------- */
.hm-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.hm-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-6); display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; text-decoration: none !important; color: inherit; }
a.hm-stat:hover { border-color: var(--border-strong); color: inherit; }
.hm-stat-label { color: var(--text-secondary); font-size: var(--fs-sm); }
.hm-stat-value { font-size: 30px; font-weight: 700; line-height: 1.3; color: var(--text-primary); }
.hm-stat-value.is-danger { color: var(--danger); }
.hm-stat-foot { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: auto; }
.hm-stat-foot a { font-weight: 500; }

/* ---------- Grid helpers ---------- */
.hm-grid { display: grid; gap: var(--space-4); }
.hm-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hm-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hm-grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.hm-stack > * + * { margin-top: var(--space-4); }
.hm-help { display: block; color: var(--text-secondary); font-size: var(--fs-xs); margin-top: 4px; }
.hm-template { display: block; width: 100%; text-align: right; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3); margin-bottom: var(--space-2); cursor: pointer; font: inherit; color: inherit; min-height: var(--tap); }
.hm-template strong { display: block; font-size: var(--fs-sm); margin-bottom: 2px; }
.hm-template span { color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.7; }
.hm-template:hover { border-color: var(--primary); }
.hm-template[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft, #EEF2FB); box-shadow: inset 0 0 0 1px var(--primary); }
.hm-section-title { font-size: var(--fs-md); font-weight: 700; margin: var(--space-6) 0 var(--space-3); }

/* ---------- Buttons ---------- */
.btn, .hm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4) !important; border-radius: var(--radius-sm) !important;
  font-size: var(--fs-sm) !important; font-weight: 500 !important; line-height: 1.4 !important;
  border: 1px solid transparent; box-shadow: none !important; text-decoration: none !important; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn svg, .hm-btn svg { width: 18px; height: 18px; flex: 0 0 18px; }
.btn-sm { min-height: 32px; padding: 0 var(--space-3) !important; font-size: var(--fs-xs) !important; }
.btn-lg, .hm-btn-lg { min-height: 48px; padding: 0 var(--space-6) !important; font-size: var(--fs-md) !important; }
.btn-block, .hm-btn-block { display: flex; width: 100%; }
.btn-primary, .btn-info, .hm-btn-primary { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }
.btn-primary:hover, .btn-info:hover, .hm-btn-primary:hover { background: var(--primary-hover) !important; border-color: var(--primary-hover) !important; }
.btn-success { background: var(--success) !important; border-color: var(--success) !important; color: #fff !important; }
.btn-danger { background: var(--surface) !important; border-color: #F2C4C6 !important; color: var(--danger) !important; }
.btn-danger:hover { background: var(--danger-soft) !important; }
.btn-warning { background: var(--warning-soft) !important; border-color: #F3D3AE !important; color: var(--warning) !important; }
.btn-secondary, .btn-light, .btn-dark, .btn-default, .btn-outline-primary, .btn-outline-secondary, .hm-btn-secondary { background: var(--surface) !important; border-color: var(--border-strong) !important; color: var(--text-primary) !important; }
.btn-secondary:hover, .btn-light:hover, .btn-default:hover, .btn-outline-primary:hover, .btn-outline-secondary:hover, .hm-btn-secondary:hover { background: var(--background) !important; }
.hm-btn-soft { background: var(--primary-soft) !important; color: var(--primary) !important; border-color: transparent !important; }
.hm-btn-soft:hover { background: #E1E8FA !important; }
.hm-btn-ghost { background: transparent !important; color: var(--primary) !important; border-color: transparent !important; }
.btn:disabled, .btn.disabled, .hm-btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-smll { min-height: 20px !important; padding: 0 6px !important; font-size: 11px !important; }

/* ---------- Forms ---------- */
.form-control, .custom-select, select.form-control, .hm-input, .select2-container .select2-selection--single, .select2-container .select2-selection--multiple {
  min-height: var(--tap); height: auto; border: 1px solid var(--border-strong) !important; border-radius: var(--radius-sm) !important;
  background-color: var(--surface) !important; color: var(--text-primary) !important; font-size: var(--fs-md) !important; padding: 8px var(--space-3);
  box-shadow: none !important; width: 100%; max-width: 100%;
}
textarea.form-control, textarea.hm-input { min-height: 96px; resize: vertical; }
.form-control:focus, .hm-input:focus, .custom-select:focus { border-color: var(--primary) !important; box-shadow: var(--focus) !important; outline: 0; }
.form-control::placeholder, .hm-input::placeholder { color: #98A2B3; }
.form-control[readonly], .form-control:disabled { background: var(--background) !important; }
label, .col-form-label, .hm-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-primary); margin-bottom: 6px; }
.form-group, .hm-field { margin-bottom: var(--space-4); }
.hm-req { color: var(--danger); margin-inline-start: 2px; }
.hm-hint { display: block; font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 4px; }
.hm-error, .invalid-feedback { display: block; font-size: var(--fs-xs); color: var(--danger); margin-top: 4px; }
.is-invalid { border-color: var(--danger) !important; }
.hm-fieldset { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-6) var(--space-2); margin-bottom: var(--space-6); background: var(--surface); }
.hm-fieldset > legend { width: auto; padding: 0 var(--space-2); font-size: var(--fs-md); font-weight: 700; margin: 0; }
input[type=file].form-control { padding: 6px; }
.custom-control-label { font-weight: 400; }
.hm-password { position: relative; }
.hm-password .hm-input { padding-left: 52px; }
.hm-password button { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); }

/* ---------- Tables ---------- */
.table-responsive { border-radius: var(--radius-md); }
.table { color: var(--text-primary) !important; font-size: var(--fs-sm); margin-bottom: 0; background: var(--surface); }
.table thead th, .table th { background: var(--surface-2) !important; color: var(--text-secondary) !important; font-weight: 500 !important; font-size: var(--fs-xs) !important; border-bottom: 1px solid var(--border) !important; border-top: 0 !important; white-space: nowrap; vertical-align: middle !important; text-align: right; }
.table td { border-top: 1px solid var(--border) !important; vertical-align: middle !important; text-align: right; }
.table-bordered, .table-bordered td, .table-bordered th { border-color: var(--border) !important; }
.table-striped tbody tr:nth-of-type(odd) { background: transparent !important; }
.table-hover tbody tr:hover, .table tbody tr:hover { background: var(--surface-2) !important; }
.table .btn { min-height: 32px; padding: 0 var(--space-3) !important; font-size: var(--fs-xs) !important; }
.hm-table-empty td { text-align: center !important; padding: 0 !important; }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select { min-height: 36px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 8px; }

/* ---------- Badges ---------- */
.badge, .hm-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px !important; border-radius: 999px !important; font-size: var(--fs-xs) !important; font-weight: 500 !important; line-height: 1.7 !important; }
.badge-primary, .badge-info, .hm-badge-primary { background: var(--primary-soft) !important; color: var(--primary) !important; }
.badge-success, .hm-badge-success { background: var(--success-soft) !important; color: var(--success) !important; }
.badge-warning, .hm-badge-warning { background: var(--warning-soft) !important; color: var(--warning) !important; }
.badge-danger, .hm-badge-danger { background: var(--danger-soft) !important; color: var(--danger) !important; }
.badge-secondary, .badge-light, .badge-dark, .hm-badge-neutral { background: var(--background) !important; color: var(--text-secondary) !important; }

/* ---------- Alerts ---------- */
.alert, .hm-alert { display: flex; gap: var(--space-3); align-items: flex-start; border: 1px solid var(--border) !important; border-radius: var(--radius-md) !important; padding: var(--space-3) var(--space-4) !important; font-size: var(--fs-sm); background: var(--surface) !important; color: var(--text-primary) !important; }
.alert-info, .alert-primary, .hm-alert-info { background: var(--primary-soft) !important; border-color: #D5DFF6 !important; }
.alert-success, .hm-alert-success { background: var(--success-soft) !important; border-color: #C5E7D8 !important; }
.alert-warning, .hm-alert-warning { background: var(--warning-soft) !important; border-color: #F3D3AE !important; }
.alert-danger, .hm-alert-danger { background: var(--danger-soft) !important; border-color: #F2C4C6 !important; }
.hm-alert-title { font-weight: 700; display: block; }
.hm-alert a, .alert a { font-weight: 600; text-decoration: underline; color: inherit; }
.hm-alert + * , .alert + * { margin-top: var(--space-4); }
.alert .close { margin-inline-start: auto; }

/* ---------- Empty state ---------- */
.hm-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-8) var(--space-4); color: var(--text-secondary); }
.hm-empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--background); display: grid; place-items: center; color: var(--text-secondary); margin-bottom: var(--space-2); }
.hm-empty-icon svg { width: 26px; height: 26px; }
.hm-empty-title { color: var(--text-primary); font-weight: 700; font-size: var(--fs-md); margin: 0; }
.hm-empty-text { margin: 0; font-size: var(--fs-sm); max-width: 420px; }
.hm-empty .hm-btn, .hm-empty .btn { margin-top: var(--space-3); }
.hm-empty.is-compact { padding: var(--space-6) var(--space-4); }

/* ---------- Lists ---------- */
.hm-list { list-style: none; margin: 0; padding: 0; }
.hm-list-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border); min-height: 56px; }
.hm-list-item:first-child { border-top: 0; }
.hm-list-main { flex: 1; min-width: 0; }
.hm-list-title { font-weight: 600; font-size: var(--fs-md); color: var(--text-primary); margin: 0; }
.hm-list-meta { font-size: var(--fs-xs); color: var(--text-secondary); margin: 2px 0 0; }
.hm-date-chip { flex: 0 0 56px; height: 56px; border-radius: var(--radius-md); background: var(--primary-soft); color: var(--primary); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.hm-date-chip b { font-size: var(--fs-lg); }
.hm-date-chip span { font-size: 11px; }
.hm-status-icon { flex: 0 0 48px; height: 48px; border-radius: var(--radius-md); display: grid; place-items: center; }
.hm-status-icon svg { width: 22px; height: 22px; }
.hm-status-icon.is-success { background: var(--success-soft); color: var(--success); }
.hm-status-icon.is-danger { background: var(--danger-soft); color: var(--danger); }
.hm-status-icon.is-neutral { background: var(--background); color: var(--text-secondary); }
.hm-progress { height: 8px; border-radius: 999px; background: var(--background); overflow: hidden; }
.hm-progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.hm-money { font-size: var(--fs-2xl); font-weight: 700; }
.hm-money small { font-size: var(--fs-sm); color: var(--text-secondary); font-weight: 400; margin-inline-start: 4px; }
.hm-actions-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.hm-actions-row > * { flex: 1 1 140px; }

/* ---------- Tabs ---------- */
.hm-tabs, .nav-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border) !important; margin-bottom: var(--space-4); overflow-x: auto; scrollbar-width: none; }
.hm-tabs a, .hm-tabs button, .nav-tabs .nav-link { min-height: var(--tap); display: inline-flex; align-items: center; padding: 0 var(--space-4) !important; border: 0 !important; border-bottom: 2px solid transparent !important; background: none !important; color: var(--text-secondary) !important; font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; border-radius: 0 !important; }
.hm-tabs .is-active, .hm-tabs [aria-selected=true], .nav-tabs .nav-link.active { color: var(--primary) !important; border-bottom-color: var(--primary) !important; }
.nav-pills .nav-link.active { background: var(--primary) !important; }

/* ---------- Modal ---------- */
.modal-content { border: 0 !important; border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-md) !important; }
.modal-header, .modal-footer { border-color: var(--border) !important; padding: var(--space-4) var(--space-6) !important; }
.modal-body { padding: var(--space-6) !important; }
.modal-title { font-weight: 700; font-size: var(--fs-lg); }
.modal-header .close { margin: -8px auto -8px -8px !important; min-width: var(--tap); min-height: var(--tap); }
.modal-backdrop.show { opacity: .4; }
.swal-modal, .swal2-popup { border-radius: var(--radius-lg) !important; }
.swal-button, .swal2-confirm { background: var(--primary) !important; border-radius: var(--radius-sm) !important; min-height: 40px; }
.swal-title { font-size: var(--fs-lg) !important; }
.swal-text { text-align: center !important; color: var(--text-secondary) !important; }

/* ---------- Toast (جایگزین مودال خوش‌آمد) ---------- */
.hm-toast-wrap { position: fixed; left: 16px; bottom: 16px; z-index: 2100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.hm-toast { display: flex; gap: var(--space-3); align-items: flex-start; background: var(--text-primary); color: #fff; border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-md); font-size: var(--fs-sm); animation: hm-in .2s ease; }
.hm-toast.is-warning { background: #4A2B05; }
.hm-toast.is-error { background: #5B1013; }
.hm-toast b { display: block; }
.hm-toast button { margin-inline-start: auto; background: none; border: 0; color: #fff; opacity: .8; min-width: 32px; min-height: 32px; }
.hm-toast .hm-toast-action { background: #fff; color: var(--text-primary); opacity: 1; border-radius: 6px; padding: 0 12px; font-weight: 600; white-space: nowrap; }
@keyframes hm-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Pagination ---------- */
.pagination { gap: 4px; flex-wrap: wrap; }
.page-link { min-width: 40px; min-height: 40px; display: grid; place-items: center; border-radius: var(--radius-sm) !important; border: 1px solid var(--border) !important; color: var(--text-primary) !important; }
.page-item.active .page-link { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }

/* ---------- Kebab (منوی سه‌نقطه) ---------- */
.hm-kebab { position: relative; display: inline-block; }
.hm-kebab > summary { list-style: none; width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-secondary); }
.hm-kebab > summary::-webkit-details-marker { display: none; }
.hm-kebab > summary:hover { background: var(--background); }
.hm-kebab svg { width: 20px; height: 20px; }
.hm-kebab-menu { position: absolute; left: 0; top: calc(100% + 4px); min-width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 6px; z-index: 50; }
.hm-kebab-menu a, .hm-kebab-menu button { display: flex; width: 100%; align-items: center; min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-sm); background: none; border: 0; color: var(--text-primary); font-size: var(--fs-sm); text-decoration: none !important; text-align: right; }
.hm-kebab-menu a:hover, .hm-kebab-menu button:hover { background: var(--background); }
.hm-kebab-menu .is-danger { color: var(--danger); }

/* ---------- Filters / chips ---------- */
.hm-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-4); }
.hm-toolbar .hm-search { flex: 1 1 260px; }
.hm-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: var(--fs-xs); font-weight: 500; text-decoration: none !important; }
.hm-sheet { position: fixed; inset: auto 0 0 0; z-index: 1080; background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); max-height: 85vh; overflow: auto; box-shadow: 0 -8px 32px rgba(16,24,40,.18); transform: translateY(105%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s; }
.hm-sheet.is-open { transform: none; visibility: visible; transition: transform .2s ease; }
.hm-sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto var(--space-3); }
.hm-sheet-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.4); z-index: 1075; display: none; }
.hm-sheet-backdrop.is-open { display: block; }

/* ---------- Misc legacy cleanups ---------- */
.icon-block, .icon-block-floating { display: none !important; }
#rcorners1 { width: auto !important; height: auto !important; }
hr { border-color: var(--border); }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary, .text-info { color: var(--primary) !important; }
.bg-light { background: var(--background) !important; }
.dropdown-menu { border: 1px solid var(--border) !important; border-radius: var(--radius-md) !important; box-shadow: var(--shadow-md) !important; }
.dropdown-item { min-height: 40px; display: flex; align-items: center; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1199.98px) {
  .hm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hm-grid-main, .hm-grid-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 991.98px) {
  .hm-sidebar { transform: translateX(100%); box-shadow: none; }
  .hm-body.hm-nav-open .hm-sidebar { transform: none; box-shadow: var(--shadow-md); }
  .hm-body.hm-nav-open .hm-backdrop { display: block; position: fixed; inset: 0; background: rgba(16,24,40,.4); z-index: 1035; }
  .hm-body.hm-nav-open { overflow: hidden; }
  .hm-shell { margin-right: 0; }
  .hm-menu-btn { display: inline-grid; }
  .hm-topbar { padding: 0 var(--space-2) 0 var(--space-3); }
  .hm-main, .hm-shell .main-content { padding: var(--space-4) !important; }
  .hm-search { display: none; }
  .hm-user-name { display: none; }
}

@media (max-width: 767.98px) {
  :root { --fs-2xl: 22px; }
  .hm-has-bottomnav .hm-main { padding-bottom: calc(var(--bottomnav-h) + var(--space-6) + env(safe-area-inset-bottom)) !important; }
  .hm-bottomnav { display: flex; position: fixed; inset: auto 0 0 0; z-index: 1030; height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
  .hm-bottomnav a, .hm-bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; color: var(--text-secondary); text-decoration: none !important; background: none; border: 0; min-height: var(--tap); position: relative; }
  .hm-bottomnav svg { width: 22px; height: 22px; }
  .hm-bottomnav .is-active { color: var(--primary); font-weight: 600; }
  .hm-bottomnav .hm-dot { top: 4px; left: calc(50% - 22px); }
  .hm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .hm-stat { padding: var(--space-3) var(--space-4); }
  .hm-stat-value { font-size: 24px; }
  .hm-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .card-body, .hm-card-body { padding: var(--space-4) !important; }
  .card-header, .card-footer { padding: var(--space-3) var(--space-4) !important; }
  .hm-page-header { margin-bottom: var(--space-4); }
  .hm-page-header .hm-page-actions { width: 100%; }
  .hm-page-header .hm-page-actions > * { flex: 1; }
  .hm-fieldset { padding: var(--space-3) var(--space-4) var(--space-1); }
  .hm-hide-mobile { display: none !important; }
  /* بازنویسی ستون‌های بوت‌استرپ دسکتاپ که بدون col-12 تعریف شده‌اند */
  .row > [class*="col-lg-"]:not([class*="col-sm-"]):not([class*="col-md-"]):not([class*="col-"][class*="col-6"]) { flex: 0 0 100%; max-width: 100%; }
  .form-inline { flex-direction: column; align-items: stretch !important; }
  .form-inline .form-control, .form-inline .btn, .form-inline select { width: 100% !important; margin: 0 0 var(--space-2) !important; }
  .btn { min-height: var(--tap); }
  .table .btn { min-height: 36px; }
  .modal-dialog { margin: var(--space-2); }
  .hm-sheet-trigger { display: inline-flex !important; }
  .hm-filters-inline { display: none !important; }
  .hm-toast-wrap { left: 12px; right: 12px; bottom: calc(var(--bottomnav-h) + 12px); max-width: none; }

  /* جدول به کارت روی موبایل */
  table.hm-stack-table, table.hm-stack-table tbody, table.hm-stack-table tr, table.hm-stack-table td { display: block; width: 100% !important; }
  table.hm-stack-table { background: transparent; border: 0 !important; }
  table.hm-stack-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.hm-stack-table tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: var(--space-3); padding: var(--space-2) var(--space-4); }
  table.hm-stack-table td { border: 0 !important; border-top: 1px solid var(--border) !important; padding: 8px 0 !important; display: flex; justify-content: space-between; gap: var(--space-4); text-align: left !important; min-height: 40px; align-items: center; }
  table.hm-stack-table td:first-child { border-top: 0 !important; }
  table.hm-stack-table td::before { content: attr(data-label); color: var(--text-secondary); font-size: var(--fs-xs); text-align: right; flex: 0 0 auto; max-width: 45%; }
  table.hm-stack-table td[data-label=""]::before { display: none; }
  table.hm-stack-table td { flex-wrap: wrap; overflow-wrap: anywhere; }
  table.hm-stack-table td > * { max-width: 100%; min-width: 0; }
  table.hm-stack-table td .btn, table.hm-stack-table td .badge { white-space: normal; }
  table.hm-stack-table tr.hm-table-empty td { display: block; }
  table.hm-stack-table tr.hm-table-empty td::before { display: none; }
  .table-responsive:has(> table.hm-stack-table) { overflow: visible; }
}
@media (min-width: 768px) { .hm-sheet-trigger { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .hm-sidebar, .hm-topbar, .hm-bottomnav, .hm-toast-wrap, .noprint { display: none !important; }
  .hm-shell { margin: 0; }
  body { background: #fff !important; }
}

/* ---------- Online class cards ---------- */
.hm-online-card + .hm-online-card { margin-top: var(--space-3); }
.hm-online-card .hm-card-title { font-size: var(--fs-md) !important; margin-bottom: 2px !important; }
.hm-online-meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-3); color: var(--text-secondary); font-size: var(--fs-sm); }
.hm-online-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hm-online-meta svg { width: 16px; height: 16px; }
.hm-online-desc { margin-top: var(--space-3); font-size: var(--fs-sm); }
.hm-online-desc summary { cursor: pointer; color: var(--primary); min-height: 32px; }

/* ---------- Grade sheet ---------- */
.hm-mark-table .hm-mark-input { width: 96px; margin: 0 auto; text-align: center; direction: ltr; }
.hm-mark-table select.hm-mark-input { width: 150px; direction: rtl; }
.hm-mark-table .hm-mark-input.is-changed { border-color: var(--warning) !important; background: var(--warning-soft) !important; }
.hm-mark-table .hm-mark-input:invalid { border-color: var(--danger) !important; }
.hm-mark-student { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; white-space: nowrap; }
.hm-mark-table thead th:first-child, .hm-mark-table tbody th { position: sticky; right: 0; z-index: 1; }
.hm-mark-table tbody th, .hm-mark-table tbody tr:nth-of-type(odd) th { background: var(--surface) !important; border-top: 1px solid var(--border); vertical-align: middle; font-weight: 600; }
.hm-avatar-sm { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; font-size: var(--fs-sm); overflow: hidden; flex: 0 0 auto; }
.hm-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.hm-savebar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: 0 -4px 16px rgba(16,24,40,.06); }
@media (max-width: 767.98px) {
  body.hm-has-bottomnav .hm-savebar { bottom: calc(var(--bottomnav-h) + 8px); }
  .hm-savebar { padding: var(--space-2) var(--space-3); }
  .hm-savebar-note { display: none; }
  .hm-savebar > div { flex: 1; }
  .hm-savebar > div > .hm-btn, .hm-savebar > div > .btn { flex: 1; justify-content: center; }
  table.hm-stack-table tbody th[scope=row] { display: block; width: 100%; padding: 8px 0 !important; border: 0 !important; position: static; }
  table.hm-stack-table .hm-mark-input { width: 120px; margin: 0; }
}

/* ---------- Legacy widgets that force width ---------- */
.hm-main .multi-select-full, .hm-main .multi-select-full .btn-group, .hm-main .multiselect, .hm-main .select2-container { max-width: 100% !important; min-width: 0; }
.hm-main .multiselect { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-main .row > [class*="col-"] { min-width: 0; }

/* ---------- Form sections (admin CRUD) ---------- */
.hm-form-main > .hm-form-section + .hm-form-section { margin-top: var(--space-4); }
.hm-form-section-title { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-md) !important; font-weight: 700; margin: 0 0 var(--space-4) !important; }
.hm-form-section-title > span { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; font-size: var(--fs-sm); }
.hm-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); }
.hm-form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hm-readonly { min-height: var(--tap); display: flex; align-items: center; padding: 0 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--text-secondary); background: var(--background); }
.hm-avatar-lg { width: 56px; height: 56px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; font-size: var(--fs-lg); font-weight: 700; overflow: hidden; flex: 0 0 auto; }
.hm-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 767.98px) { .hm-form-grid, .hm-form-grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Confirm dialog ---------- */
.hm-dialog-backdrop { position: fixed; inset: 0; z-index: 2000; background: rgba(16,24,40,.45); display: grid; place-items: center; padding: var(--space-4); }
.hm-dialog { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-6); width: min(420px, 100%); box-shadow: 0 20px 48px rgba(16,24,40,.24); }
.hm-dialog-title { font-size: var(--fs-lg) !important; margin: 0 0 var(--space-2) !important; }
.hm-dialog p { color: var(--text-secondary); margin: 0 0 var(--space-6); }
.hm-dialog-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.hm-btn-danger, .btn.hm-btn-danger { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff !important; }
.hm-btn-danger:hover { filter: brightness(.92); }
button[aria-busy="true"] { opacity: .75; cursor: progress; }

/* ---------- Phase 6: filters, choice chips, segmented mode ---------- */
.hm-table tr[hidden], [data-hm-filter-item][hidden], .hm-filter-empty[hidden] { display: none !important; }
.hm-segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-md); flex-wrap: wrap; }
.hm-segmented label { margin: 0; cursor: pointer; }
.hm-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.hm-segmented span { display: block; padding: 8px 14px; border-radius: calc(var(--radius-md) - 4px); font-size: var(--fs-sm); color: var(--text-secondary); min-height: 40px; line-height: 24px; }
.hm-segmented input:checked + span { background: var(--surface); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 3px rgba(16,24,40,.1); }
.hm-segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.hm-choices { display: flex; flex-wrap: wrap; gap: var(--space-2); border: 0; padding: 0; margin: 0; min-width: 0; }
.hm-choices legend { font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--space-2); float: none; width: auto; }
.hm-choice { position: relative; margin: 0; }
.hm-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.hm-choice span { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: var(--fs-sm); color: var(--text-primary); }
.hm-choice input:checked + span { border-color: var(--primary); background: var(--primary-soft, #EEF2FF); color: var(--primary); font-weight: 600; }
.hm-choice input:checked + span::before { content: "✓"; font-weight: 700; }
.hm-choice input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.hm-choice[hidden] { display: none; }
.hm-choices-empty { font-size: var(--fs-sm); color: var(--text-secondary); }
.hm-choices.is-invalid .hm-choice span { border-color: var(--danger); }

/* ---------- Teacher roll call ---------- */
.hm-seg-link { display: block; padding: 8px 14px; min-height: 40px; line-height: 24px; border-radius: calc(var(--radius-md) - 4px); font-size: var(--fs-sm); color: var(--text-secondary); text-decoration: none !important; }
.hm-seg-link.is-active { background: var(--surface); color: var(--text-primary); font-weight: 600; box-shadow: 0 1px 3px rgba(16,24,40,.1); }
.hm-rc-summary { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-3); font-size: var(--fs-sm); color: var(--text-secondary); }
.hm-rc-count { display: inline-flex; align-items: baseline; gap: 4px; padding: 6px 12px; border-radius: 999px; background: var(--success-soft); color: var(--success); font-weight: 600; }
.hm-rc-count b { font-size: 1.15em; }
.hm-rc-count.is-absent { background: var(--danger-soft); color: var(--danger); }
.hm-rc-summary .mr-auto { margin-right: auto !important; }
.hm-rc-item { gap: var(--space-3); align-items: center; padding-inline: var(--space-2); }
.hm-rc-item .hm-list-main { min-width: 0; flex: 1; }
.hm-rc-item .hm-list-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-rc-item.is-absent { background: var(--danger-soft); border-radius: var(--radius-md); }
.hm-rc-toggle { display: inline-flex; flex-shrink: 0; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.hm-rc-toggle label { margin: 0; position: relative; cursor: pointer; }
.hm-rc-toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.hm-rc-toggle span { display: block; min-width: 64px; padding: 10px 12px; min-height: 44px; line-height: 24px; text-align: center; font-size: var(--fs-sm); color: var(--text-secondary); }
.hm-rc-toggle label + label span { border-right: 1px solid var(--border); }
.hm-rc-toggle .is-present input:checked + span { background: var(--success); color: #fff; font-weight: 600; }
.hm-rc-toggle .is-absent input:checked + span { background: var(--danger); color: #fff; font-weight: 600; }
.hm-rc-toggle input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -3px; }
@media (max-width: 400px) { .hm-rc-item > .hm-avatar { display: none; } }
.hm-dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: 0; font-size: var(--fs-sm); }
.hm-dl dt { color: var(--text-secondary); font-weight: 400; }
.hm-dl dd { margin: 0; color: var(--text-primary); }
select[size].hm-input { height: auto; padding: 4px; }
select[size].hm-input option { padding: 8px 10px; border-radius: 6px; }
select[size].hm-input optgroup { font-style: normal; color: var(--text-secondary); }
.hm-form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1199.98px) { .hm-form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .hm-form-grid-4 { grid-template-columns: minmax(0, 1fr); } }
.hm-filter-panel > .hm-filter-summary { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); min-height: var(--tap); cursor: pointer; font-weight: 600; font-size: var(--fs-sm); list-style: none; }
.hm-filter-panel > .hm-filter-summary::-webkit-details-marker { display: none; }
.hm-filter-panel > .hm-filter-summary svg { width: 18px; height: 18px; }
.hm-filter-panel > .hm-filter-summary::after { content: "▾"; margin-right: auto; color: var(--text-secondary); }
.hm-filter-panel[open] > .hm-filter-summary::after { content: "▴"; }
.hm-field .select2-container { width: 100% !important; }
.hm-field .select2-container .select2-selection--single { height: var(--tap) !important; min-height: var(--tap); padding: 0 var(--space-3); display: flex; align-items: center; }
.hm-field .select2-container .select2-selection--single .select2-selection__rendered { line-height: normal; padding: 0; }
.hm-field .select2-container .select2-selection--single .select2-selection__arrow { height: 100%; }

/* ---------- Native charts (replaces FusionCharts) ---------- */
.hm-chart { margin: 0; width: 100%; }
.hm-chart-title { font-weight: 600; font-size: var(--fs-md); margin-bottom: var(--space-3); color: var(--text-primary); }
.hm-chart-unit { color: var(--text-secondary); font-weight: 400; font-size: var(--fs-sm); }
.hm-chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); list-style: none; padding: 0; margin: 0 0 var(--space-3); font-size: var(--fs-sm); color: var(--text-secondary); }
.hm-chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.hm-chart-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.hm-chart-rows { display: grid; gap: var(--space-2); }
.hm-chart-row { display: grid; grid-template-columns: minmax(72px, 160px) 1fr; gap: var(--space-3); align-items: center; }
.hm-chart-label { font-size: var(--fs-sm); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-chart-bars { display: grid; gap: 2px; min-width: 0; }
.hm-chart-bar { display: flex; align-items: center; gap: var(--space-2); min-height: 18px; }
.hm-chart-fill { display: block; height: 14px; min-width: 2px; border-radius: 4px 0 0 4px; }
.hm-chart-value { font-size: var(--fs-xs, 12px); color: var(--text-primary); white-space: nowrap; }
.hm-chart-bar:hover .hm-chart-fill { filter: brightness(.9); }
.hm-chart-table { margin-top: var(--space-4); font-size: var(--fs-sm); }
.hm-chart-table summary { cursor: pointer; color: var(--primary); min-height: var(--tap); display: inline-flex; align-items: center; }
@media (max-width: 575.98px) { .hm-chart-row { grid-template-columns: 1fr; gap: 2px; } }
@media (forced-colors: active) { .hm-chart-fill { forced-color-adjust: none; border: 1px solid CanvasText; } }
/* نمودارهای قدیمی داخل .row با margin منفی و overflow جدول بریده می‌شدند */
.row:has(> .panel-body > .hm-chart), .row:has(> .col > .hm-chart) { margin-inline: 0; }
.panel-body > .hm-chart { min-width: 0; }
.hm-nav-sub { display: block; }
.row:has(> .panel-body > .hm-chart) > .panel-body { flex: 1 1 100%; min-width: 0; }
/* کارت تودرتوی قالب‌های قدیمی نمودار: کارت داخلی هموار می‌شود */
.card-body .card:has(.hm-chart) { border: 0; box-shadow: none; background: transparent; margin: 0; }
.card-body .card:has(.hm-chart) > .card-body { padding: 0; }
/* فهرست غیبت‌ها (مدیر): هر دانش‌آموز یک details */
.hm-absence > details > summary { list-style: none; cursor: pointer; }
.hm-absence > details > summary::-webkit-details-marker { display: none; }
.hm-absence > details > summary::after { content: ""; width: 8px; height: 8px; border-left: 2px solid var(--text-secondary); border-bottom: 2px solid var(--text-secondary); transform: rotate(45deg); margin-inline: var(--space-2); transition: transform .15s; flex: 0 0 8px; }
.hm-absence > details[open] > summary::after { transform: rotate(-45deg); }
.hm-absence + .hm-absence > details > summary { border-top: 1px solid var(--border); }
.hm-absence > details > summary.hm-list-item { border-top: 0; }
.hm-absence > details > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm, 6px); }
.hm-absence-rows { list-style: none; margin: 0 0 var(--space-3); padding: 0; background: var(--surface-2); border-radius: var(--radius-md, 10px); }
.hm-absence-rows > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); padding: var(--space-3); }
.hm-absence-rows > li + li { border-top: 1px solid var(--border); }
.hm-absence-when { display: grid; gap: 2px; min-width: 0; }
.hm-absence-note { margin: var(--space-1, 4px) 0 0; font-size: var(--fs-sm); }
.hm-absence-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.hm-btn-ghost.is-danger { color: var(--danger) !important; }
/* نسخه پیوندی تاگل حضور (مدیر: هر تغییر بلافاصله ذخیره می‌شود) */
.hm-rc-toggle > a, .hm-rc-toggle > b { display: block; margin: 0; font-weight: inherit; text-decoration: none; }
.hm-rc-toggle > a + b span, .hm-rc-toggle > b + a span { border-right: 1px solid var(--border); }
.hm-rc-toggle > .is-present.is-on span { background: var(--success); color: #fff; font-weight: 600; }
.hm-rc-toggle > .is-absent.is-on span { background: var(--danger); color: #fff; font-weight: 600; }
.hm-rc-toggle > a:hover span { background: var(--surface-2); color: var(--text-primary); }
.hm-rc-toggle > a:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; }
/* کلید روشن/خاموش */
.hm-switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; min-height: var(--tap); margin: 0; position: relative; }
.hm-switch input { position: absolute; opacity: 0; width: 44px; height: 24px; margin: 0; cursor: pointer; }
.hm-switch input + span { width: 44px; height: 24px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; flex: 0 0 44px; }
.hm-switch input + span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: inset-inline-start .15s; }
.hm-switch input:checked + span { background: var(--primary); }
.hm-switch input:checked + span::after { inset-inline-start: 23px; }
.hm-switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (forced-colors: active) { .hm-switch input + span { border: 1px solid CanvasText; } }
/* مرکز گزارش‌ها */
.hm-section-title { font-size: var(--fs-md); font-weight: 700; margin: 0 0 var(--space-3); color: var(--text-primary); }
.hm-report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); }
.hm-report-card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); color: var(--text-primary); text-decoration: none; margin: 0; }
.hm-report-card .form-group { margin-bottom: 0; }
.hm-report-card > .hm-btn { margin-top: auto; align-self: flex-start; }
a.hm-report-card:hover { border-color: var(--primary); text-decoration: none; color: var(--text-primary); }
a.hm-report-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.hm-report-icon { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
/* فهرست مشخصات افقی (کارنامه) */
.hm-dl-inline { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-6); }
.hm-dl-inline > div { display: grid; gap: 2px; }
@media print { .d-print-flex { display: flex !important; } .hm-sidebar, .hm-topbar, .hm-bottomnav { display: none !important; } }
/* سرستون سبز قالب قدیمی (excel/component.css) کنتراست ۲٫۴ داشت */
body table th { background-color: var(--surface-2); color: var(--text-secondary); }

/* تبلت (۷۶۸ تا ۱۱۹۹): جدول پهن داخل کادر خودش اسکرول می‌شود؛ زیر ۷۶۸ جدول کارت می‌شود و بالای ۱۲۰۰ جا دارد */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .hm-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
}
.hm-main .row > .col-md-12 { min-width: 0; }
/* multiselect قدیمی خارج از .multi-select-full: دکمه از ستون خود پهن‌تر نشود */
.hm-main .btn-group:has(> .multiselect) { display: flex; max-width: 100%; min-width: 0; }
.hm-main .btn-group > .multiselect { flex: 1 1 auto; min-width: 0; }
.hm-main .multiselect { direction: rtl; text-align: right; }
.hm-main .multiselect { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.hm-main .multiselect .multiselect-selected-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }

/* ---------- فاز ۷: انتخاب فرزند (پنل والد) ---------- */
.hm-child { position: relative; }
.hm-child > summary, .hm-child.is-single { list-style: none; display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-primary); }
.hm-child > summary { cursor: pointer; }
.hm-child > summary::-webkit-details-marker { display: none; }
.hm-child > summary:hover { border-color: var(--primary); }
.hm-child > summary:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 3px rgba(36,70,168,.35)); }
.hm-child .hm-avatar { width: 28px; height: 28px; font-size: 13px; }
.hm-child-name { font-size: var(--fs-sm); font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-child-caret { color: var(--text-secondary); transition: transform .15s; }
.hm-child[open] .hm-child-caret { transform: rotate(180deg); }
.hm-child-menu { position: absolute; left: 0; top: calc(100% + 6px); min-width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: var(--space-2); z-index: 1060; }
.hm-child-head { margin: 0; padding: var(--space-2) var(--space-3); font-size: var(--fs-xs, 12px); color: var(--text-secondary); }
.hm-child-menu form { margin: 0; }
.hm-child-opt { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 56px; padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-primary); text-align: right; font: inherit; cursor: pointer; }
.hm-child-opt:hover, .hm-child-opt:focus-visible { background: var(--background); outline: none; }
.hm-child-opt[aria-current="true"] { background: var(--primary-soft, #EEF2FC); }
.hm-child-opt .hm-avatar { width: 36px; height: 36px; flex: none; }
.hm-child-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hm-child-meta b { font-size: var(--fs-sm); font-weight: 600; }
.hm-child-meta small { color: var(--text-secondary); font-size: 12px; }
.hm-child-check { color: var(--primary); display: inline-flex; }
@media (max-width: 600px) {
  .hm-child-name { max-width: 84px; }
  .hm-child > summary, .hm-child.is-single { padding: 0 var(--space-2); }
  /* backdrop-filter نوار بالا برای position:fixed بلوک دربرگیرنده می‌سازد؛ هنگام باز بودن برگه حذفش می‌کنیم */
  .hm-topbar:has(.hm-child[open]) { backdrop-filter: none; background: var(--surface); z-index: 1070; }
  .hm-child[open]::before { content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1059; }
  .hm-child-menu { position: fixed; left: 0; right: 0; bottom: 0; top: auto; min-width: 0; border-radius: 16px 16px 0 0; padding: var(--space-3) var(--space-3) calc(var(--space-4) + env(safe-area-inset-bottom)); max-height: 70vh; overflow-y: auto; }
}
@media (max-width: 380px) { .hm-child-name { display: none; } }

/* ---------- فاز ۷: پوسته Platform Admin ---------- */
.hm-user-menu-btn { display: flex; align-items: center; width: 100%; min-height: 40px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; font: inherit; font-size: var(--fs-sm); color: var(--text-primary); cursor: pointer; text-align: right; }
.hm-user-menu-btn:hover { background: var(--background); }
.hm-user-menu-btn.is-danger { color: var(--danger); }
.hm-kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
.hm-kv dt { color: var(--text-secondary); font-weight: 400; font-size: var(--fs-sm); }
.hm-kv dd { margin: 0; font-size: var(--fs-sm); }
.hm-module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-2); }
.hm-module-grid label { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 0; cursor: pointer; }
.hm-module-grid input { width: 18px; height: 18px; accent-color: var(--primary); }
.hm-activity { list-style: none; margin: 0; padding: 0; }
.hm-activity li { display: flex; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.hm-activity li:first-child { border-top: 0; }
.hm-activity time { color: var(--text-secondary); white-space: nowrap; margin-inline-start: auto; font-size: var(--fs-xs); }
.hm-locked { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--background); }
@media (max-width: 600px) { .hm-kv { grid-template-columns: 1fr; gap: 2px; } .hm-kv dd { margin-bottom: var(--space-2); } .hm-activity li { flex-wrap: wrap; } }
.hm-role-platform .hm-nav-link svg { width: 20px; height: 20px; flex: none; }
/* فاز ۷: کنتراست دکمه خطر روی پس‌زمینه صفحه (axe: 4.26 → بالای 4.5) */
.hm-main .btn-outline-danger:not(:hover):not(:focus) { color: #B8073F; border-color: #B8073F; }
