
/* ============================================================
   شوپۇرلۇق مەكتىپى - ئوقۇغۇچى باشقۇرۇش سىستېمىسى
   Modern Mobile-First Design System v3.0
   — ھەممە تېلېفوندا مىدىرلىمايدۇ، تولۇق ئەڭگەشكەن
   ============================================================ */

/* ============================================================
   1. CSS VARIABLES & ROOT
   ============================================================ */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #dbeafe;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #06b6d4;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --font: 'izlar tom', 'Arial', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', monospace;
  --transition: 0.2s ease;

  /* iOS safe area */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ============================================================
   2. FONT FACE
   ============================================================ */
@font-face {
    font-family: 'izlar tom';
    src: url('UKIJEKRAN.ttf?v300') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ============================================================
   3. RESET & BASE — Mobile First (default: ≤767px)
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  /* Prevent horizontal scroll — critical */
  overflow-x: hidden;
  max-width: 100%;
  /* Smooth scrolling */
  scroll-behavior: smooth;
}

input, select, textarea, button, option, optgroup {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Prevent horizontal scroll — critical */
  overflow-x: hidden;
  max-width: 100%;
  /* Touch optimization */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

a {
  color: var(--primary);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

a:hover { color: var(--primary-dark); }

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Prevent text overflow on narrow screens */
p, h1, h2, h3, h4, h5, h6, span, div, td, th, li, label, a {
  overflow-wrap: break-word;
  word-break: normal;
}

/* ============================================================
   4. UTILITY CLASSES
   ============================================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ============================================================
   5. SCROLLBAR — Thin, subtle
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   6. LOGIN PAGE — Mobile First
   ============================================================ */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
  position: relative;
  overflow: hidden;
}

/* Animated background shapes */
.login-page::before {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, transparent 70%);
  top: -80px; right: -80px;
  border-radius: 50%;
  animation: float-bg 8s ease-in-out infinite;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(16,185,129,0.1) 0%, transparent 70%);
  bottom: -60px; left: -60px;
  border-radius: 50%;
  animation: float-bg 10s ease-in-out infinite reverse;
}

@keyframes float-bg {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -15px) scale(1.08); }
}

.login-card {
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 2rem 1.25rem;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
  animation: slideUp 0.5s ease;
}

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

.login-logo {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 1.5rem;
  box-shadow: 0 8px 20px rgba(59,130,246,0.3);
  color: white;
}

.login-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.login-subtitle {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.8rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.input-icon-wrap {
  position: relative;
}

.input-icon-wrap .icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.input-field {
  width: 100%;
  padding: 14px 42px 14px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 16px; /* Prevent iOS zoom */
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
  outline: none;
  text-align: right;
  direction: rtl;
  -webkit-tap-highlight-color: transparent;
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input-field::placeholder {
  color: var(--text-muted);
  font-family: var(--font);
}

.form-input::placeholder,
.form-select option,
.form-select::placeholder,
textarea::placeholder {
  font-family: var(--font);
}

/* LTR-only input گە: placeholder ۋە تېكىست سول تەرەپتىن باشلىنىدۇ */
[dir="ltr"].form-input {
  text-align: left;
  direction: ltr;
  unicode-bidi: plaintext;
}

[dir="ltr"].form-input::placeholder {
  text-align: left;
  direction: ltr;
  unicode-bidi: plaintext;
}

/* v168: phone + id-number input — placeholder ئۇيغۇرچە (RTL) ئوڭ تەرەپتىن، كىرگۈزۈلگەن سانلار (LTR) سول تەرەپتىن */
.form-input.ltr-numeric {
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}
.form-input.ltr-numeric::placeholder {
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  outline: none;
  direction: rtl;
  /* Touch optimization */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: var(--shadow-md);
  border: 2px solid transparent;
}

.btn-primary:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.97);
}

