/* ============================================================================
   Bog'chaOS — Class register (sinf jurnali)
   Green cloth cover, white pages, blue-black ink, red pencil for problems.
   ============================================================================ */

:root {
  --bg-app: #f1f3ef;
  --bg-sidebar: #ffffff;
  --bg-topbar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f8f5;
  --bg-card-glass: #ffffff;
  --bg-surface: #eceee9;
  --bg-input: #ffffff;

  --border-subtle: #d8ddd5;
  --border-strong: #a8b0a5;
  --border-focus: #1f3c96;
  --border-highlight: #a8b0a5;

  --text-primary: #1a1f2b;
  --text-secondary: #485160;
  --text-muted: #5b6370;

  /* Sidebar: a plain white page with hairline rules */
  --sidebar-text: #1a1f2b;
  --sidebar-muted: #485160;
  --sidebar-hover: #f1f3ef;
  --sidebar-rule: #d8ddd5;

  /* Ink and pencil */
  --color-primary: #1f3c96;
  --color-primary-hover: #182f78;
  --color-primary-rgb: 31, 60, 150;
  --on-primary: #ffffff;
  /* Solid action fills stay deep ink in both themes; --color-primary is for text and lines. */
  --fill-primary: #1f3c96;
  --fill-primary-hover: #182f78;
  --on-fill: #ffffff;

  --color-emerald: #1c7a4a;
  --color-emerald-bg: #e2f0e7;

  --color-amber: #9a5800;
  --color-amber-bg: #f8ecd6;

  --color-rose: #c0262d;
  --color-rose-bg: #fae4e4;

  --color-indigo: #1f3c96;
  --color-indigo-bg: #e4e9f5;

  --color-late: #6a3d9a;
  --color-late-bg: #eee6f6;

  --shadow-sm: 0 1px 2px rgba(26, 31, 43, 0.06);
  --shadow-md: 0 2px 8px rgba(26, 31, 43, 0.08);
  --shadow-lg: 0 16px 40px rgba(26, 31, 43, 0.18);
  --shadow-glow: none;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  --transition-fast: 0.16s cubic-bezier(0.22, 1, 0.36, 1);
  --transition-normal: 0.26s cubic-bezier(0.22, 1, 0.36, 1);

  --font-ui: 'Golos Text', -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

/* The register at night */
[data-theme="dark"] {
  --bg-app: #0f1411;
  --bg-sidebar: #151b17;
  --bg-topbar: #151b17;
  --bg-card: #171e1a;
  --bg-card-hover: #1c2420;
  --bg-card-glass: #171e1a;
  --bg-surface: #202925;
  --bg-input: #131915;

  --border-subtle: #2b3530;
  --border-strong: #4a564f;
  --border-focus: #9db2f2;
  --border-highlight: #4a564f;

  --text-primary: #e8ece7;
  --text-secondary: #aeb8b0;
  --text-muted: #8e9891;

  --sidebar-text: #e8ece7;
  --sidebar-muted: #aeb8b0;
  --sidebar-hover: #1c2420;
  --sidebar-rule: #2b3530;

  --color-primary: #9db2f2;
  --color-primary-hover: #b6c6f6;
  --color-primary-rgb: 157, 178, 242;
  --on-primary: #0e1630;
  --fill-primary: #2c4aa8;
  --fill-primary-hover: #3756b8;
  --on-fill: #ffffff;

  --color-emerald: #5cc794;
  --color-emerald-bg: rgba(92, 199, 148, 0.14);
  --color-amber: #e6a84a;
  --color-amber-bg: rgba(230, 168, 74, 0.14);
  --color-rose: #f07479;
  --color-rose-bg: rgba(240, 116, 121, 0.14);
  --color-indigo: #9db2f2;
  --color-indigo-bg: rgba(157, 178, 242, 0.14);
  --color-late: #c2a0ea;
  --color-late-bg: rgba(194, 160, 234, 0.14);

  --shadow-sm: none;
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--color-indigo-bg); color: var(--text-primary); }

/* Components set their own display; the hidden attribute must still win. */
[hidden] { display: none !important; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-ui);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

/* ============================================================================
   App Layout
   ============================================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================================
   Sidebar
   ============================================================================ */

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background-color: var(--bg-sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-rule);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.sidebar-header {
  padding: 24px 20px 16px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--fill-primary);
  color: var(--on-fill);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text h2 {
  font-size: 1.3rem;
  line-height: 1.1;
  color: var(--sidebar-text);
}

.logo-text h2 span {
  color: var(--sidebar-muted);
  font-weight: 500;
}

.badge-saas {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--sidebar-muted);
  margin-top: 2px;
}

/* Tenant Card */
.tenant-card {
  margin: 4px 16px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--sidebar-rule);
  border-bottom: 1px solid var(--sidebar-rule);
  display: flex;
  align-items: center;
  gap: 12px;
}

.tenant-details .tenant-name { color: var(--sidebar-text); font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }

.tenant-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--sidebar-hover);
  border: 1px solid var(--sidebar-rule);
  color: var(--sidebar-text);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tenant-details h4 {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.tenant-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--sidebar-muted);
  font-weight: 500;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--color-emerald);
  border-radius: 50%;
}

/* Sidebar Nav */
.sidebar-nav {
  padding: 8px 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--sidebar-muted);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.nav-item.active {
  background: var(--color-indigo-bg);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-counter {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  color: inherit;
  opacity: 0.8;
}

.nav-status-badge {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-emerald);
  font-size: 0;
}

.nav-item.active .nav-status-badge { background: var(--color-emerald); }

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-rule);
}

.user-name { color: var(--sidebar-text); }
.user-role { color: var(--sidebar-muted); }
.sidebar-footer .icon-button { background: transparent; border-color: var(--sidebar-rule); color: var(--sidebar-muted); }
.sidebar-footer .icon-button:hover { background: var(--sidebar-hover); color: var(--sidebar-text); border-color: var(--sidebar-rule); }

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-indigo-bg);
  color: var(--color-primary);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: block;
  font-size: 0.75rem;
}

/* ============================================================================
   Main Content Area & Topbar
   ============================================================================ */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 64px;
  padding: 0 32px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 8px 18px;
  width: 340px;
  transition: all var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--border-focus);
}

