/* =========================================================
   Jumbo · Reportes de Seguridad
   ========================================================= */
@font-face {
  font-family: 'Manrope';
  src: url('fonts/manrope-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --green: #00a651;
  --green-600: #009247;
  --green-700: #007a3d;
  --green-800: #006633;
  --green-50: #eaf7ef;
  --green-100: #d3efdf;
  --yellow: #ffd100;
  --yellow-soft: #fff7cc;
  --ink: #14251b;
  --ink-2: #2e3d34;
  --muted: #6b7a70;
  --muted-2: #8b978f;
  --line: #e3e8e2;
  --line-2: #eef1ec;
  --bg: #f4f6f1;
  --card: #ffffff;
  --red: #c62828;
  --red-soft: #fdecea;
  --amber: #b25b00;
  --amber-soft: #fff1df;
  --blue: #1f5fbf;
  --blue-soft: #e8f0fd;
  --teal: #0f766e;
  --teal-soft: #e6f5f2;
  --crimson: #9f1239;
  --crimson-soft: #fce8ee;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(20, 37, 27, .04), 0 4px 14px rgba(20, 37, 27, .04);
  --shadow-md: 0 10px 30px rgba(20, 37, 27, .09);
  --shadow-lg: 0 24px 60px rgba(20, 37, 27, .16);
  --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(0, 166, 81, .07), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(255, 209, 0, .10), transparent 55%);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid rgba(0, 166, 81, .35); outline-offset: 2px; border-radius: 6px; }