.btn-lg {
  padding: 16px 28px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-full { width: 100%; }

.btn-success { background: var(--success); color: white; border: 2px solid transparent; }
.btn-success:hover { background: #059669; }
.btn-success:active { background: #059669; }

.btn-danger { background: var(--danger); color: white; border: 2px solid transparent; }
.btn-danger:hover { background: #dc2626; }
.btn-danger:active { background: #dc2626; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}

.modal-footer .btn-primary { border: 2px solid transparent; }

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-sm { padding: 8px 14px; font-size: 0.8rem; min-height: 36px; }

.login-error {
  color: var(--danger);
  background: var(--danger-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 1rem;
  text-align: center;
  font-size: 0.9rem;
  display: none;
  animation: shake 0.4s ease;
}

.login-error.visible { display: block; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ============================================================
   7. ADMIN PAGE LAYOUT — Mobile First
   ============================================================ */
.admin-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* — 7.1 Header (Mobile: sticky + hamburger) — */
.header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: white;
  padding: 0.6rem 0.75rem;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
  flex-wrap: wrap;
  gap: 0.5rem;
  direction: rtl;
  padding-top: max(0.6rem, var(--safe-top));
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.header-title {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.header-subtitle {
  display: none; /* Hidden on mobile */
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Hamburger */
.header-hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  background: transparent;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.header-hamburger:active {
  background: rgba(255,255,255,0.15);
  transform: scale(0.92);
}

/* Header actions — hidden by default, shown when hamburger tapped */
.header-actions {
  display: none;
  flex-direction: column;
  width: 100%;
  gap: 0.5rem;
  padding: 0.75rem 0 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  animation: slideDown 0.25s ease;
}

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

.header-actions.open { display: flex; }

.header-actions .btn {
  width: 100%;
  justify-content: center;
  font-size: 0.9rem;
  padding: 12px 14px;
  border-radius: var(--radius);
  min-height: 44px; /* Minimum tap target */
}

.header-actions .header-user {
  display: none; /* Hidden on mobile */
}

/* User info shown inline next to hamburger */
.header-user-mobile {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* — 7.2 Main Content (Mobile) — */
.main-content {
  flex: 1;
  padding: 0.75rem;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  padding-bottom: max(0.75rem, var(--safe-bottom));
}

/* — 7.3 Stats Row (Mobile: 2-col grid) — */
.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem 0.6rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: all var(--transition);
  cursor: default;
  border: 1px solid var(--border-light);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.stat-card:active {
  transform: scale(0.97);
}

.stat-card:nth-child(5) {
  grid-column: 1 / -1; /* Last card spans full width on 2-col */
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.cyan { background: #cffafe; color: var(--info); }

.stat-body { min-width: 0; flex: 1; }

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
  white-space: nowrap;
}

/* — 7.4 Content Grid (Mobile: single column) — */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* — 7.5 Section Card (Mobile) — */
.section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
  max-width: 100%;
}

.section-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

/* — 7.6 Table Controls (Mobile: full-width, stacked) — */
.table-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 16px; /* Prevent iOS zoom */
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: all var(--transition);
  height: 44px; /* Minimum tap target */
  -webkit-tap-highlight-color: transparent;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--surface);
}

/* v166: Chrome autofill رەڭگىنى ئۆچۈرۈش */
.search-input:-webkit-autofill,
.search-input:-webkit-autofill:hover,
.search-input:-webkit-autofill:focus,
.search-input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  transition: background-color 9999s ease-in-out 0s !important;
}

.filter-select {
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: 'izlar tom', 'Arial', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px; /* Prevent iOS zoom */
  color: var(--text);
  background: var(--bg);
  outline: none;
  cursor: pointer;
  transition: all var(--transition);
  height: 44px; /* Minimum tap target */
  min-width: 70px;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 8px center;
  padding-left: 28px;
}

.filter-select:focus { border-color: var(--primary); }

/* چېسلا سۈزگۈچ بەلگىسى */
.date-filter-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #eff6ff;
  border: 1.5px solid #3b82f6;
  border-radius: 20px;
  font-family: var(--font);
  font-size: 13px;
  color: #1d4ed8;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  user-select: none;
}
.date-filter-badge:hover { background: #dbeafe; }
.date-filter-icon { font-size: 14px; }
.date-filter-text { font-weight: 600; }
.date-filter-clear {
  font-size: 11px;
  margin-left: 2px;
  opacity: 0.6;
  font-weight: 700;
}
.date-filter-badge:hover .date-filter-clear { opacity: 1; }

/* تىملىن چۈسكىنى تېگىشلىك */

/* — 7.7 Table (Desktop view hidden on mobile) — */
.desktop-table { display: none; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead { background: var(--bg); }

th {
  padding: 12px 14px;
  text-align: center;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 10px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  text-align: center;
}

td[dir="ltr"] { text-align: center; }

tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }

td:first-child {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

td:last-child {
  white-space: nowrap;
  padding: 8px 14px;
}

.action-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: all var(--transition);
  background: var(--bg);
  color: var(--text-secondary);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Table action buttons — flex container with gap for RTL/LTR consistency */
.table-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
}

.action-btn-labeled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: auto;
  min-width: 56px;
  height: auto;
  min-height: 36px;
  padding: 5px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.2;
  gap: 2px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  transition: all 0.18s ease;
}

.action-btn-labeled .action-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.action-btn-labeled .action-label {
  font-size: 0.65rem;
  white-space: nowrap;
  font-weight: 700;
}

/* v100: كۆرۈش كۇنۇپكىسى باشقا كۇنۇپكىلار بىلەن بىردەك ئۇسلۇبتا */
.action-btn-labeled.view {
  /* base style same as other action-btn-labeled — no override needed */
}
.action-btn-labeled.view:active { background: var(--primary-light); color: var(--primary); }

/* v93: confirm (تاللاش) — بىردەك يېنىق ئۇسلۇب، ئىكۇن رەڭىلا ئوزگەرىدۇ */
.action-btn-labeled.confirm {
  background: #fff;
  border-color: var(--success);
  color: var(--success);
}
.action-btn-labeled.confirm:active { background: var(--success); color: #fff; }

.action-btn:active { transform: scale(0.92); }
.action-btn.edit:active { background: var(--success-light); color: var(--success); }
.action-btn.delete:active { background: var(--danger-light); color: var(--danger); }
.action-btn.view { /* v100: base style matches other action-btn — no color override */ }
.action-btn.view:active { background: var(--primary-light); color: var(--primary); }

@media (hover: hover) {
  .action-btn:hover { transform: scale(1.1); }
  .action-btn-labeled.view:hover { background: var(--primary-light); color: var(--primary); }
  .action-btn-labeled.confirm:hover { background: var(--success); color: #fff; }
  .action-btn.view:hover { background: var(--primary-light); color: var(--primary); }
  .action-btn.edit:hover { background: var(--success-light); color: var(--success); }
  .action-btn.delete:hover { background: var(--danger-light); color: var(--danger); }
}

.photo-thumb {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg);
}

/* ============================================================
   7.8 MOBILE CARD VIEW (default: shown on ≤767px)
   ============================================================ */
.mobile-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
}

.student-mobile-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  transition: all var(--transition);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  max-width: 100%;
}

.student-mobile-card:active {
  background: var(--surface-hover);
  transform: scale(0.985);
}

.student-mobile-card .card-photo {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border);
  background: var(--bg);
}

.student-mobile-card .card-photo-placeholder {
  width: 48px; height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

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

.card-info .card-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.1rem;
}

.card-info .card-chinese {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.card-meta-item {
  font-size: 0.68rem;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  white-space: nowrap;
}

.card-meta-item.license {
  color: var(--primary);
  font-weight: 700;
  background: var(--primary-light);
  font-family: 'izlar tom', 'Arial', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-shrink: 0;
  align-self: center;
}

.card-actions .action-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 0.85rem;
}

/* — 7.9 Pagination (Mobile) — */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.pagination .btn {
  min-width: 34px;
  height: 34px;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pagination .page-info {
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 100%;
  text-align: center;
  order: -1;
  margin-bottom: 0.3rem;
}

/* — 7.10 Empty State — */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
  display: block;
}

.empty-state .empty-text {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  display: block;
  width: 100%;
  text-align: center;
}

/* — 7.11 Loading Spinner — */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  color: var(--text-muted);
  gap: 0.75rem;
}

.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   8. MODALS — Mobile First (full-screen bottom sheet style)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end; /* Bottom-aligned on mobile */
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.2s ease;
  max-width: 100%;
  overflow: hidden;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0; /* Rounded top on mobile */
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.3s ease;
  padding-bottom: var(--safe-bottom);
  max-width: 100%;
}

@keyframes modalSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-sm { }
.modal-md { }
.modal-lg { }
.modal-xl { }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.modal-close {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modal-close:active {
  background: var(--danger-light);
  color: var(--danger);
}

@media (hover: hover) {
  .modal-close:hover {
    background: var(--danger-light);
    color: var(--danger);
  }
}

  .modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }

.modal-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.modal-footer .btn {
  width: 100%;
  min-height: 44px;
}

.modal-footer-centered {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.modal-footer-centered .btn {
  width: 100%;
  min-height: 44px;
}

/* — 8.1 Form — */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* v200: 手机端时间 + 日期并排一行 */
.form-row-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-row-inline .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0; /* v209: CSS Grid تاشقىغا ئېقىپ كېتىشنىڭ ئالدىنى ئېلىش */
}

/* v209: form-row-inline ئىچىدىكى input/select لەر تولۇق كەڭلىكنى ئىگىلەش */
.form-row-inline .form-input,
.form-row-inline .form-select {
  width: 100%;
  min-width: 0;
}

/* v206: desktop دا ۋاقىت/چېسلا 3-ئىستون grid گە كىرىش */
.form-row-inline-time {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* v231: تەۋسىيە قىلغۇچى/چېسلا/ۋاقىت — بىر قۇر 3-ئىستون */
.form-row-inline-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}
.form-row-inline-3col .form-group { min-width: 0; }
.form-row-inline-3col .form-input { width: 100%; min-width: 0; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0; /* v209: تىلفوندا تاشقىغا ئېقىپ كېتىشنىڭ ئالدىنى ئېلىش */
}

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

.form-input, .form-select {
  width: 100%; /* v209: تولۇق كەڭلىكنى ئىگىلەش */
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 16px; /* Prevent iOS zoom */
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: all var(--transition);
  text-align: right;
  direction: rtl;
  -webkit-tap-highlight-color: transparent;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--surface);
}

.form-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 36px;
  padding-right: 14px;
}