.search-box svg {
  color: var(--text-muted);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  width: 100%;
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-right: 1px solid var(--border-subtle);
  padding-right: 16px;
}

.clock-time {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.icon-button:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.lang-toggle {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.theme-toggle .sun-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: none;
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-rose);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================================
   Content Container & Panels
   ============================================================================ */

.content-container {
  padding: 32px;
  flex: 1;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.panel-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.panel-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
  max-width: 68ch;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================================================
   Buttons & Controls
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--fill-primary);
  color: var(--on-fill);
}

.btn-primary:hover:not(:disabled) {
  background: var(--fill-primary-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface);
}

.btn-success {
  background: var(--color-emerald);
  color: #ffffff;
}

.btn-success:hover:not(:disabled) { background: #166340; }
[data-theme="dark"] .btn-success { color: #0b1f14; }
[data-theme="dark"] .btn-success:hover:not(:disabled) { background: #7ad6aa; }

.btn-danger {
  background: var(--bg-card);
  color: var(--color-rose);
  border-color: currentColor;
}

.btn-danger:hover:not(:disabled) { background: var(--color-rose-bg); }

.btn-sm {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 0.82rem;
}

.custom-select, .custom-input {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.custom-input::placeholder, .search-box input::placeholder, .input-search::placeholder { color: var(--text-muted); }

.custom-select:focus, .custom-input:focus {
  border-color: var(--border-focus);
  outline: 2px solid var(--color-indigo-bg);
  outline-offset: 0;
}

/* ============================================================================
   KPI Stat Cards
   ============================================================================ */

/* Summary figures read as one ruled register line, not separate tiles. */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 28px;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-subtle);
}

.stat-card {
  padding: 16px 20px 16px 0;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
}

.stat-card + .stat-card { padding-left: 20px; box-shadow: -1px 0 0 var(--border-subtle); }

.stats-grid .stat-icon-wrapper { display: none; }

.stat-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.color-indigo { background: var(--color-indigo-bg); color: var(--color-indigo); }
.color-emerald { background: var(--color-emerald-bg); color: var(--color-emerald); }
.color-amber { background: var(--color-amber-bg); color: var(--color-amber); }
.color-rose { background: var(--color-rose-bg); color: var(--color-rose); }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-value {
  font-size: clamp(1.2rem, 1.5vw, 1.5rem);
  white-space: nowrap;
  font-weight: 700;
  margin: 2px 0 4px;
  letter-spacing: -0.01em;
}

.stat-trend {
  font-size: 0.78rem;
  font-weight: 600;
}

.stat-trend.positive { color: var(--color-emerald); }
.stat-trend.negative { color: var(--color-rose); }

/* ============================================================================
   Cards & Grids
   ============================================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.card.no-padding {
  padding: 8px;
  overflow: hidden;
}

.card.no-padding .table-responsive { border-radius: var(--radius-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-header.border-bottom {
  padding: 20px 24px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
  align-items: start;
}

/* Custom CSS Bar Chart */
.chart-wrapper {
  padding-top: 10px;
}

.custom-bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 200px;
  padding: 20px 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: 16px;
}

.bar-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
  gap: 8px;
}

.bar-pill {
  width: 100%;
  max-width: 6px;
  border-radius: 3px 3px 0 0;
  background: var(--color-primary);
  transition: background-color var(--transition-fast);
  position: relative;
}

.bar-pill:hover {
  background: var(--color-primary-hover);
}

/* Values are always printed: touch screens have no hover. */
.bar-pill::before {
  content: attr(data-percent);
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.bar-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Activity Feed */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.85rem;
}

.activity-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: var(--color-emerald-bg);
  color: var(--color-emerald);
}

.activity-icon[data-mark="EVENT"] { background: var(--bg-surface); }
.activity-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-secondary); }
.activity-icon[data-mark="ABSENT"] { background: var(--color-rose-bg); color: var(--color-rose); }
.activity-icon[data-mark="EXCUSED"] { background: var(--color-amber-bg); color: var(--color-amber); }
.activity-icon[data-mark="LATE"] { background: var(--color-late-bg); color: var(--color-late); }

.activity-details p {
  color: var(--text-primary);
  font-weight: 500;
}

.activity-details small {
  color: var(--text-muted);
}

.pulse-status {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-emerald);
  background: var(--color-emerald-bg);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* Groups Mini Grid */
.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.groups-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.group-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.group-name {
  font-weight: 700;
  font-size: 1rem;
}

.group-teacher {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.group-progress-wrap {
  margin-top: 12px;
}

.group-progress-bar {
  height: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 6px;
}

.group-progress-fill {
  height: 100%;
  background: var(--color-emerald);
  border-radius: var(--radius-full);
}

/* ============================================================================
   Tables
   ============================================================================ */

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  padding: 12px 16px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background-color var(--transition-fast);
}

/* Wide tables scroll inside their card, capped to the viewport so the horizontal
   scrollbar is always on screen; the name column and the actions column stay put. */
.table-responsive {
  max-height: calc(100vh - 240px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.table-responsive .data-table thead th { position: sticky; top: 0; z-index: 3; }
.table-responsive .data-table thead th:first-child { z-index: 4; }
.table-responsive .data-table .col-actions {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--bg-card);
  box-shadow: -1px 0 0 var(--border-subtle);
  white-space: nowrap;
}
.table-responsive .data-table th.col-actions { background: var(--bg-surface); z-index: 3; }
.table-responsive .data-table th:first-child,
.table-responsive .data-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-card);
  box-shadow: 1px 0 0 var(--border-subtle);
}
.table-responsive .data-table th:first-child { background: var(--bg-surface); }
.data-table td:has(> .btn), .data-table td:has(.badge) { white-space: nowrap; }
.doc-code, code {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-secondary);
}

.data-table td:has(> .btn[aria-label]) { white-space: nowrap; }
.data-table td > .btn[aria-label] { min-height: 30px; width: 30px; padding: 0; justify-content: center; vertical-align: middle; }
.tabel-grid-table td:last-child, .tabel-grid-table td:nth-last-child(2), .tabel-grid-table td:nth-last-child(3) { white-space: nowrap; }

