/* ============================================
   KIOSKO VEGA — Design System
   Warm café aesthetic: cream, roasted coffee, leaf green, terracotta
   ============================================ */

:root {
  /* Base tones — warm cream, espresso — inspired by Kiosko Vega logo */
  --bg-cream: #F5EAD4;
  --bg-paper: #FBF4E2;
  --bg-card: #FFFFFF;
  --bg-sidebar: #2C1810;
  --bg-sidebar-hover: #3D2618;
  --bg-overlay: rgba(44, 24, 16, 0.55);

  /* Text */
  --ink-900: #2C1810;
  --ink-700: #4A2E1E;
  --ink-500: #8A6B56;
  --ink-400: #B09B84;
  --ink-300: #D4C3A8;
  --ink-on-dark: #FBF4E2;
  --ink-on-dark-dim: #C4B093;

  /* Brand — from logo: espresso browns, sunset orange, teal/turquoise, cream */
  --coffee-900: #3A1F10;
  --coffee-700: #5C3518;
  --coffee-500: #8B5028;
  --coffee-300: #D49565;
  --coffee-100: #F2DFC5;

  /* Teal from ocean/waves in logo */
  --teal-700: #1E6670;
  --teal-500: #3D9CA8;
  --teal-300: #8DC5CE;
  --teal-100: #D4EAEE;

  /* Sunset orange from logo backdrop */
  --sunset-700: #C4511A;
  --sunset-500: #E87A35;
  --sunset-300: #F2A970;
  --sunset-100: #FCE4C9;

  /* Kept leaf for categorical variety, but tuned toward palm green */
  --leaf-700: #3F5D3A;
  --leaf-500: #5C8255;
  --leaf-300: #9DB895;
  --leaf-100: #DCE6D8;

  --terra-700: #9A4A2E;
  --terra-500: #C56B45;
  --terra-300: #E4A07F;
  --terra-100: #F5D9C6;

  --gold-500: #D99333;
  --gold-100: #FBE3B8;

  /* Semantic */
  --success: #5C8255;
  --success-bg: #DCE6D8;
  --danger: #9A4A2E;
  --danger-bg: #F5D9C6;
  --warning: #D99333;
  --warning-bg: #FBE3B8;
  --info: #1E6670;
  --info-bg: #D4EAEE;

  /* Strokes */
  --line: #EADEC4;
  --line-strong: #D9C8A8;
  --line-dark: #3D2618;

  /* Shadows — soft & warm */
  --shadow-sm: 0 1px 2px rgba(62, 40, 23, 0.06), 0 1px 3px rgba(62, 40, 23, 0.04);
  --shadow-md: 0 4px 12px rgba(62, 40, 23, 0.08), 0 2px 4px rgba(62, 40, 23, 0.05);
  --shadow-lg: 0 12px 32px rgba(62, 40, 23, 0.12), 0 4px 8px rgba(62, 40, 23, 0.06);
  --shadow-xl: 0 24px 48px rgba(62, 40, 23, 0.18);

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* Type */
  --font-display: 'Fraunces', 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink-900);
  background: var(--bg-cream);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  color: inherit;
}

/* ----- Typography helpers ----- */
.t-display { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.02em; }
.t-mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.t-tnum { font-variant-numeric: tabular-nums; }

/* ----- App layout ----- */
.app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.sidebar {
  width: 244px;
  background: var(--bg-sidebar);
  color: var(--ink-on-dark);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 99px; }
.sidebar-footer { flex-shrink: 0; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  border-bottom: 1px solid var(--line-dark);
  margin-bottom: 14px;
}

.sidebar-logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--coffee-500), var(--coffee-300));
  display: grid;
  place-items: center;
  color: var(--bg-cream);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.sidebar-logo-text .name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.sidebar-logo-text .tag {
  font-size: 11px;
  color: var(--ink-on-dark-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-on-dark-dim);
  padding: 14px 10px 6px;
  font-weight: 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--ink-on-dark-dim);
  font-size: 13.5px;
  font-weight: 450;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: var(--ink-on-dark); }
.nav-item.active {
  background: var(--bg-sidebar-hover);
  color: var(--ink-on-dark);
  box-shadow: inset 3px 0 0 var(--coffee-300);
}
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--r-full);
  background: var(--coffee-500);
  color: var(--bg-cream);
  font-weight: 500;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line-dark);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 4px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--terra-500), var(--gold-500));
  display: grid;
  place-items: center;
  color: var(--bg-cream);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.sidebar-footer .who { font-size: 13px; line-height: 1.2; }
.sidebar-footer .who .role { font-size: 11px; color: var(--ink-on-dark-dim); }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(251, 247, 238, 0.92);
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.015em;
  flex: 1;
}
.topbar-title .sub {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-500);
  letter-spacing: 0;
  margin-top: 2px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.content {
  padding: 28px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary {
  background: var(--coffee-700);
  color: var(--bg-cream);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--coffee-900); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--ink-900);
  border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--bg-paper); border-color: var(--ink-400); }