[dir="ltr"].form-select {
  background-position: right 12px center;
  padding-right: 36px;
  padding-left: 14px;
}

.form-input[readonly] {
  background: var(--bg);
  opacity: 0.7;
  cursor: default;
}

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

/* — 8.3 Photo Upload — */
.photo-preview {
  width: 100%;
  max-width: 120px;
  aspect-ratio: 4/3;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
  background: var(--bg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* v205: form-row-inline دىكى رەسىم ئالدىن كۆرۈش ستوننى تولدۇرىدۇ */
.form-row-inline .photo-preview {
  max-width: 100%;
  width: 100%;
}

.photo-preview:active {
  border-color: var(--primary);
  background: var(--primary-light);
}

@media (hover: hover) {
  .photo-preview:hover {
    border-color: var(--primary);
    background: var(--primary-light);
  }
}

.photo-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* v215: كىملىك رەسىمى تولۇق كۆرۈنسۇن — contain ئىشلىتىپ كېسىلمەيدۇ */
/* v240: image-orientation: from-image — EXIF يۆنىلىشىنى قوبۇل قىلىش */
#preview-id img {
  object-fit: contain;
  image-orientation: from-image;
}

/* v236: كىملىك رەسىمى بۇلۇڭ بايقاش رامكىسى (كۆك سىزىق) */
.id-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}
.id-card-overlay polygon {
  stroke-dasharray: 10, 8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.photo-add-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 2.5rem;
  font-weight: 300;
  color: var(--primary);
  user-select: none;
  pointer-events: none;
}