.tabel-cell-demo { font-size: 16px; }

.data-table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

.child-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.child-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--color-indigo-bg);
  color: var(--color-primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.child-name {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-emerald { background: var(--color-emerald-bg); color: var(--color-emerald); }
.badge-rose { background: var(--color-rose-bg); color: var(--color-rose); }
.badge-amber { background: var(--color-amber-bg); color: var(--color-amber); }
.badge-indigo { background: var(--color-indigo-bg); color: var(--color-indigo); }

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.group-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.filter-tab {
  min-height: 34px;
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.filter-tab:hover { color: var(--text-primary); background: var(--bg-surface); }

.filter-tab.active {
  background: var(--fill-primary);
  color: var(--on-fill);
  font-weight: 600;
}

.filter-inputs {
  display: flex;
  gap: 10px;
}

.input-search {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
}

.input-search:focus { border-color: var(--border-focus); }

/* ============================================================================
   Attendance Section
   ============================================================================ */

/* Filled mark colours stay dark in both themes so white labels pass 4.5:1. */
.tab-panel {
  --att-present: #1c7a4a;
  --att-absent: #c0262d;
  --att-excused: #9a5800;
  --att-late: #6a3d9a;
}

.mark {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.att-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.att-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.att-field > span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.att-field .custom-select,
.att-field .custom-input {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
}

.att-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.att-progress {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.att-progress b {
  font-size: 1.5rem;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.att-tally {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.att-tally li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 4px 10px 4px 8px;
  border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums;
}

.att-tally .tally-present { background: var(--color-emerald-bg); color: var(--color-emerald); }
.att-tally .tally-absent { background: var(--color-rose-bg); color: var(--color-rose); }
.att-tally .tally-excused { background: var(--color-amber-bg); color: var(--color-amber); }
.att-tally .tally-late { background: var(--color-late-bg); color: var(--color-late); }

.att-readonly-note {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--color-amber-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.attendance-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.att-row {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.att-row[data-status="present"] { border-color: color-mix(in srgb, var(--color-emerald) 40%, var(--border-subtle)); }
.att-row[data-status="absent"] { border-color: color-mix(in srgb, var(--color-rose) 40%, var(--border-subtle)); }
.att-row[data-status="excused"] { border-color: color-mix(in srgb, var(--color-amber) 40%, var(--border-subtle)); }
.att-row[data-status="late"] { border-color: color-mix(in srgb, var(--color-late) 40%, var(--border-subtle)); }

/* The mark column: one drawn register mark per child, always in the same place. */
.att-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
}

.att-row[data-status="present"] .att-mark { border: none; background: var(--color-emerald-bg); color: var(--color-emerald); }
.att-row[data-status="absent"] .att-mark { border: none; background: var(--color-rose-bg); color: var(--color-rose); }
.att-row[data-status="excused"] .att-mark { border: none; background: var(--color-amber-bg); color: var(--color-amber); }
.att-row[data-status="late"] .att-mark { border: none; background: var(--color-late-bg); color: var(--color-late); }

/* Countdown bar for the undo window before a mark is saved. */
.att-row.is-pending::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--color-primary);
  transform-origin: left;
  animation: att-undo-drain var(--att-undo-ms, 5000ms) linear forwards;
}

@keyframes att-undo-drain {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.att-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.att-info {
  flex: 1;
  min-width: 0;
}

.att-name {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.att-meta {
  display: block;
  margin-top: 2px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.att-row[data-status="present"] .att-meta { color: var(--color-emerald); }
.att-row[data-status="absent"] .att-meta { color: var(--color-rose); }
.att-row[data-status="excused"] .att-meta { color: var(--color-amber); }
.att-row[data-status="late"] .att-meta { color: var(--color-late); }

.att-sync {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.att-sync.is-error { color: var(--color-rose); }

.att-link {
  background: none;
  border: none;
  padding: 0 2px;
  min-height: 32px;
  font: inherit;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.att-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.att-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.att-btn:active:not(:disabled) { transform: scale(0.97); }
.att-btn:disabled { cursor: not-allowed; opacity: 0.55; }
.att-btn[aria-pressed="true"]:disabled { opacity: 1; }

.att-btn[data-status="PRESENT"][aria-pressed="true"] { background: var(--att-present); border-color: var(--att-present); color: #ffffff; }
.att-btn[data-status="ABSENT"][aria-pressed="true"] { background: var(--att-absent); border-color: var(--att-absent); color: #ffffff; }
.att-btn[data-status="EXCUSED"][aria-pressed="true"] { background: var(--att-excused); border-color: var(--att-excused); color: #ffffff; }
.att-btn .mark { font-size: 1.1rem; }
.att-btn[data-status="LATE"][aria-pressed="true"] { background: var(--att-late); border-color: var(--att-late); color: #ffffff; }

@media (hover: hover) {
  .att-btn:hover:not(:disabled):not([aria-pressed="true"]) { border-color: var(--text-secondary); }
}

.att-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-secondary);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
}

.att-actionbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-top: 12px;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  background: var(--bg-app);
  border-top: 1px solid var(--border-subtle);
}

.att-actionbar[hidden] { display: none; }

.att-mark-rest {
  width: 100%;
  min-height: 52px;
  justify-content: center;
  font-size: 1rem;
}

@media (min-width: 640px) {
  .att-controls { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); max-width: 640px; }
}

/* Desktop: the register itself, one ruled line per child ending in the mark column. */
@media (min-width: 1024px) {
  .attendance-list {
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }

  .att-row,
  .att-row[data-status] {
    display: grid;
    grid-template-columns: 36px minmax(180px, 1fr) auto auto 40px;
    align-items: center;
    column-gap: 16px;
    padding: 10px 16px;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 0;
  }

  .att-row:last-child { border-bottom: none; }
  .att-row:hover { background: var(--bg-card-hover); }
  .att-row-head { display: contents; }
  .att-row .child-avatar { grid-column: 1; grid-row: 1; width: 36px; height: 36px; }
  .att-row .att-info { grid-column: 2; grid-row: 1; }
  .att-row .att-sync { grid-column: 3; grid-row: 1; flex-direction: row; align-items: center; gap: 6px; }
  .att-row .att-choices { grid-column: 4; grid-row: 1; grid-template-columns: repeat(4, auto); gap: 6px; }
  .att-row .att-mark { grid-column: 5; grid-row: 1; width: 36px; height: 36px; font-size: 20px; }
  .att-row .att-btn { min-height: 38px; padding: 6px 12px; font-size: 0.88rem; }
  .att-row.is-pending::after { height: 2px; }

  .att-actionbar { position: static; background: none; border-top: none; padding: 16px 0 0; }
  .att-mark-rest { width: auto; }
}


/* ============================================================================
   Kitchen & Meal Section
   ============================================================================ */

.meal-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.meal-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.meal-card.highlight-card {
  border-color: var(--color-primary);
  background: var(--color-indigo-bg);
}

.meal-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: none;
  letter-spacing: 0.05em;
}

.meal-title {
  font-size: 1.1rem;
  line-height: 1.3;
}

.meal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex: 1;
}

.meal-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.supplies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  padding: 24px;
}

.supply-item {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.supply-name {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 6px;
}

.supply-amount {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
}

.supply-calc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ============================================================================
   Telegram TMA Simulator
   ============================================================================ */

.tma-simulator-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 32px;
  align-items: start;
}

.tma-info-card {
  padding: 32px;
}

.feature-checklist {
  list-style: none;
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.feature-checklist li::before {
  content: '';
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--color-emerald-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231c7a4a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 14px no-repeat;
}

.tma-action-box {
  padding-top: 20px;
  margin-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

/* Phone Mockup Frame */
.phone-mockup-wrapper {
  display: flex;
  justify-content: center;
}

.smartphone-frame {
  width: 360px;
  height: 680px;
  background: #000;
  border-radius: 44px;
  border: 8px solid #27272a;
  padding: 6px;
  box-shadow: 0 20px 48px rgba(26, 31, 43, 0.28);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.smartphone-frame .tma-screen { border-radius: 30px; }

.smartphone-notch {
  width: 140px;
  height: 24px;
  background: #27272a;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 0 0 16px 16px;
  z-index: 100;
}

.tma-screen {
  flex: 1;
  background: #17212b; /* Telegram Dark BG */
  color: #fff;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-y: auto;
}

.tma-header {
  height: 52px;
  padding: 16px 16px 8px;
  background: #242f3d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tma-screen {
  --color-emerald: #5cc794; --color-emerald-bg: rgba(92, 199, 148, 0.16);
  --color-rose: #f07479; --color-rose-bg: rgba(240, 116, 121, 0.16);
  --color-amber: #e6a84a; --color-amber-bg: rgba(230, 168, 74, 0.16);
}
.tma-close { color: #6ab2f2; cursor: pointer; }
.tma-title { font-weight: 600; }
.tma-menu { color: #6ab2f2; cursor: pointer; }

.tma-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tma-profile-card {
  padding: 4px 2px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.tma-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #2b5278;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.tma-child-meta h4 {
  font-size: 1rem;
  color: #fff;
}

.tma-child-meta span {
  font-size: 0.75rem;
  color: #93a4b5;
}

.tma-status-tag {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 0.72rem;
  font-weight: 600;
}

.tma-widget {
  background: #242f3d;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tma-widget-title {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: #6ab2f2;
}

.tma-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #c0cdd9;
}

.tma-menu-snippet {
  font-size: 0.82rem;
  line-height: 1.4;
  color: #e4ecf2;
}

.tma-payment-widget {
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.tma-amount-row {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
}

.tma-btn-pay {
  background: #2b5278;
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s;
}

.tma-btn-pay:hover {
  background: #3a6d9e;
}

/* ============================================================================
   Settings & Plan
   ============================================================================ */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.settings-grid .span-2 { grid-column: 1 / -1; }
.audit-changes-list { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.audit-changes-list li { white-space: nowrap; }
.audit-empty { color: var(--text-secondary); font-size: 0.92rem; padding: 10px 0 0; }
.text-muted { color: var(--text-secondary); font-size: 0.85rem; }
.staff-delete-btn { margin-left: 6px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.plan-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plan-banner p { color: var(--text-secondary); }

.plan-badge {
  display: inline-block;
  align-self: flex-start;
  background: var(--color-primary);
  color: var(--on-primary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* ============================================================================
   Modals
   ============================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 22, 18, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.modal-close:hover { background: var(--bg-surface); color: var(--text-primary); }

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-surface);
}

/* Receipt Print Area */
.receipt-box {
  max-width: 480px;
}

/* A flat sheet of paper, not a card: it is what gets printed. */
.receipt-print-area {
  background: #ffffff;
  color: #1a1f2b;
  padding: 24px;
  border-top: 1px dashed #a8b0a5;
  border-bottom: 1px dashed #a8b0a5;
}

.receipt-header {
  text-align: center;
}

.receipt-header h4 {
  color: #1a1f2b;
  font-size: 1.1rem;
}

.receipt-header p {
  font-size: 0.8rem;
  color: #5b6370;
}

.receipt-code {
  display: inline-block;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  background: #eceee9;
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 6px;
}

.receipt-divider {
  border-top: 1px dashed #a8b0a5;
  margin: 14px 0;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.receipt-row.total-row {
  font-size: 1rem;
  font-weight: 700;
}

.receipt-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 16px;
  gap: 8px;
}

.receipt-qr small {
  font-size: 0.75rem;
  color: #5b6370;
  text-align: center;
}

/* ============================================================================
   Toast Notifications
   ============================================================================ */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  --toast-mark: #9db2f2;
  background: #1a1f2b;
  color: #f2f4f1;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(26, 31, 43, 0.25);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  animation: slideInRight 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 400px;
}

.toast::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--toast-mark);
  flex-shrink: 0;
}

[data-theme="dark"] .toast { background: #26302b; border: 1px solid var(--border-strong); }

@keyframes slideInRight {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.toast-success { --toast-mark: #6fd3a0; }
.toast.toast-info { --toast-mark: #9db2f2; }
.toast.toast-warning { --toast-mark: #f0a35a; }

.toast-action {
  flex-shrink: 0;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.toast-action:hover { background: rgba(255, 255, 255, 0.1); }

/* ============================================================================
   Phone & tablet shell
   ============================================================================ */

.menu-toggle,
.sidebar-scrim { display: none; }

/* Rasm yuborish */
#tab-photos .card { max-width: 760px; margin-bottom: 16px; }
.photo-channel-status { font-size: 0.95rem; }
.photo-channel-status[data-state="linked"] { color: var(--text-primary); }
.photo-channel-status[data-state="pending"] { color: var(--color-amber); }
.photo-channel-status[data-state="error"] { color: var(--color-rose); }
.photo-warning {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--color-amber-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
}
.photo-connect { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.photo-connect label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.photo-connect small { color: var(--text-muted); font-size: 0.82rem; }
.photo-connect-row { display: flex; gap: 8px; }
.photo-connect-row .custom-input { flex: 1; min-width: 0; }

.photo-form { display: flex; flex-direction: column; gap: 18px; }
.photo-target { border: none; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#photoChildSelect { width: 100%; max-width: 100%; }
.photo-target legend { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.photo-radio { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 0.95rem; cursor: pointer; }
.photo-radio input { width: 18px; height: 18px; accent-color: var(--fill-primary); }
#photoChildSelect { min-height: 44px; }

.photo-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}
.photo-drop:hover { border-color: var(--color-primary); }
.photo-drop svg { color: var(--color-primary); }
.photo-drop b { color: var(--text-primary); }
.photo-drop small { font-size: 0.82rem; color: var(--text-muted); }

.photo-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.photo-previews:empty { display: none; }
.photo-thumb { position: relative; aspect-ratio: 1; margin: 0; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-subtle); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(26, 31, 43, 0.75);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.photo-caption { width: 100%; resize: vertical; min-height: 64px; line-height: 1.4; }
.photo-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.photo-actions span { color: var(--text-secondary); font-size: 0.9rem; }

@media (max-width: 767px) {
  .photo-connect-row { flex-direction: column; }
  .photo-actions { flex-direction: column; align-items: stretch; }
  .photo-actions .btn { justify-content: center; min-height: 48px; }
}

/* Dashboard: to-do list and debtors */
.todo-list, .debtor-list { list-style: none; display: flex; flex-direction: column; }
.todo-list li + li, .debtor-list li + li { border-top: 1px solid var(--border-subtle); }
.todo-item, .debtor-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 4px;
  border: none;
  background: none;
  font: inherit;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.todo-item:hover, .debtor-item:hover { background: var(--bg-card-hover); }
.todo-text, .debtor-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.todo-text b, .debtor-text b { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.todo-text small, .debtor-text small { color: var(--text-secondary); font-size: 0.82rem; }
.todo-count { font-weight: 700; font-size: 1.05rem; color: var(--color-amber); font-variant-numeric: tabular-nums; }
.todo-item[data-kind="money"] .todo-count { color: var(--color-rose); }
.todo-item[data-kind="telegram"] .todo-count, .todo-item[data-kind="groups"] .todo-count { color: var(--text-secondary); }
.todo-chevron { color: var(--text-muted); flex-shrink: 0; }
.todo-empty { padding: 14px 4px; color: var(--text-secondary); font-size: 0.92rem; }
.debtor-item .child-avatar { width: 34px; height: 34px; font-size: 0.78rem; }
.debtor-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.debtor-amount.is-overdue { color: var(--color-rose); }

/* Dashboard: collection and income chart */
.collection-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
.collection-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.92rem; }
.collection-head b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.collection-bar { height: 8px; margin: 10px 0 8px; border-radius: var(--radius-full); background: var(--bg-surface); overflow: hidden; }
.collection-bar span { display: block; height: 100%; background: var(--color-emerald); border-radius: inherit; }
.collection-note { font-size: 0.85rem; color: var(--text-secondary); }
.custom-bar-chart { position: relative; }
.chart-empty { position: absolute; inset: 0 0 32px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); font-size: 0.92rem; }
.bar-pill.is-empty { height: 3px; background: var(--border-subtle); }
.bar-column.is-current .bar-label { color: var(--text-primary); font-weight: 700; }

/* Group cards with a fill ring */
.groups-mini-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.group-card { display: flex; gap: 14px; align-items: flex-start; }
.group-ring { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.group-ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.group-ring .ring-track { fill: none; stroke: var(--bg-surface); stroke-width: 6; }
.group-ring .ring-fill { fill: none; stroke: var(--color-emerald); stroke-width: 6; stroke-linecap: round; }
.group-card[data-state="full"] .ring-fill { stroke: var(--color-amber); }
.group-card[data-state="over"] .ring-fill { stroke: var(--color-rose); }
.group-ring span { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 0.72rem; color: var(--text-secondary); line-height: 1.1; }
.group-ring b { font-size: 1.05rem; color: var(--text-primary); }
.group-body { flex: 1; min-width: 0; }
.group-body .group-card-header { margin-bottom: 2px; }
.group-body .group-card-header .btn { width: 30px; min-height: 30px; padding: 0; justify-content: center; }
.teacher-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.teacher-chip { font-size: 0.8rem; padding: 2px 8px; border-radius: var(--radius-full); background: var(--color-indigo-bg); color: var(--color-primary); }
.teacher-chip.is-missing { background: var(--color-amber-bg); color: var(--color-amber); }
.group-status { font-size: 0.85rem; color: var(--text-secondary); padding-top: 8px; border-top: 1px solid var(--border-subtle); }
.group-card[data-state="full"] .group-status { color: var(--color-amber); font-weight: 600; }
.group-card[data-state="over"] .group-status { color: var(--color-rose); font-weight: 600; }
.group-card[data-state="over"] { border-color: color-mix(in srgb, var(--color-rose) 40%, var(--border-subtle)); }

/* Payment window */
.pay-body { display: flex; flex-direction: column; gap: 16px; }
.pay-status { padding: 12px 14px; border-radius: var(--radius-md); background: var(--bg-surface); font-weight: 600; }
.pay-status[data-state="ok"] { background: var(--color-emerald-bg); color: var(--color-emerald); }
.pay-status[data-state="debt"] { background: var(--color-amber-bg); color: var(--color-amber); }
.pay-status[data-state="overdue"], .pay-status[data-state="error"] { background: var(--color-rose-bg); color: var(--color-rose); }
.pay-month { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pay-month > span { font-size: 0.9rem; color: var(--text-secondary); font-weight: 600; }
.pay-month-picker { display: flex; align-items: center; gap: 8px; }
.pay-month-picker b { min-width: 120px; text-align: center; }
.pay-amount { font-size: 1.4rem !important; font-weight: 700; min-height: 52px; width: 100%; }
.pay-hint { color: var(--text-secondary); font-size: 0.82rem; }
.pay-methods { border: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-width: 0; }
.pay-methods legend { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.pay-methods label { position: relative; }
.pay-methods input { position: absolute; opacity: 0; inset: 0; }
.pay-methods span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-card);
}
.pay-methods input:checked + span { background: var(--fill-primary); border-color: var(--fill-primary); color: var(--on-fill); }
.pay-methods input:focus-visible + span { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Reminders */
.reminders-card { margin-bottom: 24px; }
.reminder-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}
.reminder-stats > div { padding: 12px 14px 12px 0; display: flex; flex-direction: column; }
.reminder-stats > div + div { padding-left: 14px; box-shadow: -1px 0 0 var(--border-subtle); }
.reminder-stats span, .reminder-stats small { font-size: 0.8rem; color: var(--text-secondary); }
.reminder-stats b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.reminder-form { display: flex; flex-direction: column; gap: 4px; max-width: 760px; }
.switch-row, .stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.section-heading { font-size: 1.15rem; font-weight: 700; }
.tma-pick-label { font-size: 0.95rem; margin-bottom: 8px; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row small { color: var(--text-secondary); font-size: 0.82rem; }
.switch { appearance: none; width: 46px; height: 26px; border-radius: var(--radius-full); background: var(--border-strong); position: relative; cursor: pointer; transition: background-color var(--transition-fast); flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform var(--transition-fast); }
.switch:checked { background: var(--color-emerald); }
.switch:checked::after { transform: translateX(20px); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper b { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.stepper .icon-button { font-size: 1.2rem; font-weight: 600; }
.reminder-help { font-size: 0.82rem; color: var(--text-muted); margin: 6px 0 10px; }
.reminder-block { padding: 12px 0; border-bottom: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 8px; }
.reminder-label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.time-chips, .field-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.time-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px; border-radius: var(--radius-full); background: var(--bg-surface); font-weight: 600; font-variant-numeric: tabular-nums; }
.time-chip button { width: 24px; height: 24px; border: none; border-radius: 50%; background: transparent; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.time-chip button:hover { background: var(--border-subtle); color: var(--text-primary); }
.time-add { display: flex; gap: 8px; align-items: center; }
.time-add .custom-input { width: 130px; }
.field-chip { border: 1px dashed var(--border-strong); background: none; color: var(--color-primary); border-radius: var(--radius-full); padding: 4px 10px; font: inherit; font-size: 0.82rem; cursor: pointer; }
.reminder-template { width: 100%; resize: vertical; min-height: 80px; line-height: 1.45; }
.reminder-preview { font-size: 0.88rem; color: var(--text-secondary); background: var(--bg-surface); border-radius: var(--radius-md); padding: 10px 12px; }
.reminder-preview:empty { display: none; }
.reminder-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; }

/* Staff attendance */
.staff-att-card { margin-bottom: 24px; }
.staff-att-row { display: flex; align-items: center; gap: 16px; padding: 10px 0; border-top: 1px solid var(--border-subtle); }
.staff-att-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.staff-att-info small { color: var(--text-secondary); font-size: 0.82rem; }
.staff-att-row[data-status="present"] .staff-att-info small { color: var(--color-emerald); }
.staff-att-row[data-status="absent"] .staff-att-info small { color: var(--color-rose); }
.staff-att-row[data-status="excused"] .staff-att-info small { color: var(--color-amber); }
.staff-att-row[data-status="late"] .staff-att-info small { color: var(--color-late); }
.staff-att-buttons { display: grid; grid-template-columns: repeat(4, auto); gap: 6px; }
.staff-att-buttons .att-btn { min-height: 38px; padding: 6px 10px; font-size: 0.85rem; }

@media (max-width: 767px) {
  .pay-methods { grid-template-columns: repeat(2, 1fr); }
  .staff-att-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .staff-att-buttons { grid-template-columns: repeat(2, 1fr); }
  .staff-att-buttons .att-btn { min-height: 44px; }
  .reminder-actions { flex-direction: column-reverse; }
  .reminder-actions .btn { justify-content: center; min-height: 46px; }
}

/* Ошхона харажатлари */
.kitchen-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}
.kitchen-summary > div { padding: 14px 20px 14px 0; display: flex; flex-direction: column; gap: 2px; }
.kitchen-summary > div + div { padding-left: 20px; box-shadow: -1px 0 0 var(--border-subtle); }
.kitchen-summary span { font-size: 0.85rem; color: var(--text-secondary); }
.kitchen-summary b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.kitchen-summary small { font-size: 0.8rem; color: var(--text-secondary); }

.kitchen-history { display: flex; flex-direction: column; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; }
.kitchen-history-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto 16px;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 10px 16px;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  background: none;
  font: inherit;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}
.kitchen-history-row:last-child { border-bottom: none; }
.kitchen-history-row:hover { background: var(--bg-card-hover); }
.kitchen-history-week { font-weight: 600; }
.kitchen-history-count, .kitchen-history-total { color: var(--text-secondary); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.kitchen-history-per { font-weight: 700; font-variant-numeric: tabular-nums; }
.kitchen-history-row .todo-chevron { color: var(--text-muted); }

.kitchen-modal { max-width: 640px; }
.kitchen-items-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 120px 110px 40px;
  gap: 8px;
  padding: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.kitchen-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; min-width: 0; }
.kitchen-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 120px 110px 40px;
  gap: 8px;
  align-items: center;
}
.kitchen-item-row { min-width: 0; }
.kitchen-item-row input { min-height: 40px; min-width: 0; }
.kitchen-row-total { font-size: 0.88rem; font-variant-numeric: tabular-nums; color: var(--text-secondary); text-align: right; padding-right: 4px; }
.kitchen-item-row .icon-button { width: 36px; height: 36px; }
.kitchen-totals { display: flex; justify-content: flex-end; gap: 24px; padding-top: 14px; border-top: 1px solid var(--border-subtle); margin-top: 6px; }
.kitchen-totals b { font-variant-numeric: tabular-nums; }
.kitchen-detail-summary { margin-bottom: 14px; color: var(--text-secondary); }

@media (max-width: 767px) {
  .kitchen-items-head { display: none; }
  .kitchen-item-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "name name" "qty price" "total remove"; }
  .kitchen-item-row .kitchen-name { grid-area: name; }
  .kitchen-item-row .kitchen-qty { grid-area: qty; }
  .kitchen-item-row .kitchen-price { grid-area: price; }
  .kitchen-item-row .kitchen-row-total { grid-area: total; text-align: left; }
  .kitchen-item-row .icon-button { grid-area: remove; justify-self: end; }
  .kitchen-item-row { gap: 6px 8px; padding-bottom: 10px; border-bottom: 1px dashed var(--border-subtle); }
  .kitchen-history-row { grid-template-columns: 1fr auto 16px; row-gap: 4px; }
  .kitchen-history-count { display: none; }
}

.tg-btn { margin-top: 6px; }
.tg-child { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.tg-status { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 12px; }
.tg-status[data-state="linked"] { color: var(--color-emerald); }
.tg-status[data-state="error"] { color: var(--color-rose); }
.tg-help { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 14px; max-width: 60ch; }
#tgLinkUrl { width: 100%; font-size: 0.85rem; }

.demo-chip {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-amber);
  background: var(--color-amber-bg);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

@media (min-width: 1024px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; height: auto; }
  .main-content { margin-left: 264px; }
}

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 86vw);
    height: 100dvh;
    z-index: 1100;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--transition-normal), visibility 0s linear 0.28s;
    box-shadow: var(--shadow-lg);
  }

  body.nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform var(--transition-normal);
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
  }

  body.nav-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  .menu-toggle { display: flex; flex-shrink: 0; width: 44px; height: 44px; }

  .topbar { height: 64px; padding: 0 16px; gap: 12px; }
  .topbar-left { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
  .search-box, .search-box:focus-within { width: 100%; min-width: 0; }
  .topbar-right { gap: 10px; }

  .content-container { padding: 20px 16px 24px; }

  .dashboard-grid-2,
  .tma-simulator-layout,
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .tma-action-box .custom-select { width: 100%; max-width: 100%; }
  .smartphone-frame { max-width: 100%; }
}

@media (max-width: 767px) {
  .topbar .role-switcher-box, .topbar .live-clock { display: none; }
  .demo-chip { font-size: 0.72rem; padding: 3px 8px; }

  .filter-bar { align-items: stretch; }
  .group-tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .group-tabs .filter-tab { flex-shrink: 0; min-height: 40px; }
  .filter-inputs { flex-wrap: wrap; width: 100%; }
  .filter-inputs > * { flex: 1 1 100%; min-width: 0; min-height: 44px; }

  .panel-header { flex-direction: column; align-items: stretch; gap: 16px; margin-bottom: 20px; }
  .panel-title { font-size: 1.45rem; }
  .header-actions { flex-wrap: wrap; }
  .header-actions .btn { flex: 1 1 auto; justify-content: center; min-height: 44px; }

  .form-row { grid-template-columns: 1fr; }
  .modal-overlay { padding: 12px; }
  .modal-box { width: 100%; max-height: calc(100dvh - 24px); }
  .modal-body { max-height: none; flex: 1; }

  .toast-container { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .toast { max-width: none; }

  /* 16px inputs stop iOS Safari from zooming the page on focus. */
  .custom-input, .custom-select, .search-box input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Utilities */
.w-100 { width: 100%; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.text-right { text-align: right; }
.text-emerald { color: var(--color-emerald); }
.text-rose { color: var(--color-rose); }
.text-amber { color: var(--color-amber); }
.text-indigo { color: var(--color-indigo); }
.mb-4 { margin-bottom: 16px; }

/* ============================================================================
   Role Switcher in Topbar
   ============================================================================ */

.role-switcher-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  padding: 4px 12px;
  border-radius: var(--radius-md);
}

.role-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: none;
  letter-spacing: 0.04em;
}

.role-select {
  border: none !important;
  background: transparent !important;
  padding: 4px 6px !important;
  font-weight: 700 !important;
  color: var(--text-primary) !important;
  cursor: pointer;
}

/* ============================================================================
   Oylik Tabel (Monthly Attendance Matrix)
   ============================================================================ */

.tabel-legend-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.tabel-cell-demo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 16px;
}

.tabel-grid-table th, .tabel-grid-table td {
  padding: 8px 6px;
  text-align: center;
}

.tabel-grid-table th:first-child, .tabel-grid-table td:first-child {
  text-align: left;
  padding-left: 18px;
  min-width: 170px;
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 5;
}

.tabel-day-cell {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.p-cell { color: var(--color-emerald); }
.e-cell { color: var(--color-amber); }
.a-cell { color: var(--color-rose); }
.l-cell { color: var(--color-late); }
.w-cell { color: var(--text-muted); font-weight: 400; }

.tabel-grid-table .is-weekend { background: var(--bg-surface); }
.tabel-grid-table th.is-today { color: var(--color-primary); box-shadow: inset 0 -2px 0 var(--color-primary); }
.tabel-grid-table td.is-today { background: var(--color-indigo-bg); }

/* ============================================================================
   Omborxona & Sklad
   ============================================================================ */

.alert-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
}

.alert-warning {
  background: var(--color-amber-bg);
  border: 1px solid color-mix(in srgb, var(--color-amber) 35%, transparent);
  color: var(--text-primary);
}

.alert-info {
  background: var(--color-indigo-bg);
  border: 1px solid color-mix(in srgb, var(--color-primary) 30%, transparent);
  color: var(--text-primary);
}

.stock-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stock-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.stock-card.critical {
  border-color: var(--color-rose);
}

.stock-badge-critical {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--color-rose-bg);
  color: var(--color-rose);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stock-category {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: none;
}

.stock-title {
  font-size: 1rem;
  font-weight: 700;
}

.stock-amount-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.stock-qty {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================================================
   To'garaklar (Clubs)
   ============================================================================ */

.clubs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.club-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.club-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.club-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.club-fee {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-emerald);
}

/* ============================================================================
   Shartnomalar (Contracts) Paper
   ============================================================================ */

.contract-modal-box {
  max-width: 720px;
}

.contract-paper {
  background: #ffffff;
  color: #1a1f2b;
  padding: 36px 40px;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  line-height: 1.6;
}

.contract-head {
  text-align: center;
  border-bottom: 1px solid #1a1f2b;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.contract-head h3 {
  font-size: 1.15rem;
  color: #1a1f2b;
}

.contract-content h4 {
  font-size: 0.95rem;
  margin: 14px 0 6px;
  color: #1a1f2b;
}

.contract-content p {
  font-size: 0.88rem;
  margin-bottom: 10px;
  text-align: justify;
}

.contract-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-top: 24px;
  border-top: 1px solid #d8ddd5;
  padding-top: 16px;
  font-size: 0.85rem;
}

/* ============================================================================
   Foto-galereya
   ============================================================================ */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.gallery-card {
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.gallery-img-box {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
}

.img-art { background: #6a3d9a; }
.img-music { background: #1f3c96; }
.img-sport { background: #1c7a4a; }
.img-lunch { background: #9a5800; }

.gallery-info {
  padding: 16px;
}

.gallery-info h4 {
  font-size: 0.95rem;
  font-weight: 700;
}

.gallery-info small {
  color: var(--text-muted);
  font-size: 0.78rem;
}


/* Tabel period picker */
.tabel-controls { align-items: end; }
.tabel-period-nav { display: flex; gap: 8px; }
.tabel-period-nav .btn { min-height: 48px; min-width: 48px; font-size: 1.25rem; justify-content: center; }
.tabel-period-label { font-weight: 700; color: var(--text-secondary); margin: 0 0 12px; }
.tabel-year-link {
  background: none; border: 0; padding: 4px 6px; border-radius: 6px;
  font: inherit; color: inherit; cursor: pointer; white-space: nowrap;
}
.tabel-year-link:hover, .tabel-year-link:focus-visible { background: var(--surface-hover, rgba(127,127,127,.12)); }
@media (min-width: 640px) {
  .att-controls.tabel-controls { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; max-width: 820px; }
}

/* Staff attendance: date picker, monthly sheet, payroll rules */
.staff-att-card .card-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.staff-att-date { min-width: 180px; }
.staff-att-note { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: rgba(245, 158, 11, .12); color: var(--text-secondary); font-size: .9rem; }
.staff-month-controls { align-items: end; }
.staff-rules-summary { margin: 0; color: var(--text-secondary); font-size: .9rem; align-self: center; }
@media (min-width: 640px) {
  .att-controls.staff-month-controls { grid-template-columns: minmax(0, 220px) minmax(0, 1fr); max-width: none; }
}
.staff-sheet-header { padding: 16px 16px 0; }
.staff-sheet-day { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; border-radius: 6px; }
.staff-sheet-day:hover, .staff-sheet-day:focus-visible { outline: 2px solid var(--primary, #6366f1); outline-offset: 1px; }
.tabel-day-cell.u-cell { color: var(--text-muted); border: 1px dashed currentColor; font-weight: 700; }
.settings-payroll-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .settings-payroll-grid { grid-template-columns: 1fr 1fr; } }
.settings-subhead { font-size: 1rem; margin: 16px 0 8px; }
.holiday-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; margin-bottom: 12px; }
.holiday-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border-color, rgba(127,127,127,.2)); }
.holiday-date { font-variant-numeric: tabular-nums; font-weight: 600; }
.holiday-add { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .holiday-add { grid-template-columns: 180px minmax(0, 1fr) auto; } }

/* Financial reports */
.reports-card-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.reports-year-field { min-width: 140px; }
.reports-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.reports-kpi { border: 1px solid var(--border-subtle); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.reports-kpi span { font-size: .8rem; color: var(--text-secondary); }
.reports-kpi b { font-size: 1.05rem; overflow-wrap: anywhere; }
.reports-bar-cell { position: relative; min-width: 150px; padding: 2px 0; }
.reports-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--color-emerald-bg); border-radius: 4px; z-index: 0; }
.reports-bar-cell b { position: relative; z-index: 1; padding-left: 6px; }
.reports-table tr.is-future td { opacity: .45; }
.reports-total-row td { border-top: 2px solid var(--border-strong); }
.reports-controls { align-items: end; }
@media (min-width: 640px) {
  .att-controls.reports-controls { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; max-width: none; }
}
.reports-debtors-toggle { min-height: 48px; gap: 10px; }
.badge-slate { background: var(--border-subtle); color: var(--text-secondary); }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--border-focus); cursor: pointer; text-align: left; }
.link-button:hover, .link-button:focus-visible { text-decoration: underline; }
.modal-box.modal-wide { max-width: 920px; max-height: 90vh; }
.modal-box.modal-wide .modal-body { overflow-y: auto; }
.history-payments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

/* Delete group */
.modal-footer .modal-footer-start { margin-right: auto; }
.delete-group-text { margin: 0 0 16px; line-height: 1.5; }
.delete-group-note { margin: 12px 0 0; font-size: 13px; color: var(--text-secondary); }

.group-tabs-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.group-tab-actions { display: flex; gap: 8px; }
.group-tab-actions:empty { display: none; }
.group-tab-actions .btn { display: inline-flex; align-items: center; gap: 6px; }

/* Manual salary deduction */
.deduction-edit { margin-left: 6px; padding: 2px 6px; vertical-align: middle; }
.deduction-note { color: var(--text-secondary); }
.deduction-hint { margin: 0 0 14px; color: var(--text-secondary); }
.deduction-result { margin: 10px 0 0; font-weight: 600; }

#staffPayrollTableBody .badge-slate { margin-left: 4px; }
