/* Dar Al Maghrib — RTL-first styles. Logical properties (inline-start/end) keep LTR working too. */

:root {
  /* Brand colours taken from the Dar Al Maghrib logo */
  --primary: #12375e;        /* navy: circle, calligraphy, book */
  --primary-dark: #0b2540;
  --primary-soft: #e9eff6;
  --gold: #f2ae1e;           /* gold: the heart */
  --gold-dark: #c98a0c;
  --gold-soft: #fef5e0;
  --accent: #e8821a;         /* orange: the word "ملازم" (warnings) */
  --accent-soft: #fdf0e1;
  --warning-text: #9a4a07;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --success: #067647;
  --success-soft: #e7f6ee;
  --text: #1d2939;
  --muted: #667085;
  --border: #e4e7ec;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.3; margin: 0 0 0.4em; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
a { color: var(--primary); }
button { font: inherit; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: 16px; }
.page { padding-block: 28px 48px; }
.muted { color: var(--muted); margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.65rem 1.2rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; padding: 8px; cursor: pointer; border-radius: var(--radius-sm); }

/* ---------- Top bar ---------- */
.topbar { background: var(--surface); border-block-end: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.1rem; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #1e4f80);
  color: #fff; font-weight: 700;
}
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.6rem; }

.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a {
  padding: 0.45rem 0.85rem; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.main-nav a:hover { background: var(--bg); color: var(--text); }
.main-nav a.active { background: var(--primary-soft); color: var(--primary); }

.topbar-actions { display: flex; align-items: center; gap: 12px; margin-inline-start: auto; }

.lang-switch { margin: 0; }
.lang-switch button {
  background: none; border: 1px solid var(--border); border-radius: 999px;
  padding: 0.3rem 0.85rem; cursor: pointer; color: var(--text); font-size: 0.85rem;
}
.lang-switch button:hover { border-color: var(--primary); color: var(--primary); }

.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 4px; cursor: pointer; text-align: start; color: var(--text);
}
.avatar {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); }
.dropdown {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px);
  min-width: 180px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.dropdown form { margin: 0; }
.dropdown-item {
  display: block; width: 100%; padding: 0.55rem 0.75rem;
  background: none; border: 0; border-radius: 6px; text-align: start; cursor: pointer; color: var(--text);
}
.dropdown-item:hover { background: var(--bg); }

.nav-toggle { display: none; }
.nav-toggle span { display: block; width: 22px; height: 2px; margin: 4px 0; background: var(--text); }

/* Six manager links plus bell, language and user chip need ~1100px; collapse the menu below that. */
@media (max-width: 1100px) {
  .topbar-inner { gap: 12px; }
  .nav-toggle { display: block; order: -1; }
  .main-nav {
    display: none; position: absolute; top: 64px; inset-inline: 0;
    flex-direction: column; padding: 12px 16px;
    background: var(--surface); border-block-end: 1px solid var(--border); box-shadow: var(--shadow-lg);
  }
  .main-nav.open { display: flex; }
  .user-meta { display: none; }
}

/* ---------- Alerts ---------- */
.messages { padding-block-start: 16px; }
.alert { padding: 0.8rem 1rem; border-radius: var(--radius-sm); margin-block-end: 8px; transition: opacity 0.3s; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--accent-soft); color: var(--warning-text); }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); }
.alert.fade { opacity: 0; }