.photo-preview .photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
}

.file-input-hidden { display: none; }

/* — OCR ID Card Button — */
.ocr-id-btn {
  width: 100%;
  justify-content: center;
  gap: 0.3rem;
  background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
  border-color: #7dd3fc;
  color: #0369a1;
}
.ocr-id-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.form-group .ocr-id-btn {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  margin-top: 0;
}

/* v212: خەنزۇچە ئىسمى ياردەمچى رايونى */
.chinese-name-helper {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  background: var(--danger-bg, rgba(239, 68, 68, 0.08));
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 8px 10px;
}
.chinese-name-helper .warning-text {
  color: var(--danger);
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}
.chinese-name-helper .helper-btn {
  display: inline-block;
  background: var(--warning);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  margin-top: 4px;
  font-family: var(--font);
}
.chinese-name-helper .helper-btn:hover {
  filter: brightness(0.92);
}

/* v213: خەنزۇچە ئىسمى كىرگۈزگۈچىنىڭ ئەتراپىدا تەرجىمە كۇنۇپكىسى */
.input-with-action {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.input-with-action .form-input {
  flex: 1;
  min-width: 0;
}
.input-with-action .input-action-btn {
  width: 40px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-1);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.input-with-action .input-action-btn:hover {
  background: var(--bg-2);
}

/* v213: خەنزۇچە ئىسمى كىرگۈزگۈچى تەرتىپسىزلىك ئەسكەرتىشى */
.form-input.name-incomplete {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* v212: OCR خام جاۋابى */
.ocr-diagnostics {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--bg-2);
  border-radius: 8px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  max-height: 160px;
  overflow: auto;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* — 8.4 Chat Records Upload — */
.chat-records {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-thumb-wrap {
  position: relative;
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
}

.chat-thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.chat-thumb-wrap .remove-chat {
  position: absolute;
  top: 2px; right: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: transform var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.chat-thumb-wrap .remove-chat:active {
  transform: scale(1.15);
}

@media (hover: none) {
  .chat-thumb-wrap .remove-chat { opacity: 1; }
}

.chat-add-btn {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border);
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--text-muted);
  transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.chat-add-btn:active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.chat-loading {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--primary);
  animation: pulse-loading 1s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-loading {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@media (hover: hover) {
  .chat-thumb-wrap:hover .remove-chat { opacity: 1; }
  .chat-add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
  }
}

/* ============================================================
   8.5 LIGHTBOX (رەسىم چوڭايتىش)
   ============================================================ */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  animation: fadeIn 0.2s ease;
  max-width: 100%;
}

.lightbox-overlay .lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.lightbox-overlay .lightbox-close:active {
  background: rgba(239,68,68,0.8);
}

@media (hover: hover) {
  .lightbox-overlay .lightbox-close:hover {
    background: rgba(239,68,68,0.8);
  }
}

.lightbox-overlay .lightbox-img-wrap {
  position: relative;
  max-width: 95vw;
  max-height: 78dvh;
}

.lightbox-overlay .lightbox-img-wrap img {
  max-width: 95vw;
  max-height: 78dvh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
  animation: lightboxIn 0.25s ease;
  display: block;
}

.lightbox-overlay .lightbox-watermark {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: linear-gradient(135deg, rgba(59,130,246,0.88), rgba(37,99,235,0.9));
  color: #fff;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  pointer-events: none;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
  white-space: nowrap;
}

@keyframes lightboxIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ============================================================
   9. DETAIL MODAL — Mobile First
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.detail-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem;
}

.detail-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.detail-value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
  text-align: right;
  direction: ltr;
  unicode-bidi: embed;
  line-height: 1.5;
}