/* ---------- Buttons / fields ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -.01em;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green-700); color: #fff; box-shadow: 0 6px 16px rgba(0, 122, 61, .22); }
.btn-primary:hover { background: var(--green-800); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: #c9d4ca; background: #fbfcfa; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #0b1510; }
.btn-small { height: 34px; padding: 0 13px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; height: 46px; font-size: 14.5px; }
.btn-label { position: relative; }
.btn .spinner { display: none; width: 17px; height: 17px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn.is-loading .btn-label { opacity: .5; }
.btn.is-loading .spinner { display: block; position: absolute; }
.link-btn { font-size: 12.5px; font-weight: 700; color: var(--green-700); }
.link-btn:hover { text-decoration: underline; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 7px; }
.field-control { position: relative; display: flex; align-items: center; }
.field-control input {
  width: 100%;
  height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #fbfcfa;
  padding: 0 44px 0 42px;
  font-size: 14px;
  font-weight: 500;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.field-control input::placeholder { color: #a2ada5; }
.field-control input:focus { outline: 0; border-color: var(--green); background: #fff; box-shadow: 0 0 0 4px rgba(0,166,81,.10); }
.field-icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted-2); pointer-events: none; }
.field-action { position: absolute; right: 8px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.field-action:hover { background: var(--green-50); color: var(--green-700); }
.field-action svg { width: 18px; height: 18px; }
.check-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--muted); margin: 2px 0 18px; cursor: pointer; user-select: none; }
.check-row input { width: 16px; height: 16px; accent-color: var(--green-700); }
.form-error { background: var(--red-soft); color: var(--red); border: 1px solid #f6cdc9; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 14px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.06fr .94fr; background: #fff; }
.login-hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  padding: 46px 52px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(145deg, #006633 0%, #008a47 46%, #00a651 100%);
}
.hero-shapes { position: absolute; inset: 0; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(1px); }
.blob-a { width: 520px; height: 520px; right: -180px; top: -190px; background: radial-gradient(circle at 35% 35%, rgba(255,209,0,.34), rgba(255,209,0,0) 66%); }
.blob-b { width: 440px; height: 440px; left: -200px; bottom: -180px; background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.14), rgba(255,255,255,0) 68%); }
.ring { position: absolute; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; }
.ring-a { width: 380px; height: 380px; right: -80px; bottom: 40px; }
.ring-b { width: 560px; height: 560px; right: -170px; bottom: -60px; border-color: rgba(255,209,0,.20); }
.login-brand { position: relative; display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--green), var(--green-700));
  color: #fff;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -.06em;
  position: relative;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.10);
  flex: none;
}
.brand-mark::after {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  right: 6px; bottom: 6px;
  box-shadow: 0 0 0 2px rgba(0,0,0,.06);
}
.brand-mark-light { background: #fff; color: var(--green-700); box-shadow: none; }
.brand-mark-light::after { background: var(--yellow); box-shadow: none; }
.brand-word { font-size: 24px; font-weight: 800; letter-spacing: -.055em; line-height: .95; color: var(--green-700); }
.brand-word-light { color: #fff; font-size: 26px; }
.brand-sub { font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.brand-sub-light { color: rgba(255,255,255,.72); }
.hero-copy { position: relative; margin-top: auto; margin-bottom: auto; padding: 44px 0 30px; max-width: 590px; }
.hero-kicker { font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--yellow); margin-bottom: 18px; }
.hero-copy h1 { font-size: clamp(34px, 4vw, 52px); line-height: 1.04; font-weight: 800; letter-spacing: -.045em; }
.hero-copy h1 span { color: var(--yellow); }
.hero-text { margin-top: 20px; max-width: 460px; font-size: 15px; line-height: 1.65; color: rgba(255,255,255,.80); font-weight: 500; }
.hero-list { list-style: none; margin: 30px 0 0; padding: 0; display: grid; gap: 13px; }
.hero-list li { display: flex; align-items: center; gap: 11px; font-size: 13.5px; font-weight: 600; color: rgba(255,255,255,.92); }
.hero-check { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); flex: none; }
.hero-check svg { width: 13px; height: 13px; stroke-width: 2.4; color: var(--yellow); }
.hero-foot { position: relative; display: flex; align-items: center; gap: 12px; font-size: 11px; letter-spacing: .02em; color: rgba(255,255,255,.55); font-weight: 600; }
.hero-dot { width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,.35); }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 36px 28px; background: #fff; }
.login-card { width: 100%; max-width: 392px; }
.login-heading { margin-bottom: 28px; }
.login-eyebrow { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; color: var(--green-700); background: var(--green-50); padding: 6px 10px; border-radius: 999px; margin-bottom: 15px; }
.login-heading h2 { font-size: 30px; font-weight: 800; letter-spacing: -.04em; }
.login-heading p { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.login-help { display: flex; gap: 9px; align-items: flex-start; margin-top: 22px; font-size: 11.5px; line-height: 1.55; color: var(--muted-2); }
.login-help svg { width: 15px; height: 15px; margin-top: 1px; color: var(--muted-2); }
.login-legal { margin-top: 36px; font-size: 11px; color: #a7b1aa; }

/* ---------- App shell ---------- */
.topbar { position: sticky; top: 0; z-index: 60; background: rgba(255,255,255,.92); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1440px; margin: 0 auto; height: 74px; padding: 0 30px; display: flex; align-items: center; gap: 26px; }
.brand { display: flex; align-items: center; gap: 11px; flex: none; }
.brand-copy { display: flex; flex-direction: column; }
.brand .brand-word { font-size: 21px; }
.brand .brand-sub { font-size: 8.5px; letter-spacing: .12em; margin-top: 3px; }
.topnav { display: flex; align-items: center; gap: 4px; margin-left: 12px; }
.nav-item { height: 36px; padding: 0 14px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--muted); }
.nav-item.active { background: var(--green-50); color: var(--green-700); }
.nav-item:hover { color: var(--ink); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.update-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; color: var(--muted); background: #f7f9f5; border: 1px solid var(--line-2); padding: 7px 11px; border-radius: 999px; white-space: nowrap; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(0,166,81,.12); animation: pulse 2.4s ease-in-out infinite; }
.user-menu { position: relative; }
.user-button { display: flex; align-items: center; gap: 10px; padding: 5px 7px 5px 5px; border-radius: 12px; border: 1px solid transparent; }
.user-button:hover, .user-button[aria-expanded="true"] { background: #f7f9f5; border-color: var(--line-2); }
.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--green-50); color: var(--green-700); font-weight: 800; font-size: 14px; flex: none; }
.avatar-lg { width: 44px; height: 44px; border-radius: 13px; font-size: 17px; }
.user-data { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.user-name { font-size: 12.5px; font-weight: 800; }
.user-role { font-size: 10.5px; color: var(--muted); text-transform: capitalize; }
.user-button .chev { width: 15px; height: 15px; color: var(--muted); }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 10px); width: 270px; background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow-md); padding: 8px; z-index: 80; animation: pop .16s ease; }
.dropdown-head { display: flex; gap: 11px; align-items: center; padding: 10px 10px 13px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; }
.dropdown-head strong { display: block; font-size: 13px; }
.dropdown-head span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.dropdown-item { width: 100%; display: flex; align-items: center; gap: 10px; height: 39px; padding: 0 10px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--muted); }
.dropdown-item:hover { background: #f6f8f4; }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger svg { color: var(--red); }
.dropdown-item.danger:hover { background: var(--red-soft); }
.loading-bar { position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; background: linear-gradient(90deg, var(--green), var(--yellow)); transition: width .25s ease; }
.topbar.is-loading .loading-bar { width: 100%; animation: loading 1.4s ease-in-out infinite; }

/* ---------- Filters ---------- */
.filters-wrap { position: sticky; top: 74px; z-index: 50; padding: 14px 30px 0; background: linear-gradient(180deg, rgba(244,246,241,.96), rgba(244,246,241,.78) 70%, rgba(244,246,241,0)); }
.filters { max-width: 1380px; margin: 0 auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 9px 10px; box-shadow: var(--shadow-sm); }
.mode-tabs { display: flex; background: #f1f4ee; border-radius: 10px; padding: 3px; gap: 2px; }
.mode-tab { height: 34px; padding: 0 12px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; transition: all .16s ease; }
.mode-tab:hover { color: var(--ink); }
.mode-tab.active { background: #fff; color: var(--green-700); box-shadow: 0 1px 4px rgba(20,37,27,.10); }
.period-block { display: flex; align-items: center; gap: 7px; }
.current-week { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.mini-icon { width: 15px; height: 15px; color: var(--green-700); }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .02em; white-space: nowrap; }
.tag-soft { background: #f3f5f1; color: var(--muted); }
.tag-green { background: var(--green-50); color: var(--green-700); }
.tag-yellow { background: var(--yellow-soft); color: #7a5b00; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-2); background: #fff; transition: all .16s ease; flex: none; }
.icon-btn:hover { border-color: #c8d4c9; background: #fbfcfa; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn svg { width: 17px; height: 17px; }
.refresh-btn { margin-left: auto; }
.refresh-btn.is-spinning svg { animation: spin .9s linear infinite; }
.select-wrap { position: relative; }
.select-wrap select { height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0 32px 0 11px; font-size: 12.5px; font-weight: 700; appearance: none; cursor: pointer; color: var(--ink-2); }
.select-wrap select:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px rgba(0,166,81,.10); }
.week-select select { min-width: 176px; }
.select-chev { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--muted); pointer-events: none; }
.date-field { display: flex; align-items: center; gap: 8px; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: #fff; }
.date-field span { font-size: 10.5px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.date-field input { border: 0; background: transparent; font-size: 12px; font-weight: 700; color: var(--ink-2); outline: 0; width: 118px; }
.range-sep { width: 10px; height: 1px; background: var(--line); }
.locals-wrap { position: relative; }
.locals-button { height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 12.5px; font-weight: 700; color: var(--ink-2); max-width: 270px; }
.locals-button:hover { border-color: #c8d4c9; }
.locals-button #localsLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.locals-button .chev { width: 14px; height: 14px; color: var(--muted); margin-left: 2px; }
.count-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--green-700); color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.locals-popover { position: absolute; right: 0; top: calc(100% + 8px); width: 330px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-md); z-index: 90; animation: pop .16s ease; overflow: hidden; }
.popover-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px 10px; border-bottom: 1px solid var(--line-2); }
.popover-head strong { font-size: 12.5px; }
.locals-list { max-height: 300px; overflow: auto; padding: 6px; }
.local-option { display: flex; align-items: center; gap: 10px; padding: 9px 9px; border-radius: 8px; cursor: pointer; transition: background .12s ease; }
.local-option:hover { background: #f6f8f4; }
.local-option input { width: 16px; height: 16px; accent-color: var(--green-700); flex: none; }
.local-option .local-name { font-size: 12.5px; font-weight: 600; flex: 1; }
.local-option .tag { height: 18px; font-size: 9px; }
.popover-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line-2); background: #fbfcfa; }
.popover-foot span { font-size: 10.5px; color: var(--muted); }

/* ---------- Content ---------- */
.content { max-width: 1380px; margin: 0 auto; padding: 26px 30px 44px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--green-700); margin-bottom: 8px; }
.page-head h1 { font-size: clamp(24px, 2.6vw, 32px); font-weight: 800; letter-spacing: -.04em; line-height: 1.1; }
.page-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 9px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.meta-sep { width: 4px; height: 4px; border-radius: 50%; background: #c3ccc5; }
.page-actions { display: flex; gap: 8px; flex: none; }
.page-actions .btn { height: 38px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.kpi-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 19px 19px 16px;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  animation: fadeUp .4s ease both;
}
.kpi-card::before { content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 3px; background: var(--accent, var(--green)); opacity: .9; }
.kpi-card::after { content: ''; position: absolute; right: -46px; top: -54px; width: 150px; height: 150px; border-radius: 50%; background: var(--accent-soft, var(--green-50)); opacity: .55; pointer-events: none; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #d5ded6; }
.kpi-card:active { transform: translateY(0); }
.kpi-card[data-tone="ln"] { --accent: var(--red); --accent-soft: var(--red-soft); }
.kpi-card[data-tone="enc"] { --accent: var(--amber); --accent-soft: var(--amber-soft); }
.kpi-card[data-tone="ppu"] { --accent: var(--blue); --accent-soft: var(--blue-soft); }
.kpi-card[data-tone="prev"] { --accent: var(--teal); --accent-soft: var(--teal-soft); }
.kpi-card[data-tone="del"] { --accent: var(--crimson); --accent-soft: var(--crimson-soft); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; position: relative; z-index: 1; }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft, var(--green-50)); color: var(--accent, var(--green-700)); }
.kpi-icon svg { width: 20px; height: 20px; }
.kpi-open { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: #b2bdb5; transition: all .18s ease; }
.kpi-open svg { width: 16px; height: 16px; }
.kpi-card:hover .kpi-open { background: var(--accent-soft, var(--green-50)); color: var(--accent, var(--green-700)); transform: translate(1px, -1px); }
.kpi-label { position: relative; z-index: 1; margin-top: 14px; font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: -.01em; }
.kpi-value-row { position: relative; z-index: 1; display: flex; align-items: flex-end; gap: 10px; margin-top: 6px; }
.kpi-value { font-size: 32px; font-weight: 800; letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 11px; font-weight: 700; color: var(--muted-2); margin-bottom: 3px; }
.kpi-bottom { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 13px; }
.delta { display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 8px 0 6px; border-radius: 999px; font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta svg { width: 13px; height: 13px; stroke-width: 2.2; }
.delta.good { background: var(--green-50); color: #087a42; }
.delta.bad { background: var(--red-soft); color: var(--red); }
.delta.flat { background: #f3f5f1; color: var(--muted); }
.delta.na { background: #f7f8f6; color: var(--muted-2); font-weight: 700; }
.kpi-compare { font-size: 10.5px; font-weight: 600; color: var(--muted-2); }
.kpi-compare strong { color: var(--muted); font-weight: 800; }
.kpi-coverage { margin-top: 6px; font-size: 10px; color: #9aa59d; position: relative; z-index: 1; }

/* Skeleton */
.skeleton { pointer-events: none; }
.skeleton::before { display: none; }
.skeleton::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, #f7f8f5 20%, #eef1ec 38%, #f7f8f5 56%); background-size: 200% 100%; animation: shimmer 1.5s linear infinite; border-radius: inherit; opacity: 1; }
.skeleton > * { visibility: hidden; }

/* ---------- Panels ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.chart-panel { margin-top: 16px; padding: 20px 22px 16px; animation: fadeUp .45s .06s ease both; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-title-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15.5px; font-weight: 800; letter-spacing: -.025em; }
.panel-sub { margin-top: 5px; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.chart-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 36px; height: 21px; border-radius: 999px; background: #dfe5df; position: relative; transition: background .18s ease; flex: none; }
.switch-thumb { position: absolute; width: 15px; height: 15px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .18s ease; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(15px); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(0,166,81,.35); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .4; }
.switch input:disabled ~ .switch-label { opacity: .5; }
.switch-label { font-size: 11.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.chart-legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 0 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; color: var(--muted); cursor: pointer; user-select: none; }
.legend-item.is-off { opacity: .38; }
.legend-line { width: 20px; height: 3px; border-radius: 2px; background: var(--c, var(--green)); position: relative; }
.legend-line.dashed { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); height: 2px; }
.legend-item .legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.legend-sep { width: 1px; height: 16px; background: var(--line); }
.legend-caption { font-size: 10px; color: var(--muted-2); font-weight: 600; }
.chart-wrap { position: relative; height: 330px; margin-top: 4px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.chart-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); background: rgba(255,255,255,.72); border-radius: 12px; }
.chart-empty svg { width: 26px; height: 26px; color: var(--muted-2); }
.chart-empty p { font-size: 12.5px; font-weight: 600; }
.chart-foot { margin-top: 8px; font-size: 10px; color: var(--muted-2); }

.lower-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; margin-top: 16px; }
.locals-panel, .insights-panel { padding: 20px 22px 16px; animation: fadeUp .45s .12s ease both; }
.table-scroll { width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted-2); text-align: left; padding: 12px 10px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); font-size: 12.5px; vertical-align: middle; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr:hover { background: #fafbf8; }
.data-table tbody tr.is-clickable { cursor: pointer; }
.data-table tbody tr.is-active { background: var(--green-50); }
.data-table tbody tr.is-active td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.locals-table td:first-child { font-weight: 700; }
.local-cell { display: flex; align-items: center; gap: 8px; }
.local-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.local-cell .tag { height: 17px; font-size: 8.5px; }
.locals-table tfoot td { padding: 12px 10px; font-size: 12px; font-weight: 800; border-top: 1px solid var(--line); border-bottom: 0; background: #fbfcfa; }
.locals-table tfoot td:first-child { border-radius: 0 0 0 10px; }
.locals-table tfoot td:last-child { border-radius: 0 0 10px 0; }
.table-note { margin-top: 10px; font-size: 10.5px; color: var(--muted-2); line-height: 1.5; }

.insight-list { display: grid; gap: 8px; margin-top: 16px; }
.insight { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border: 1px solid var(--line-2); border-radius: 12px; background: #fcfdfb; }
.insight-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--green-50); color: var(--green-700); flex: none; }
.insight-icon svg { width: 16px; height: 16px; }
.insight-body { flex: 1; min-width: 0; }
.insight-label { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.insight-sub { font-size: 10px; color: var(--muted-2); margin-top: 2px; }
.insight-value { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.insight-value.good { color: #087a42; }
.insight-value.bad { color: var(--red); }
.insight-value.flat { color: var(--muted); }
.coverage-card { display: flex; gap: 10px; margin-top: 14px; padding: 12px; border-radius: 12px; background: #f7f9f5; border: 1px dashed #dbe3db; }
.coverage-icon { width: 30px; height: 30px; border-radius: 9px; background: #fff; display: grid; place-items: center; color: var(--muted); flex: none; border: 1px solid var(--line); }
.coverage-icon svg { width: 15px; height: 15px; }
.coverage-card strong { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.coverage-card p { margin-top: 3px; font-size: 10.5px; line-height: 1.5; color: var(--muted-2); }

/* ---------- Detail ---------- */
.detail-head { margin-bottom: 18px; }
.back-btn { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 16px; }
.back-btn:hover { color: var(--green-700); }
.back-btn svg { width: 16px; height: 16px; }
.detail-title-row { display: flex; align-items: center; gap: 14px; }
.detail-icon { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: var(--green-50); color: var(--green-700); flex: none; }
.detail-icon svg { width: 25px; height: 25px; }
.detail-title-row h1 { font-size: 26px; font-weight: 800; letter-spacing: -.04em; }
.detail-chart-panel { padding: 18px 20px 12px; margin-bottom: 14px; }
.detail-chart-head { align-items: flex-start; }
.detail-chart-head .panel-title-row h2 { font-size: 15px; }
.detail-chart-totals { display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.detail-total { display: flex; flex-direction: column; gap: 1px; min-width: 64px; }
.detail-total small { font-size: 8.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted-2); }
.detail-total strong { font-size: 17px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.detail-chart-wrap { position: relative; height: 235px; margin-top: 10px; }
.detail-chart-wrap canvas { width: 100% !important; height: 100% !important; }
.detail-chart-wrap .chart-empty { background: rgba(255,255,255,.8); }
.detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 14px; }
.detail-locals { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.toolbar-label { font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); flex: none; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 11px; font-weight: 700; color: var(--muted); transition: all .14s ease; white-space: nowrap; }
.chip:hover { border-color: #c8d4c9; color: var(--ink); }
.chip.is-active { background: var(--green-50); border-color: #b9e3c9; color: var(--green-700); }
.chip .chip-count { font-size: 9.5px; font-weight: 800; color: var(--muted-2); background: #f3f5f1; border-radius: 999px; padding: 1px 5px; }
.chip.is-active .chip-count { background: #fff; color: var(--green-700); }
.detail-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.search-field { position: relative; display: flex; align-items: center; }
.search-field svg { position: absolute; left: 11px; width: 15px; height: 15px; color: var(--muted-2); pointer-events: none; }
.search-field input { height: 38px; width: 270px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfa; padding: 0 12px 0 34px; font-size: 12px; font-weight: 500; }
.search-field input:focus { outline: 0; border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(0,166,81,.10); }
.detail-panel { overflow: hidden; }
.detail-scroll { max-height: calc(100vh - 590px); min-height: 260px; }
.detail-table { min-width: 880px; }
.detail-table thead th { position: sticky; top: 0; background: #fbfcfa; z-index: 2; border-bottom: 1px solid var(--line); }
.detail-table td { font-size: 12px; }
.detail-table .mono { font-family: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; letter-spacing: .02em; font-weight: 600; }
.detail-table .strong { font-weight: 700; }
.detail-table .muted { color: var(--muted); }
.badge { display: inline-flex; align-items: center; height: 21px; padding: 0 7px; border-radius: 6px; font-size: 9.5px; font-weight: 800; letter-spacing: .01em; white-space: nowrap; }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-green { background: var(--green-50); color: var(--green-700); }
.badge-gray { background: #f2f4f0; color: var(--muted); }
.badge-crimson { background: var(--crimson-soft); color: var(--crimson); }
.badge-teal { background: var(--teal-soft); color: var(--teal); }
.detail-empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.detail-empty svg { width: 34px; height: 34px; color: var(--muted-2); margin-bottom: 10px; }
.detail-empty h3 { font-size: 15px; color: var(--ink); margin-bottom: 5px; }
.detail-empty p { font-size: 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line-2); background: #fcfdfb; }
.pager-info { font-size: 11px; color: var(--muted); font-weight: 600; }
.pager-controls { display: flex; align-items: center; gap: 7px; }
.pager-btn { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; background: #fff; color: var(--ink-2); }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }
.pager-btn svg { width: 15px; height: 15px; }
.pager-page { font-size: 11px; font-weight: 700; color: var(--muted); min-width: 58px; text-align: center; }

/* ---------- Footer / modal / toast ---------- */
.app-footer { max-width: 1380px; margin: 0 auto; padding: 0 30px 26px; display: flex; align-items: center; gap: 10px; font-size: 10.5px; color: var(--muted-2); font-weight: 600; }
.footer-sep { width: 4px; height: 4px; border-radius: 50%; background: #cbd4cc; }
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 29, 21, .44); backdrop-filter: blur(3px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .16s ease; }
.modal { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .18s ease; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 0; }
.modal-head h2 { font-size: 18px; font-weight: 800; letter-spacing: -.03em; }
.modal-head p { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.modal-close { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.modal-close:hover { background: #f4f6f2; color: var(--ink); }
.modal-body { padding: 18px 20px 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 20px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 120; display: flex; align-items: center; gap: 9px; max-width: calc(100vw - 32px); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 11px; box-shadow: var(--shadow-lg); font-size: 12px; font-weight: 600; animation: toastIn .2s ease; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green-800); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lower-grid { grid-template-columns: 1fr; }
  .insights-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
  .insights-panel .panel-head { grid-column: 1 / -1; }
  .insight-list { grid-column: 1; }
  .coverage-card { grid-column: 2; align-self: start; margin-top: 16px; }
}
@media (max-width: 1000px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { min-height: 340px; padding: 32px 28px; }
  .hero-copy { padding: 28px 0 20px; }
  .hero-copy h1 { font-size: 34px; }
  .hero-text { font-size: 13.5px; }
  .hero-list { display: none; }
  .hero-foot { display: none; }
  .login-panel { padding: 34px 22px 26px; }
  .login-legal { margin-top: 22px; }
}
@media (max-width: 900px) {
  .topbar-inner { padding: 0 18px; gap: 14px; }
  .topnav { display: none; }
  .filters-wrap { padding: 10px 18px 0; }
  .content { padding: 20px 18px 36px; }
  .app-footer { padding: 0 18px 22px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .update-chip { display: none; }
}
@media (max-width: 720px) {
  .topbar-inner { height: 66px; }
  .filters-wrap { top: 66px; }
  .brand .brand-sub { display: none; }
  .user-data { display: none; }
  .user-button .chev { display: none; }
  .filters { gap: 8px; padding: 8px; }
  .mode-tabs { width: 100%; }
  .mode-tab { flex: 1; padding: 0 6px; font-size: 11px; }
  #actualBlock, #weekBlock, #rangeBlock { order: 3; width: 100%; }
  .current-week { width: 100%; justify-content: center; }
  .week-select { flex: 1; }
  .week-select select { width: 100%; min-width: 0; }
  .range-block { width: 100%; }
  .date-field { flex: 1; }
  .date-field input { width: 100%; }
  .locals-wrap { order: 4; flex: 1; min-width: 0; }
  .locals-button { width: 100%; max-width: none; }
  .refresh-btn { order: 4; }
  .locals-popover { right: auto; left: 0; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  #periodTag, .page-meta .meta-sep { display: none; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 150px; }
  .chart-panel { padding: 16px 14px 12px; }
  .chart-head { flex-direction: column; gap: 10px; }
  .chart-actions { width: 100%; justify-content: flex-end; }
  .chart-wrap { height: 270px; }
  .chart-legend { gap: 10px; }
  .chart-legend .legend-caption, .chart-legend .legend-sep { display: none; }
  .locals-panel, .insights-panel { padding: 16px 14px 12px; }
  .insights-panel { display: block; }
  .coverage-card { margin-top: 14px; }
  .detail-title-row h1 { font-size: 21px; }
  .detail-chart-panel { padding: 14px 14px 10px; }
  .detail-chart-head { flex-direction: column; gap: 10px; }
  .detail-chart-totals { width: 100%; justify-content: flex-start; }
  .detail-chart-wrap { height: 205px; }
  .detail-toolbar { align-items: stretch; flex-direction: column; }
  .detail-locals { align-items: flex-start; flex-direction: column; }
  .detail-tools { width: 100%; }
  .search-field { flex: 1; }
  .search-field input { width: 100%; }
  .detail-scroll { max-height: none; }
  .pager { flex-direction: column; align-items: flex-start; gap: 8px; }
  .app-footer { display: none; }
}
@media (max-width: 480px) {
  .login-hero { min-height: 290px; padding: 24px 20px; }
  .hero-copy h1 { font-size: 29px; }
  .hero-text { display: none; }
  .login-panel { padding: 28px 18px 22px; }
  .login-heading h2 { font-size: 26px; }
  .content { padding: 16px 12px 30px; }
  .filters-wrap { padding: 8px 12px 0; }
  .topbar-inner { padding: 0 12px; }
  .kpi-value { font-size: 30px; }
  .chart-wrap { height: 240px; }
  .mode-tab { font-size: 10px; }
  .page-head h1 { font-size: 23px; }
}

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

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes loading { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