/* ---------- Page structure ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-block-end: 24px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-block-end: 20px;
}
.card-title { margin-block-end: 16px; }
.notice { background: var(--primary-soft); border-color: transparent; color: var(--primary-dark); box-shadow: none; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-block-end: 24px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(6, 1fr); } }
.stat {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.45rem; font-weight: 700; }
.stat-value small { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.stat-accent { background: var(--primary); border-color: var(--primary); }
.stat-accent .stat-label, .stat-accent .stat-value, .stat-accent .stat-value small { color: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.75rem 0.9rem; text-align: start; border-block-end: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; background: #fafbfc; }
.table tbody tr:hover { background: #fafbfc; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
.form .field { margin-block-end: 16px; }
.form label { display: block; margin-block-end: 6px; font-weight: 500; }
.form input, .form select, .form textarea {
  width: 100%; padding: 0.65rem 0.8rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; color: var(--text); background: var(--surface);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.form .has-error input { border-color: var(--danger); }
.field-error { margin: 6px 0 0; color: var(--danger); font-size: 0.875rem; }

/* ---------- Login ---------- */
.auth-page { background: radial-gradient(circle at 15% 0%, #dbe5f1, transparent 45%), radial-gradient(circle at 90% 100%, #fde9b8, transparent 42%), var(--bg); }
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-top { position: absolute; top: 16px; inset-inline-end: 16px; }
.auth-card {
  width: 100%; max-width: 400px; padding: 32px 28px;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
}
.auth-brand { text-align: center; margin-block-end: 24px; }
.auth-brand h1 { margin-block: 14px 4px; }
.auth-brand p { margin: 0; color: var(--muted); }

/* ---------- Empty / error states ---------- */
.empty-state { text-align: center; max-width: 440px; margin: 64px auto; }
.empty-icon {
  display: inline-grid; place-items: center; width: 88px; height: 88px; margin-block-end: 16px;
  border-radius: 50%; background: var(--danger-soft); color: var(--danger); font-size: 1.5rem; font-weight: 700;
}
.empty-state p { color: var(--muted); margin-block-end: 24px; }

/* ---------- Shared helpers ---------- */
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.strong { font-weight: 700; }
.text-primary { color: var(--primary); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.badge {
  display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; line-height: 1.6; vertical-align: middle;
}
.badge-muted { background: #f2f4f7; color: var(--muted); }
.badge-warning { background: var(--accent-soft); color: #b45f06; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Card with full-bleed table ---------- */
.card-flush { padding: 0; overflow: hidden; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-block-end: 1px solid var(--border);
}
.search-form { display: flex; gap: 8px; flex: 1 1 260px; min-width: 0; max-width: 520px; }
.search-form input {
  flex: 1; min-width: 0; width: 100%; padding: 0.6rem 0.85rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit;
}
.search-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.table-note { padding: 12px 20px; font-size: 0.85rem; border-block-start: 1px solid var(--border); }
.empty-inline { padding: 40px 20px; text-align: center; color: var(--muted); margin: 0; }

/* ---------- Professors table ---------- */
.th-hint { display: block; font-weight: 400; font-size: 0.72rem; color: var(--muted); }
.professors-table > tbody > .prof-row > td { vertical-align: middle; }
.professors-table tfoot td {
  font-weight: 700; background: #fafbfc; border-block-start: 2px solid var(--border);
  padding: 0.85rem 0.9rem; white-space: nowrap;
}
.prof-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.col-toggle { width: 44px; padding-inline-end: 0 !important; }
.row-toggle {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer;
}
.row-toggle:hover { border-color: var(--primary); }
.chevron {
  width: 8px; height: 8px; border-inline-end: 2px solid var(--muted); border-block-end: 2px solid var(--muted);
  transform: rotate(45deg); margin-block-start: -3px; transition: transform 0.15s;
}
.row-toggle[aria-expanded="true"] { background: var(--primary-soft); border-color: var(--primary-soft); }
.row-toggle[aria-expanded="true"] .chevron { transform: rotate(225deg); margin-block-start: 3px; border-color: var(--primary); }
.prof-row.is-open > td { background: #f7f9fc; border-block-end-color: transparent; }
.is-inactive > td:not(.col-toggle) { color: var(--muted); }

.detail-row > td { padding: 0 16px 16px; background: #f7f9fc; white-space: normal; }
.table-inner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.table-inner th { background: #eef2f8; }
.table-inner tr:last-child td { border-block-end: 0; }
.inner-empty { padding: 12px 4px 0; }
.prof-row { cursor: pointer; }

/* ---------- Phase 3: forms, detail page, confirm ---------- */
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; }
.btn-danger-ghost { background: var(--surface); color: var(--danger); border-color: #f4c7c3; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.col-actions { text-align: end; white-space: nowrap; }
.col-actions .btn + .btn { margin-inline-start: 4px; }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-block-end: 8px; font-size: 0.875rem; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs a::after { content: "/"; margin-inline-start: 6px; color: var(--border); }

.title-with-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.title-with-badges .badge { font-size: 0.8rem; }
.notes { white-space: normal; color: var(--muted); }
.toolbar-title { margin: 0; font-size: 1.1rem; }
.prof-link { color: inherit; text-decoration: none; }
.prof-link:hover { color: var(--primary); text-decoration: underline; }

.form-card { max-width: 760px; padding: 24px; }
.form-section {
  font-size: 1rem; margin-block: 24px 14px; padding-block-start: 20px; border-block-start: 1px solid var(--border);
}
.form-section:first-of-type { margin-block-start: 0; padding-block-start: 0; border-block-start: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form .req { color: var(--danger); margin-inline-start: 3px; }
.form .help { margin: 6px 0 0; color: var(--muted); font-size: 0.82rem; }
.form .has-error input, .form .has-error textarea, .form .has-error select { border-color: var(--danger); }
.form .field-check .check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; margin: 0; }
.form .field-check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block-start: 24px; }

.split-preview {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-block: 0 16px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--primary-soft);
}
.split-title { grid-column: 1 / -1; margin: 0; color: var(--primary-dark); font-size: 0.85rem; font-weight: 600; }
.split-part { display: flex; flex-direction: column; }
.split-part span { color: var(--muted); font-size: 0.82rem; }
.split-part strong { font-size: 1.25rem; color: var(--primary-dark); }
.split-part small { color: var(--text); }

.confirm-card { max-width: 560px; margin: 32px auto; padding: 28px; }
.confirm-card h1 { font-size: 1.3rem; }
.confirm-card p { color: var(--muted); }

@media (max-width: 420px) {
  .brand-name { display: none; }
  .topbar-inner, .topbar-actions { gap: 8px; }
}

/* ---------- Phase 4: sales ---------- */
.nowrap { white-space: nowrap; }
.small { font-size: 0.82rem; }
.sale-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-block-end: 4px; }
@media (max-width: 860px) { .sale-layout { grid-template-columns: 1fr; } }
.sale-form { padding: 24px; }
.booklet-filter {
  width: 100%; margin-block-end: 8px; padding: 0.55rem 0.8rem;
  border: 1px dashed var(--border); border-radius: var(--radius-sm); font: inherit; background: #fafbfc;
}
.booklet-filter:focus { outline: none; border-style: solid; border-color: var(--primary); }

.sale-preview { margin-block: 4px 18px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--primary-soft); }
.preview-row { display: flex; justify-content: space-between; gap: 12px; padding-block: 4px; }
.preview-row span { color: var(--muted); }
.preview-row small { color: var(--muted); }
.preview-total { border-block: 1px solid rgba(18, 55, 94, 0.15); padding-block: 8px; margin-block: 4px; }
.preview-total strong { font-size: 1.35rem; color: var(--primary-dark); }
.preview-warning { margin: 6px 0 0; color: var(--danger); font-weight: 600; }
.sale-preview.is-short { background: var(--danger-soft); }
.btn:disabled { opacity: 0.6; cursor: wait; }

.today-card { padding: 24px; }
.today-list { margin: 0; display: grid; gap: 10px; }
.today-list div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-block: 8px; border-block-end: 1px solid var(--border); }
.today-list div:last-child { border-block-end: 0; }
.today-list dt { color: var(--muted); }
.today-list dd { margin: 0; font-weight: 700; font-size: 1.15rem; }
.today-list dd small { font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.today-accent dd { color: var(--primary); }

.sales-table .is-cancelled td { color: var(--muted); }
.sales-table .is-cancelled .amount { text-decoration: line-through; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; border-block-start: 1px solid var(--border); }

.detail-list { margin: 16px 0; display: grid; gap: 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 16px; padding-block: 8px; border-block-end: 1px solid var(--border); }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 600; }

/* ---------- Phase 5: accounts ---------- */
.period-filter { display: flex; flex-direction: column; gap: 16px; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--bg); border-radius: 10px; align-self: flex-start; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span { display: block; padding: 0.45rem 1rem; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.segment input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.segment input:focus-visible + span { outline: 2px solid var(--primary); }
.period-inputs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.period-input { display: flex; flex-direction: column; gap: 4px; }
.period-input label { font-size: 0.85rem; color: var(--muted); }
.period-input input {
  padding: 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; min-width: 160px;
}
.period-input input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.filter-errors { margin: 0; }


.stats-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) { .stats-4 { grid-template-columns: repeat(4, 1fr); } }

.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-block-end: 8px; }
.card-head .card-title { margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.85rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.swatch-shop, .bar-shop { background: var(--primary); fill: var(--primary); }
.swatch-prof, .bar-prof { background: var(--gold); fill: var(--gold); }

.chart { width: 100%; overflow-x: auto; }
.chart-svg { width: 100%; min-width: 560px; height: auto; display: block; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.bar-hit { fill: transparent; }
.bar:hover .bar-hit, .bar:focus .bar-hit { fill: rgba(18, 55, 94, 0.06); }
.bar:focus { outline: none; }
.chart-readout { min-height: 1.6em; margin: 8px 0 0; font-size: 0.875rem; }

.top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .top-grid { grid-template-columns: 1fr; } }
.rank-list { list-style: none; margin: 0; padding: 8px 0; }
.rank-list li { display: flex; gap: 14px; align-items: flex-start; padding: 12px 20px; }
.rank-list li + li { border-block-start: 1px solid var(--border); }
.rank {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 0.85rem;
}
.rank-list li:first-child .rank { background: var(--primary); color: #fff; }
.rank-body { flex: 1; min-width: 0; }
.rank-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rank-value { font-weight: 700; white-space: nowrap; }
.rank-bar { height: 6px; margin-block-start: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }


/* ---------- Phase 6: settlements ---------- */
.stats-3 { grid-template-columns: 1fr; }
@media (min-width: 640px) { .stats-3 { grid-template-columns: repeat(3, 1fr); } }
.stat-warning { background: var(--accent-soft); border-color: #f8d5ae; }
.stat-warning .stat-label, .stat-warning .stat-value, .stat-warning .stat-value small { color: var(--warning-text); }
.stat-success { background: var(--success-soft); border-color: #b7e4cb; }
.stat-success .stat-label, .stat-success .stat-value, .stat-success .stat-value small { color: var(--success); }
.text-warning { color: #b45f06; }

.segmented-sm { padding: 3px; }
.segment-link { display: block; padding: 0.35rem 0.85rem; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: 0.875rem; font-weight: 500; }
.segment-link:hover { color: var(--text); }
.segment-link.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.settle-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .settle-layout { grid-template-columns: 1fr; } }
.input-with-action { display: flex; flex-wrap: wrap; gap: 8px; }
.input-with-action input { flex: 1 1 160px; min-width: 0; }
.input-with-action .btn { white-space: nowrap; }
.paid-up { margin: 0; padding: 16px; border-radius: var(--radius-sm); background: var(--success-soft); color: var(--success); font-weight: 600; text-align: center; }

.allocations summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.allocations ul { list-style: none; margin: 8px 0 0; padding: 0; min-width: 240px; }
.allocations li { display: flex; justify-content: space-between; gap: 16px; padding-block: 4px; border-block-end: 1px dashed var(--border); font-size: 0.85rem; white-space: normal; }
.allocations li:last-child { border-block-end: 0; }

/* ---------- Phase 7: notifications & profile ---------- */
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-size: 0.85rem; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.bell { position: relative; }
.bell-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; color: var(--text); }
.bell-btn:hover { background: var(--bg); }
.bell-count {
  position: absolute; top: 2px; inset-inline-end: 0;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.bell-panel {
  position: absolute; top: calc(100% + 8px); inset-inline-end: -60px; z-index: 30;
  width: min(380px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-block-end: 1px solid var(--border); }
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.notif-item + .notif-item { border-block-start: 1px solid var(--border); }
.notif-link { display: flex; gap: 12px; padding: 12px 16px; color: var(--text); text-decoration: none; }
.notif-link:hover { background: var(--bg); }
.notif-item.is-unread .notif-link { background: #f1f5fb; }
.notif-item.is-unread .notif-title::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-inline-start: 6px; border-radius: 50%; background: var(--primary); vertical-align: middle; }
.notif-item.is-new { animation: slide-in 0.4s ease; }
.notif-dot { flex: none; width: 10px; height: 10px; margin-block-start: 6px; border-radius: 50%; background: var(--muted); }
.kind-sale.notif-dot { background: var(--primary); }
.kind-payment.notif-dot { background: var(--success); }
.kind-sale_cancelled.notif-dot { background: var(--danger); }
.kind-low_stock.notif-dot { background: var(--accent); }
.notif-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-title { font-size: 0.85rem; }
.notif-message { font-size: 0.875rem; }
.notif-time { font-size: 0.75rem; color: var(--muted); }
.notif-empty { margin: 0; padding: 24px 16px; text-align: center; color: var(--muted); }
.bell-foot { display: block; padding: 10px 16px; text-align: center; border-block-start: 1px solid var(--border); text-decoration: none; font-weight: 600; font-size: 0.875rem; }
.bell-foot:hover { background: var(--bg); }

.toasts { position: fixed; bottom: 16px; inset-inline-end: 16px; z-index: 50; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 32px)); }
.toast {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px;
  background: var(--surface); color: var(--text); text-decoration: none;
  border: 1px solid var(--border); border-inline-start: 4px solid var(--primary); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(12px); transition: opacity 0.3s, transform 0.3s;
}
.toast.is-visible { opacity: 1; transform: none; }
.toast.kind-payment { border-inline-start-color: var(--success); }
.toast.kind-sale_cancelled { border-inline-start-color: var(--danger); }
.toast.kind-low_stock { border-inline-start-color: var(--accent); }
.toast-title { font-size: 0.85rem; color: var(--primary-dark); }
.toast-time { color: var(--muted); }

.history-list { list-style: none; margin: 0; padding: 0; }
.history-item { display: flex; gap: 14px; align-items: flex-start; padding: 14px 20px; }
.history-item + .history-item { border-block-start: 1px solid var(--border); }
.history-item.is-unread { background: #f1f5fb; }
.history-body { flex: 1; display: flex; flex-direction: column; gap: 2px; color: var(--text); text-decoration: none; min-width: 0; }
.history-body:hover strong { color: var(--primary); }
.history-body time { font-size: 0.8rem; color: var(--muted); }

.stats-5 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .stats-5 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .stats-5 { grid-template-columns: repeat(5, 1fr); } }
.live-badge { display: inline-flex; align-items: center; gap: 8px; padding: 0.3rem 0.8rem; border-radius: 999px; background: var(--success-soft); color: var(--success); font-weight: 600; font-size: 0.85rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 1.6s infinite; }
#profile-body.flash .stat, #profile-body.flash .card { animation: flash 1.2s ease; }

@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes flash { 0% { box-shadow: 0 0 0 3px rgba(18, 55, 94, 0.35); } 100% { box-shadow: var(--shadow); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 600px) {
  .bell-panel { position: fixed; top: 64px; inset-inline: 12px; width: auto; }
}

@media (max-width: 380px) {
  .stats, .stats-3, .stats-4, .stats-5 { grid-template-columns: 1fr; }
}

/* ---------- Phase 8: stock ---------- */
.nav-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-inline-start: 4px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center;
}
.stat-link { text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
.stat-link:hover { border-color: var(--primary); }
.stat-link.is-current { box-shadow: 0 0 0 2px var(--primary); }
.stat-danger { background: var(--danger-soft); border-color: #f4c7c3; }
.stat-danger .stat-label, .stat-danger .stat-value { color: var(--danger); }

.stock-table .stock-out .stock-qty { color: var(--danger); font-weight: 700; }
.stock-table .stock-low .stock-qty { color: #b45f06; font-weight: 700; }
.add-stock-form { display: flex; gap: 6px; margin: 0; }
.add-stock-form input {
  width: 90px; padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; font: inherit;
}
.add-stock-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }


/* ---------- Phase 9: exports ---------- */
.export-buttons { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.file-badge { display: inline-block; padding: 0 4px; border-radius: 3px; font-size: 0.65rem; font-weight: 700; color: #fff; letter-spacing: 0.02em; }
.file-xlsx { background: #1d7a46; }
.file-pdf { background: #c0392b; }


/* ---------- Brand: logo and gold accents ---------- */
.topbar { border-block-end: 3px solid var(--gold); }
.brand-logo { width: 44px; height: 44px; object-fit: contain; flex: none; }
.brand-name { color: var(--primary); }
.main-nav a.active { box-shadow: inset 0 -2px 0 var(--gold); }
.stat-accent { border-block-end: 3px solid var(--gold); }
.rank-list li:first-child .rank { background: var(--gold); color: var(--primary-dark); }
.rank-bar span { background: linear-gradient(90deg, var(--primary), #2a5b8c); }
.toast-title { color: var(--primary); }
.auth-card { border-block-start: 4px solid var(--gold); }
.auth-logo { display: block; width: 132px; height: 132px; margin: 0 auto; object-fit: contain; }
.auth-brand h1 { color: var(--primary); }
.page-head h1 { color: var(--primary-dark); }

.logo-setting { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.logo-preview {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px;
  border: 1px dashed var(--border); border-radius: var(--radius); background: var(--bg);
}
.logo-preview img { width: 120px; height: 120px; object-fit: contain; }
.logo-fields { flex: 1; min-width: 240px; }
.logo-fields input[type="file"] { padding: 0.5rem; background: var(--bg); }

/* ---------- Accounts: profits by professor ---------- */
.profit-table tfoot td {
  font-weight: 700; background: var(--gold-soft); border-block-start: 2px solid var(--gold);
  padding: 0.85rem 0.9rem; white-space: nowrap;
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .topbar, .messages, .toasts, .page-head .actions, .page-head .muted, .toolbar, .col-toggle { display: none !important; }
  .page { padding: 0; max-width: none; }
  .page-head { margin-block-end: 12px; }
  .card { box-shadow: none; border: 0; }
  .table-wrap { overflow: visible; }
  .table tr { break-inside: avoid; }
}