#det-license {
  font-family: 'izlar tom', 'Arial', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* — 9.1 Detail Photos — */
.detail-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  width: 100%;
}

.detail-photo {
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.detail-photo-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  text-align: right;
}

.detail-photo img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 400px;
  object-fit: contain;
  background: #f8fafc;
  cursor: pointer;
  touch-action: manipulation;
}

/* — 9.2 Detail Chat Records — */
.detail-chat-records {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  margin-top: 0.5rem;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  direction: rtl;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-light) transparent;
}

.detail-chat-records::-webkit-scrollbar { height: 4px; }
.detail-chat-records::-webkit-scrollbar-track { background: transparent; }
.detail-chat-records::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 2px;
}

.detail-chat-records .chat-record-item {
  flex: 0 0 auto;
  width: 100px;
  height: 133px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.detail-chat-records .chat-record-item:active {
  transform: scale(0.96);
}

@media (hover: hover) {
  .detail-chat-records .chat-record-item:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
  }
}

.detail-chat-records img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #f8fafc;
}

.detail-chat-records-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
  display: block;
  font-weight: 600;
}


/* ============================================================
   10. STATS SIDEBAR (License Stats + Referrer + Timeline)
   ============================================================ */
.stats-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* — License Grid — */
.license-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  padding: 0.75rem;
}

.license-grid:has(> .empty-state) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.license-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.6rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.license-card:active {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: scale(0.97);
}

.license-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

@media (hover: hover) {
  .license-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
  }
}

.license-card-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
  font-family: 'izlar tom', 'Arial', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.license-card-count {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.license-card-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.4rem;
  overflow: hidden;
}

.license-card-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* — Referrer List — */
.referrer-list {
  padding: 0.75rem;
}

.referrer-list:has(> .empty-state) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
}

