:root {
  --p: #432874;
  --p-dark: #2a1948;
  --v: #7851b5;
  --g: #087f5b;
  --g-dark: #06694b;
  --ink: #241a39;
  --muted: #635b70;
  --line: #e2dceb;
  --bg: #f7f5fa;
  --lav: #e9ddf8;
  --mint: #d1fae5;
  --mint-ink: #095c43;
  --blue: #cfe2ff;
  --blue-ink: #174488;
  --pink: #f5d0e8;
  --pink-ink: #7a1959;
  --amber: #fef3c7;
  --amber-ink: #92400e;
  --red: #fee2e2;
  --red-ink: #991b1b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

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

/* Desktop Sidebar */
.sidebar {
  display: none;
  width: 260px;
  background: var(--p);
  color: #fff;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  box-shadow: 4px 0 24px rgba(42, 25, 72, 0.16);
}
.brand { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.12); display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 38px; height: 38px; border-radius: 12px; background: var(--g); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.brand h1 { margin: 0; font-size: 15px; line-height: 1.2; }
.brand span { font-size: 11px; color: var(--lav); }

.nav-list { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 14px; border-radius: 12px; border: 0;
  background: transparent; color: var(--lav); font-weight: 600; font-size: 14px; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-btn.active { background: #fff; color: var(--p); }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,0.12); display: flex; flex-direction: column; gap: 10px; font-size: 12px; }
.param-box { background: var(--p-dark); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.param-row { display: flex; justify-content: space-between; color: var(--lav); }
.param-row strong { color: #fff; }

/* Main Column */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
}
.row-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.stepper { display: inline-flex; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 2px; }
.stepper button { border: 0; background: transparent; padding: 6px 10px; border-radius: 9px; font-weight: 700; color: var(--p); }
.stepper button:hover { background: #fff; }
.stepper span { padding: 0 8px; font-size: 13px; font-weight: 700; color: var(--p); }

.select, .input, .textarea {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 12px; font-size: 13px; font-weight: 600;
}
.select-bg { background: var(--bg); }
.input, .textarea { font-weight: 500; width: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 12px; border: 1px solid transparent;
  font-size: 13px; font-weight: 700; text-decoration: none; transition: 0.15s;
}
.btn-primary { background: var(--p); color: #fff; }
.btn-primary:hover { background: #351f5e; }
.btn-emerald { background: var(--g); color: #fff; }
.btn-emerald:hover { background: var(--g-dark); }
.btn-soft { background: var(--bg); color: var(--p); border-color: var(--line); }
.btn-soft:hover { background: var(--lav); }
.btn-mint { background: var(--mint); color: var(--mint-ink); border-color: #a7f3d0; }
.btn-danger { background: var(--red); color: var(--red-ink); border-color: #fecaca; }

/* APK Download Hero Strip */
.apk-banner {
  background: linear-gradient(135deg, var(--p), var(--p-dark));
  color: #fff; border-radius: 18px; padding: 16px 20px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  box-shadow: 0 10px 25px rgba(67, 40, 116, 0.18);
  margin-bottom: 18px;
}
.apk-banner h3 { margin: 0 0 4px; font-size: 16px; }
.apk-banner p { margin: 0; font-size: 12px; color: var(--lav); }

.content { max-width: 1280px; width: 100%; margin: 0 auto; padding: 18px 16px 90px; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--g); margin: 0 0 4px; }
.page-title { font-size: 22px; font-weight: 800; margin: 0 0 14px; letter-spacing: -0.02em; }

/* Grids & Cards */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.kpi-label { font-size: 11px; font-weight: 700; color: var(--muted); }
.kpi-val { font-size: 22px; font-weight: 800; margin-top: 4px; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; font-size: 12px; }
.pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; border: 1px solid transparent; }
.pill-T, .cell-T { background: var(--mint); color: var(--mint-ink); border-color: #a7f3d0; }
.pill-F, .cell-F { background: var(--lav); color: var(--p); border-color: #d6c2f2; }
.pill-FE, .cell-FE { background: var(--blue); color: var(--blue-ink); border-color: #b3d1ff; }
.pill-AF, .cell-AF { background: var(--pink); color: var(--pink-ink); border-color: #eab6d8; }
.pill-empty, .cell-empty { background: #f4f1f8; color: #8c8499; border-color: var(--line); }
.pill-ok { background: var(--mint); color: var(--mint-ink); }
.pill-warn { background: var(--amber); color: var(--amber-ink); }
.pill-bad { background: var(--red); color: var(--red-ink); }

.cards-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.cal-7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { text-align: center; font-size: 10px; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.cal-day {
  height: 40px; border-radius: 10px; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; line-height: 1.05;
}
.cal-day small { font-size: 9px; opacity: 0.75; }
.cal-day span { font-size: 12px; }
.cal-day.tap { height: 48px; }
.cal-day.tap:active { transform: scale(0.95); }

/* Tables */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; margin-bottom: 16px; }
.table-scroll { overflow-x: auto; }
table.matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
table.matrix th { background: var(--p); color: #fff; padding: 9px 6px; font-weight: 700; white-space: nowrap; border-right: 1px solid rgba(255,255,255,0.12); }
table.matrix th.wknd { background: #361f60; }
table.matrix td { padding: 6px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
table.matrix td.sticky-col, table.matrix th.sticky-col { position: sticky; left: 0; z-index: 5; text-align: left; padding-left: 12px; min-width: 150px; }
table.matrix td.sticky-col { background: #fff; border-right: 1px solid var(--line); font-weight: 700; }
.code-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid transparent; font-weight: 800; font-size: 11px; }

/* Mobile Bottom Nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255,255,255,0.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px max(8px, env(safe-area-inset-bottom));
}
.bnav-btn {
  border: 0; background: transparent; display: flex; flex-direction: column;
  align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted);
}
.bnav-btn.active { color: var(--p); }
.bnav-pill { padding: 3px 12px; border-radius: 999px; }
.bnav-btn.active .bnav-pill { background: var(--lav); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
.modal-card {
  background: #fff; width: 100%; max-width: 520px; border-radius: 22px 22px 0 0;
  padding: 20px; max-height: 90vh; overflow-y: auto;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.field label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }

.toast {
  position: fixed; bottom: 80px; right: 16px; z-index: 60;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 13px; font-weight: 600; box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.desktop-only { display: none; }
.mobile-only { display: block; }

@media (min-width: 960px) {
  .sidebar { display: flex; }
  .main-col { padding-left: 260px; }
  .bottom-nav { display: none; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 24px 26px 40px; }
  .desktop-only { display: block; }
  .mobile-only { display: none; }
  .modal-backdrop { align-items: center; padding: 16px; }
  .modal-card { border-radius: 20px; }
  .toast { bottom: 24px; }
}

@media print {
  @page { size: landscape; margin: 10mm; }
  .no-print, .sidebar, .topbar, .bottom-nav, .apk-banner { display: none !important; }
  .main-col { padding-left: 0 !important; }
  body { background: #fff !important; }
}