.btn-ghost {
  background: transparent;
  color: var(--ink-700);
}
.btn-ghost:hover { background: var(--coffee-100); color: var(--ink-900); }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 12px 18px; font-size: 14px; }
.btn-icon { padding: 8px; border-radius: var(--r-sm); }

/* ----- Cards ----- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.card-header .sub {
  font-size: 12px;
  color: var(--ink-500);
  margin-top: 2px;
}
.card-body { padding: 20px; }

/* ----- Inputs ----- */
.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  font-size: 13.5px;
  transition: all 0.15s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--coffee-500);
  box-shadow: 0 0 0 3px var(--coffee-100);
}
.label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-700);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 12px; }
.field-row.cols-2 { grid-template-columns: 1fr 1fr; }
.field-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ----- Tags / Pills ----- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 500;
  background: var(--coffee-100);
  color: var(--coffee-700);
  letter-spacing: 0.01em;
}
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-warn { background: var(--warning-bg); color: var(--warning); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-leaf { background: var(--leaf-100); color: var(--leaf-700); }
.pill-ghost { background: transparent; color: var(--ink-500); border: 1px solid var(--line-strong); }

.pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

/* ----- Table ----- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  border-bottom: 1px solid var(--line);
  background: var(--bg-paper);
}
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-paper); }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }

/* ----- Metric card ----- */
.metric {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.metric-label {
  font-size: 12px;
  color: var(--ink-500);
  font-weight: 500;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-top: 6px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.metric-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  margin-top: 8px;
  font-weight: 500;
}
.metric-delta.up { color: var(--success); }
.metric-delta.down { color: var(--danger); }
.metric .spark {
  position: absolute;
  right: 0; bottom: 0;
  width: 100px;
  height: 40px;
  opacity: 0.5;
}

/* ----- Scrollbars ----- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid var(--bg-cream); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

/* ----- Toast ----- */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--bg-sidebar);
  color: var(--ink-on-dark);
  padding: 12px 16px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  animation: toastIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  border-left: 3px solid var(--leaf-500);
}
.toast .toast-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--leaf-500);
  display: grid; place-items: center;
  color: white;
  flex-shrink: 0;
}
.toast .t-title { font-size: 13px; font-weight: 600; }
.toast .t-body { font-size: 12px; color: var(--ink-on-dark-dim); margin-top: 2px; }
.toast .t-amount { font-family: var(--font-display); font-size: 18px; margin-left: auto; font-variant-numeric: tabular-nums; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ----- Modal ----- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}
.modal-lg { max-width: 960px; }
.modal-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.modal-header { flex-shrink: 0; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-footer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-paper);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ----- Upload dropzone ----- */
.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-lg);
  padding: 40px 24px;
  text-align: center;
  background: var(--bg-paper);
  transition: all 0.2s ease;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--coffee-500); background: var(--coffee-100); }
.dropzone.active { border-color: var(--coffee-700); background: var(--coffee-100); }

/* ----- Segmented control ----- */
.segmented {
  display: inline-flex;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}
.segmented button {
  padding: 6px 12px;
  border-radius: calc(var(--r-sm) - 3px);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-500);
  transition: all 0.15s ease;
}
.segmented button.active {
  background: var(--bg-card);
  color: var(--ink-900);
  box-shadow: var(--shadow-sm);
}

/* ----- AI Chat ----- */
.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}
.chat-bubble.user {
  background: var(--coffee-700);
  color: var(--ink-on-dark);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.chat-bubble.ai {
  background: var(--bg-paper);
  color: var(--ink-900);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

/* Pulse for live indicators */
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--leaf-500);
  position: relative;
  display: inline-block;
}
.live-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--leaf-500);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.8); opacity: 0; }
}

/* Mobile */
.mobile-nav { display: none; }
.sidebar-mobile-toggle { display: none; }
.mobile-tabbar { display: none; }
html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }

@media (max-width: 860px) {
  :root { --tabbar-h: 62px; }
  body { -webkit-tap-highlight-color: transparent; }
  .app { min-height: 100dvh; }
  .sidebar {
    position: fixed; left: -290px; top: 0; bottom: 0; z-index: 60;
    width: min(280px, 82vw); height: 100dvh; overflow-y: auto;
    padding-top: calc(env(safe-area-inset-top) + 16px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
    transition: left 0.25s ease;
  }
  .sidebar.open { left: 0; box-shadow: var(--shadow-xl); }
  .sidebar .nav-item { min-height: 46px; font-size: 15px; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: var(--bg-overlay); z-index: 55; }
  .sidebar-backdrop.show { display: block; }
  .sidebar-mobile-toggle { display: none; }

  .topbar { padding: calc(env(safe-area-inset-top) + 8px) 14px 8px; gap: 8px; }
  .topbar-title { font-size: 19px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-title .sub { display: none; }
  .topbar-actions { gap: 2px; }
  .topbar-lang button { padding: 6px 9px; font-size: 12px; }
  .notif-pop { position: fixed !important; left: 10px !important; right: 10px !important; width: auto !important; top: calc(env(safe-area-inset-top) + 58px) !important; max-height: 70dvh !important; }

  .content { padding: 14px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 20px); }
  .content > .col.gap-6 { gap: 16px; }

  /* Bottom tab bar */
  .mobile-tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 4px 6px env(safe-area-inset-bottom);
    background: rgba(251, 247, 238, 0.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .mobile-tab { appearance: none; border: 0; background: transparent; font: inherit; color: var(--ink-500); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; cursor: pointer; }
  .mobile-tab-icon { position: relative; display: grid; place-items: center; width: 44px; height: 30px; border-radius: 15px; transition: background .15s ease; }
  .mobile-tab-label { font-size: 11px; font-weight: 500; letter-spacing: .01em; }
  .mobile-tab.active { color: var(--coffee-900); }
  .mobile-tab.active .mobile-tab-icon { background: var(--coffee-100); }
  .mobile-tab.active .mobile-tab-label { font-weight: 700; }
  .mobile-tab.primary .mobile-tab-icon { background: var(--coffee-700); color: var(--bg-cream); width: 48px; height: 34px; border-radius: 17px; box-shadow: var(--shadow-md); }
  .mobile-tab.primary.active .mobile-tab-icon { background: var(--coffee-900); }
  .mobile-tab-badge { position: absolute; top: -3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--sunset-500, var(--gold-500)); color: white; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

  /* Touch targets + no iOS zoom on focus */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; padding: 7px 12px; font-size: 13px; }
  .btn-icon { min-width: 44px; min-height: 44px; justify-content: center; }
  .btn-icon.btn-sm { min-width: 38px; min-height: 38px; }
  .input, .textarea, .select { font-size: 16px !important; min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .segmented button { min-height: 36px; }
  .field-row.cols-2, .field-row.cols-3 { grid-template-columns: 1fr; }

  /* Cards */
  .card-header { padding: 14px 14px; flex-wrap: wrap; }
  .card-body { padding: 14px; }
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Grids: single column; stat grids stay 2-up */
  .metric { min-width: 0; padding: 14px; }
  .metric-value { font-size: 21px !important; }
  .grid { grid-template-columns: minmax(0, 1fr) !important; }
  .grid.cols-2-mobile, .grid:has(> .metric) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; gap: 10px !important; }

  /* Tables */
  .table { table-layout: auto; width: 100%; }
  .table td, .table th { white-space: normal; padding: 11px 10px; font-size: 13px; }
  .table th { font-size: 10.5px; }
  .table td.num, .table th.num { white-space: nowrap; }
  .table tr:hover td { background: transparent; }
  .table .hide-mobile-col { display: none; }
  .upcoming-label { word-break: break-word; font-size: 12.5px; line-height: 1.3; }

  /* Modals as bottom sheets */
  .modal-backdrop { padding: 0; align-items: end; place-items: end stretch; }
  .modal { max-width: 100% !important; width: 100%; border-radius: 20px 20px 0 0; max-height: calc(100dvh - env(safe-area-inset-top) - 24px); display: flex; flex-direction: column; animation: sheetIn .28s cubic-bezier(.2,.9,.3,1); }
  .modal::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 8px auto 0; flex-shrink: 0; }
  .modal-header { padding: 10px 16px 12px; }
  .modal-body { padding: 16px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
  .modal-footer { padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px); position: sticky; bottom: 0; background: var(--bg-card); flex-wrap: wrap; }
  .modal-footer > .btn, .modal-footer > .row > .btn { flex: 1; }

  /* Charts */
  .chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chart-scroll > svg { min-width: 320px; }

  /* Attendance calendar compact */
  .att-grid { min-width: 0 !important; grid-template-columns: repeat(7, minmax(0, 1fr)) !important; gap: 3px !important; }
  .att-cell { min-height: 64px !important; padding: 4px 3px 5px !important; border-radius: 8px !important; gap: 2px !important; }
  .att-chip { font-size: 9.5px !important; padding: 2px 3px !important; border-radius: 4px !important; justify-content: center !important; }
  .att-chip .att-name { display: none; }
  .att-chip .att-ini { display: inline !important; }
  .att-wrap { padding: 0 8px 12px !important; overflow: visible !important; }
}
@media (max-width: 860px) { .kv-toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px) !important; max-width: calc(100vw - 24px); } }
@keyframes sheetIn { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* Utility */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }
.grid { display: grid; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 12.5px; } .text-xs { font-size: 11.5px; }
.text-muted { color: var(--ink-500); }
.text-strong { color: var(--ink-900); font-weight: 600; }
.center { display: grid; place-items: center; }
.hide-mobile { display: initial; }
.show-mobile { display: none; }
@media (max-width: 860px) {
  .hide-mobile { display: none; }
  .show-mobile { display: initial; }
}

@keyframes kvspin{to{transform:rotate(360deg)}}
@media (max-width: 860px) {
  .modal-backdrop { z-index: 100 !important; }
  body:has(.modal-backdrop) .mobile-tabbar { display: none !important; }
  .modal { max-height: calc(100dvh - env(safe-area-inset-top) - 12px) !important; }
}