.referrer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
}

.referrer-item:last-child { border-bottom: none; }

.referrer-name {
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1;
}

.referrer-info {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.referrer-count {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 700;
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 20px;
}

.referrer-rank {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.referrer-rank.gold { background: #f59e0b; }
.referrer-rank.silver { background: #94a3b8; }
.referrer-rank.bronze { background: #d97706; }

/* ============================================================
   11. PASSWORD / CONFIRM DELETE MODALS
   ============================================================ */
.pw-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.confirm-icon {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 0.75rem;
}

.confirm-text {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.confirm-name {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

/* ============================================================
   12. TOAST — Mobile First
   ============================================================ */
.toast-container {
  position: fixed;
  top: max(0.5rem, var(--safe-top));
  left: 0.5rem;
  right: 0.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  font-size: 0.8rem;
  pointer-events: auto;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-right: 4px solid var(--primary);
  max-width: 100%;
}

.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--danger); }
.toast.warning { border-right-color: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-40px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-40px); }
}

/* ============================================================
   13. TIMELINE CHART
   ============================================================ */
.timeline-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.timeline-tab {
  flex: 1;
  min-width: 44px;
  padding: 0.55rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: 'izlar tom', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.timeline-tab:active {
  transform: scale(0.95);
}

.timeline-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(59,130,246,0.28);
}

@media (hover: hover) {
  .timeline-tab:hover:not(.active) {
    background: var(--surface-hover);
    border-color: var(--border);
    color: var(--text);
  }
}

.timeline-chart-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0.5rem;
  max-width: 100%;
  min-height: 210px;
}

/* v260: drill-down back button + year label */
.timeline-back-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
  flex-wrap: wrap;
}

.timeline-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-size: 0.78rem;
  font-family: 'izlar tom', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.timeline-back-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.timeline-back-btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

.timeline-drill-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  font-family: 'izlar tom', sans-serif;
}

.timeline-chart-wrap svg {
  display: block;
  width: 100%;
  min-width: 100%;
}

.timeline-bar {
  transition: opacity 0.2s ease, fill 0.2s ease;
  cursor: pointer;
}

.timeline-bar:hover {
  opacity: 0.85;
  fill: #2563eb;
}

.timeline-tooltip {
  position: absolute;
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  color: #fff;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 9999;
  font-family: 'izlar tom', monospace;
  max-width: 90vw;
}

/* ============================================================
   14. CSV PERIOD EXPORT MENU
   ============================================================ */
.csv-period-menu {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0,0,0,0.04);
  padding: 0.4rem;
  min-width: 180px;
  max-width: 92vw;
  animation: fadeInDown 0.22s ease;
  direction: rtl;
  overflow: hidden;
}

.csv-period-title {
  padding: 0.5rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border-light);
  margin-bottom: 0.3rem;
  text-align: center;
  letter-spacing: 0.3px;
}

.csv-period-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  width: 100%;
  text-align: right;
  padding: 0.65rem 0.85rem;
  margin: 0.2rem 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  font-family: 'izlar tom', sans-serif;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.csv-period-item::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.csv-period-item:active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.csv-period-item:active::before {
  background: var(--primary);
}

@media (hover: hover) {
  .csv-period-item:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
  }
  .csv-period-item:hover::before {
    background: var(--primary);
  }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Small screen: center the CSV menu */
@media (max-width: 640px) {
  .csv-period-menu {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    transform: translate(-50%, -50%);
    width: 240px;
    max-width: 92vw;
  }
  .csv-period-menu .csv-period-item {
    justify-content: center;
  }
}

/* — CSV export v103: 5-period grid + custom date range — */
.csv-menu { display: flex; flex-direction: column; gap: 0.6rem; }
.csv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}
.csv-grid .csv-option:last-child {
  grid-column: 1 / span 2;
  justify-self: center;
  max-width: 50%;
}
.csv-range-sep {
  height: 1px;
  background: var(--border-light);
  margin: 0.3rem 0 0.2rem;
}
.csv-range-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 0.2rem;
}
.csv-range-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
}
.csv-range-row label {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 60px;
  font-weight: 600;
}
.csv-range-row input[type="date"] {
  flex: 1;
  padding: 0.5rem 0.6rem;
  font-size: 0.88rem;
  font-family: 'izlar tom', sans-serif;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}
.csv-range-row input[type="date"]:focus {
  border-color: var(--primary);
}

/* ============================================================
   14.5 LANGUAGE SWITCHER (تىل ئالماشتۇرغۇچ / 语言切换器)
   ============================================================ */

/* — Admin header lang switch — */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: rgba(59,130,246,0.3);
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 3px;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--font);
  direction: ltr;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.lang-option {
  padding: 4px 12px;
  border-radius: 18px;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  transition: all 0.2s ease;
  white-space: nowrap;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
}

.lang-option.active {
  background: rgba(255,255,255,0.95);
  color: var(--primary-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  font-weight: 800;
}

/* — Login page lang switch — */
.login-lang-switch {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 2px;
  cursor: pointer;
  font-size: 0.72rem;
  font-family: var(--font);
  direction: ltr;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.login-lang-switch .lang-option {
  color: rgba(255,255,255,0.65);
}

.login-lang-switch .lang-option.active {
  color: #0f172a;
  background: rgba(255,255,255,0.9);
}

/* ============================================================
   15. RESPONSIVE — TABLET (768px+)
   Switch from card view to table view, expand layout
   ============================================================ */
@media (min-width: 768px) {
  /* — Header — */
  .header {
    height: 64px;
    padding: 0 1.5rem;
    flex-wrap: nowrap;
    gap: 1rem;
    min-height: 64px;
    padding-top: 0;
  }

  .header-logo {
    width: 40px; height: 40px;
    font-size: 1.2rem;
    border-radius: 10px;
  }

  .header-title { font-size: 1.15rem; }
  .header-subtitle { display: block; }

  /* Hide hamburger, show actions in row */
  .header-hamburger { display: none; }
  .header-user-mobile { display: none; }

  .header-actions {
    display: flex;
    flex-direction: row;
    width: auto;
    gap: 0.5rem;
    padding-top: 0;
    border-top: none;
  }

  .header-actions .btn {
    width: auto;
    font-size: 0.8rem;
    padding: 8px 14px;
    min-height: 36px;
  }

  .header-actions .header-user { display: flex; }

  /* — Main Content — */
  .main-content { padding: 1.5rem; }

  /* — Stats Row (5 columns) — */
  .stats-row {
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
  .stat-card:nth-child(5) { grid-column: auto; }
  .stat-card {
    padding: 1.25rem;
    gap: 1rem;
    border-radius: var(--radius-lg);
  }
  .stat-icon {
    width: 48px; height: 48px;
    font-size: 1.4rem;
    border-radius: var(--radius);
  }
  .stat-value { font-size: 1.6rem; }
  .stat-label { font-size: 0.8rem; }

  /* — Content Grid (table + sidebar) — */
  .content-grid {
    grid-template-columns: 1fr 360px;
    align-items: start;
    gap: 1.5rem;
  }

  /* — Switch to table view — */
  .mobile-cards { display: none; }
  .desktop-table { display: block; }

  /* — Section Header — */
  .section-header {
    padding: 1rem 1.25rem;
    flex-direction: row;
    align-items: center;
  }
  .section-title { font-size: 1rem; }
  .table-controls { width: auto; }
  .search-input {
    min-width: 200px;
    font-size: 0.85rem;
    height: auto;
  }
  .filter-select {
    font-size: 0.85rem;
    height: auto;
  }

  /* — Pagination — */
  .pagination { padding: 1rem; }
  .pagination .page-info {
    width: auto;
    order: 0;
    margin-bottom: 0;
  }

  /* — Modal (centered, not bottom sheet) — */
  .modal-overlay {
    padding: 1.5rem;
    align-items: center;
  }
  .modal {
    border-radius: var(--radius-xl);
    width: auto;
    max-height: 90vh;
    max-height: 90dvh;
    animation: modalIn 0.3s ease;
  }
  .modal-sm { max-width: 420px; }
  .modal-md { max-width: 560px; }
  .modal-lg { max-width: 800px; }
  .modal-xl { max-width: 1000px; }

  @keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
  }

  .modal-footer {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 1rem 1.5rem;
  }
  .modal-footer .btn { width: auto; }
  .modal-footer-centered {
    flex-direction: row;
    justify-content: center;
  }
  .modal-footer-centered .btn { width: auto; }

  /* — Form (2 columns) — */
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  .form-row-inline-3col {
    grid-column: 1 / -1;
  }
  .form-input, .form-select {
    font-size: 0.9rem;
    padding: 10px 14px;
  }

  /* — Detail Grid (3 columns on tablet, 4 on desktop) — */
  .detail-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.1rem;
  }
  .detail-card {
    padding: 1.1rem 1.1rem;
  }

  /* — Photo upload — */
  .photo-preview { max-width: 160px; }
  .photo-add-icon { font-size: 3rem; }

  /* — License Grid (2 cols) — */
  .license-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 1.25rem;
  }

  /* — Referrer — */
  .referrer-list { padding: 1.25rem; }

  /* — Detail Chat Records — */
  .detail-chat-records .chat-record-item {
    width: 140px;
    height: 186px;
  }

  /* — Toast — */
  .toast-container {
    right: 1rem;
    left: auto;
  }
  .toast { max-width: 400px; }

  /* — Chat Records Upload — */
  .chat-thumb-wrap { width: 72px; height: 72px; }
  .chat-add-btn { width: 72px; height: 72px; font-size: 1.5rem; }

  /* — Confirm Delete — */
  .confirm-icon { font-size: 3rem; }
}

/* ============================================================
   16. RESPONSIVE — DESKTOP (1024px+)
   ============================================================ */
@media (min-width: 1024px) {
  .header { padding: 0 2rem; }
  .main-content { padding: 2rem; }
  .header-actions .btn { font-size: 0.85rem; padding: 8px 16px; }

  .content-grid { grid-template-columns: 1fr 400px; }
  .form-grid { grid-template-columns: repeat(3, 1fr); }
  .form-row-inline-time,
  .form-row-inline-3col {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
  }
  .form-row-inline-time { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
  .detail-card { padding: 1.1rem 1.2rem; }
  .license-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-photo { flex: 1 1 280px; }
}

/* ============================================================
   17. RESPONSIVE — LARGE DESKTOP (1400px+)
   ============================================================ */
@media (min-width: 1400px) {
  .main-content { padding: 2.5rem 3rem; }
  .content-grid { grid-template-columns: 1fr 440px; }
}

/* ============================================================
   18. LICENSE RECEIVED — پىراۋا ئېلىپ بولغانلىق بەلگىسى
   ============================================================ */

/* Table column — پىراۋا بەلگىسى */
.license-received-badge {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
  flex-shrink: 0;
  transition: all var(--transition);
}
.license-received-badge:hover {
  background: #bbf7d0;
  transform: scale(1.05);
}

/* License mark button */
.action-btn-labeled.license-mark {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
}
.action-btn-labeled.license-mark:active {
  background: #f59e0b;
  color: #fff;
}
@media (hover: hover) {
  .action-btn-labeled.license-mark:hover {
    background: #f59e0b;
    color: #fff;
  }
}

/* Mobile card license badge */
.license-received-meta {
  color: #166534 !important;
  font-weight: 600;
}

/* License upload modal */
.license-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
}
.license-photo-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}
.license-photo-upload:hover {
  border-color: var(--primary);
}
.license-photo-preview {
  width: 100%;
  max-width: 200px;
  aspect-ratio: 4/3;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.license-photo-placeholder {
  font-size: 2rem;
  color: var(--text-muted);
}
.license-photo-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
}

/* Detail view — license section */
.detail-license-section {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}
.detail-license-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #166534;
  margin-bottom: 0.75rem;
  text-align: center;
}
.detail-license-section .detail-photo {
  margin-top: 0.5rem;
}

/* Lightbox title */
.lightbox-title {
  color: #fff;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

/* ============================================================
   v209: ئىنتايىن كىچىك ئېكرانلار ئۈچۈن (380px دىن كىچىك)
   form-row-inline نى بىر ئىستونغا ئۆزگەرتىش
   ============================================================ */
@media (max-width: 379px) {
  .form-row-inline,
  .form-row-inline-time,
  .form-row-inline-3col {
    grid-template-columns: 1fr;
  }
  .modal-body {
    padding: 1rem;
  }
  .form-input, .form-select {
    padding: 10px 12px;
    font-size: 16px; /* iOS zoom نىڭ ئالدىنى ئېلىش ئۈچۈن 16px دىن تۆۋەن بولماسلىقى كېرەك */
  }
}