:root {
  --navy-1000: #04101f;
  --navy-950: #07172b;
  --navy-900: #0a2340;
  --navy-800: #103b63;
  --navy-700: #175a8d;
  --blue: #2687c8;
  --cyan: #1cb5c9;
  --sky: #dff3ff;
  --orange: #ff9f1c;
  --orange2: #f36b21;
  --green: #168a55;
  --red: #c83f49;
  --purple: #6f5bd6;
  --bg: #f2f6fb;
  --panel: #ffffff;
  --text: #132238;
  --muted: #68778a;
  --line: #dce5ef;
  --shadow: 0 18px 48px rgba(7, 23, 43, .09);
  --shadow-strong: 0 22px 55px rgba(7, 23, 43, .17);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
body.dark {
  --bg: #07111f;
  --panel: #0e1b2c;
  --text: #edf5fc;
  --muted: #a8b7c8;
  --line: #24364a;
  --sky: #112c42;
  --shadow: 0 18px 48px rgba(0, 0, 0, .3);
  --shadow-strong: 0 24px 60px rgba(0, 0, 0, .44);
}
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(4, 16, 31, .94), rgba(16, 59, 99, .88)),
    radial-gradient(circle at 20% 20%, rgba(255, 159, 28, .18), transparent 34%);
}
body:not(.auth-locked) .auth-gate { display: none; }
.auth-card {
  width: min(470px, 100%);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .34);
  padding: 28px;
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-logo {
  width: 47px;
  height: auto;
  aspect-ratio: 356 / 378;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(7, 23, 43, .18));
}
.auth-brand h1 { margin: 0; font-size: 19px; }
.auth-brand p, .auth-intro, .auth-note { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.auth-card h2 { margin: 0 0 8px; font-size: 24px; }
.auth-field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 900;
}
.auth-field input, .password-wrap input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0 12px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.password-wrap { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.password-wrap button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 0 12px;
  cursor: pointer;
}
.auth-submit, .primary-action {
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--navy-800), var(--blue));
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
.auth-submit { width: 100%; height: 46px; margin-top: 18px; }
.auth-submit:disabled { cursor: wait; opacity: .65; }
.auth-link-button {
  display: block;
  min-height: 44px;
  margin: 5px auto 0;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.auth-link-button:hover { text-decoration: underline; }
.auth-link-button:focus-visible, .auth-submit:focus-visible, .auth-field input:focus-visible {
  outline: 3px solid rgba(38, 135, 200, .28);
  outline-offset: 2px;
}
.install-link { display: grid; place-items: center; text-decoration: none; }
.auth-note { margin-top: 14px; padding: 12px; border-radius: 13px; background: var(--bg); }
.auth-site-link { display: block; margin-top: 14px; color: var(--blue); text-align: center; text-decoration: none; font-size: 11px; font-weight: 850; }
.form-message { margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--red); }
.form-message.success { color: var(--green); }

.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns .24s ease;
}
body.auth-locked .app { opacity: 0; pointer-events: none; }
.app.collapsed { grid-template-columns: 82px minmax(0, 1fr); }
.backdrop { display: none; }
.sidebar {
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 600;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 15px;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(180deg, var(--navy-1000), var(--navy-900) 54%, #113b61);
}
.sidebar-head {
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}
.brand-logo {
  width: 43px;
  height: auto;
  aspect-ratio: 356 / 378;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .25));
}
.brand-copy { min-width: 0; transition: opacity .18s; }
.brand-copy h1 { margin: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-copy small { display: block; margin-top: 4px; opacity: .68; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collapse-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  cursor: pointer;
}
.nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 5px;
  padding-right: 2px;
}
.site-return { min-height: 40px; display: flex; align-items: center; gap: 10px; margin: 8px 0; padding: 8px 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 10px; color: rgba(255,255,255,.82); text-decoration: none; font-size: 11px; font-weight: 850; }
.nav a, .nav button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: rgba(255, 255, 255, .76);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.nav a:hover, .nav a.active, .nav button:hover { background: rgba(255, 255, 255, .11); color: #fff; }
.nav .ico { width: 22px; flex: 0 0 22px; text-align: center; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.upload-nav { margin-top: 10px; border: 1px solid rgba(255, 159, 28, .42) !important; background: rgba(255, 159, 28, .08) !important; color: #ffd59c !important; }
.source-note {
  flex: 0 0 auto;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 14px;
  background: rgba(255, 255, 255, .055);
  font-size: 10.5px;
  line-height: 1.45;
  color: rgba(255, 255, 255, .72);
}
.source-note b { display: block; color: #fff; margin-bottom: 4px; }
.app.collapsed .brand-copy, .app.collapsed .nav-label, .app.collapsed .source-note { opacity: 0; width: 0; overflow: hidden; pointer-events: none; }
.app.collapsed .site-return span:last-child { display: none; }
.app.collapsed .sidebar-head { grid-template-columns: 48px; }
.app.collapsed .collapse-btn { position: absolute; left: 22px; top: 78px; transform: rotate(180deg); }

.main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 550;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mobile-menu {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  cursor: pointer;
}
.title { min-width: 0; }
.title h2 { margin: 0; font-size: 21px; overflow-wrap: anywhere; }
.title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.company-heading { display: inline-flex; gap: 6px; margin-top: 5px; color: var(--muted); font-size: 11px; }
.company-heading strong { color: var(--text); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.company-select, .top-actions button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 0 11px;
}
.theme-btn { width: 40px; padding: 0 !important; cursor: pointer; }
.admin-users-btn, .logout-btn { cursor: pointer; font-weight: 850; }
.logout-btn { color: var(--red); }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  max-width: 220px;
}
.user-chip span { color: var(--green); }
.user-chip b, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip b { font-size: 12px; }
.user-chip small { color: var(--muted); font-size: 10px; }

.content { padding: 24px 26px 60px; max-width: 1740px; margin: auto; }
.section-anchor { scroll-margin-top: 86px; }
.filters-card {
  position: relative;
  z-index: 300;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.filters {
  display: grid;
  grid-template-columns: minmax(230px, 2fr) repeat(4, minmax(135px, 1fr)) repeat(2, minmax(130px, .7fr)) auto;
  gap: 10px;
  align-items: end;
}
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 9.5px;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.input-shell, .input-date, .multi-button, .field select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  outline: none;
}
.input-shell { display: flex; align-items: center; gap: 8px; padding: 0 11px; }
.input-shell input { border: 0; background: transparent; color: inherit; outline: 0; width: 100%; min-width: 0; }
.input-date, .field select { padding: 0 10px; }
.filter-icon { color: var(--blue); }
.clear-btn {
  height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 850;
  color: var(--muted);
  white-space: nowrap;
  transition: border-color .18s ease, color .18s ease, background-color .18s ease;
}
.clear-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--sky);
}
.clear-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 28%, transparent);
  outline-offset: 2px;
}
.multi-filter { position: relative; }
.multi-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  cursor: pointer;
}
.multi-button span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.multi-menu {
  position: absolute;
  top: 46px;
  left: 0;
  z-index: 320;
  width: min(280px, 88vw);
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: var(--shadow-strong);
  padding: 8px;
  display: none;
}
.multi-filter.open .multi-menu { display: grid; gap: 4px; }
.multi-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px;
  border-radius: 10px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 600;
}
.multi-option:hover { background: var(--bg); }
.multi-actions { display: flex; justify-content: space-between; gap: 6px; padding: 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.multi-actions button { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 11px; font-weight: 850; }
.active-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.filter-chip {
  border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--line));
  background: var(--sky);
  color: var(--navy-800);
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 10px;
  cursor: pointer;
}
body.dark .filter-chip { color: #cfeeff; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 14px; margin: 18px 0; }
.kpi {
  --accent: var(--blue);
  position: relative;
  overflow: hidden;
  min-height: 116px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.kpi:before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 50%, var(--orange)));
}
.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-strong); }
.kpi.active { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), var(--shadow-strong); }
.kpi .label { font-size: 10px; color: var(--muted); font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { margin-top: 9px; font-size: 25px; font-weight: 950; color: var(--navy-800); }
body.dark .kpi .value { color: #f2f8fd; }
.kpi .sub { margin-top: 7px; max-width: 90%; color: var(--muted); font-size: 10.5px; line-height: 1.4; }
.kpi.win { --accent: var(--green); }
.kpi.risk { --accent: var(--red); }
.kpi.highlight { --accent: var(--orange); }
.kpi.money { --accent: var(--purple); }

.grid2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; margin-top: 18px; }
.grid2.equal { grid-template-columns: 1fr 1fr; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 18px; }
.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.spaced { margin-top: 18px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.panel h3 { margin: 0; font-size: 16px; }
.panel .desc { margin-top: 5px; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--sky);
  color: var(--navy-700);
  border: 1px solid color-mix(in srgb, var(--blue) 26%, var(--line));
  font-size: 9.5px;
  white-space: nowrap;
}
body.dark .badge { color: #cfeeff; }
.insights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.insight {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px;
  background: linear-gradient(145deg, var(--panel), var(--bg));
}
.insight .tag { font-size: 9px; font-weight: 950; letter-spacing: .09em; text-transform: uppercase; color: var(--blue); }
.insight h4 { margin: 7px 0 6px; font-size: 13.5px; }
.insight p { margin: 0; color: var(--muted); font-size: 11.2px; line-height: 1.55; }
.conversion-funnel { display: grid; gap: 8px; justify-items: center; }
.funnel-step {
  --step: var(--blue);
  width: var(--w);
  min-width: 48%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--step) 88%, #fff), var(--step));
  clip-path: polygon(6% 0, 94% 0, 86% 100%, 14% 100%);
  padding: 0 15%;
  cursor: pointer;
}
.funnel-step.active { outline: 3px solid color-mix(in srgb, var(--orange) 70%, #fff); outline-offset: 3px; }
.f-name { font-weight: 900; font-size: 12px; }
.f-count { display: block; font-size: 21px; font-weight: 950; text-align: right; }
.f-rate { display: block; font-size: 9px; opacity: .84; text-align: right; }
.funnel-explain { margin-top: 12px; padding: 11px 12px; border-radius: 13px; background: var(--sky); color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.stage-flow { position: relative; display: grid; gap: 9px; padding-left: 23px; }
.stage-flow:before { content: ""; position: absolute; left: 8px; top: 12px; bottom: 12px; width: 2px; background: linear-gradient(var(--blue), var(--orange), var(--green)); opacity: .35; }
.stage-card {
  --c: var(--blue);
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--panel), var(--bg));
  border-radius: 14px;
  padding: 12px 13px;
  cursor: pointer;
}
.stage-card:before { content: ""; position: absolute; left: -22px; width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.stage-name { font-size: 11px; font-weight: 900; }
.stage-sub { margin-top: 4px; color: var(--muted); font-size: 9.5px; }
.stage-value { text-align: right; }
.stage-value b { display: block; font-size: 18px; }
.status-layout { display: grid; grid-template-columns: 190px 1fr; gap: 18px; align-items: center; }
.status-svg { width: 180px; height: 180px; overflow: visible; }
.donut-seg { cursor: pointer; transition: stroke-width .18s, opacity .18s; }
.donut-seg:hover { stroke-width: 28; opacity: .9; }
.donut-center { font-size: 19px; font-weight: 950; fill: var(--text); }
.donut-sub { font-size: 8px; font-weight: 800; fill: var(--muted); }
.legend { display: grid; gap: 8px; }
.legend-item, .metric-bar {
  border: 0;
  background: transparent;
  width: 100%;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}
.legend-item { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 6px; border-radius: 10px; font-size: 10.5px; }
.legend-item:hover, .metric-bar:hover { background: var(--bg); }
.dot { width: 10px; height: 10px; border-radius: 3px; }
.movement {
  display: grid;
  grid-template-columns: 62px 1.3fr .8fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.date-box { text-align: center; background: var(--sky); border-radius: 12px; padding: 8px 5px; color: var(--navy-800); }
.date-box b { font-size: 17px; }
.date-box small { display: block; text-transform: uppercase; font-size: 9px; font-weight: 900; }
.movement-title { font-size: 12px; font-weight: 850; }
.movement-sub, .movement-value { color: var(--muted); font-size: 10.5px; }
.movement-value { text-align: right; }
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 7px 9px;
  cursor: pointer;
  color: var(--navy-700);
  font-weight: 850;
  text-decoration: none;
}
.metric-bar { --c: var(--blue); display: grid; grid-template-columns: minmax(120px, 1.08fr) 2fr auto; gap: 10px; align-items: center; margin: 9px 0; padding: 6px; border-radius: 11px; }
.bar-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10.5px; }
.bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; width: var(--pct); height: 100%; background: linear-gradient(90deg, var(--navy-800), var(--c)); border-radius: 999px; }
.bar-value { font-size: 10.5px; font-weight: 900; white-space: nowrap; }
.loss-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.loss-card {
  --c: var(--red);
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  cursor: pointer;
  text-align: left;
}
.loss-card .l-label { font-size: 10px; color: var(--muted); }
.loss-card .l-value { font-size: 22px; font-weight: 950; margin-top: 5px; }
.loss-card .l-rate { font-size: 9.5px; color: var(--muted); margin-top: 4px; }
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border-radius: 15px;
  padding: 14px;
  border: 1px solid #f4ca82;
  background: #fff7e8;
  color: #75430a;
  margin-bottom: 11px;
}
body.dark .alert { background: #34250f; color: #ffd89a; border-color: #5b421c; }
.alert.info { background: var(--sky); border-color: #bbd8ea; color: var(--navy-800); }
body.dark .alert.info { color: #c9e8f8; border-color: #254b67; }
.alert strong { display: block; margin-bottom: 4px; font-size: 12px; }
.alert p { margin: 0; font-size: 11px; line-height: 1.5; }
.sync-box { display: grid; grid-template-columns: repeat(5, 1fr); gap: 11px; }
.sync-metric { padding: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; }
.sync-metric small { font-size: 9.5px; color: var(--muted); text-transform: uppercase; font-weight: 850; }
.sync-metric b { display: block; font-size: 20px; margin-top: 5px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 1460px; }
th {
  position: sticky;
  top: 0;
  background: var(--bg);
  text-align: left;
  font-size: 9.5px;
  color: var(--muted);
  padding: 11px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
}
td { padding: 11px; border-bottom: 1px solid var(--line); font-size: 10.8px; vertical-align: top; }
tr:hover td { background: color-mix(in srgb, var(--bg) 65%, transparent); }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 850; color: #fff; white-space: nowrap; }
.observation-cell { max-width: 280px; color: var(--muted); line-height: 1.45; white-space: pre-wrap; }
.observation-empty { opacity: .55; font-style: italic; }
.object { max-width: 330px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.table-summary, .footer-note { margin-top: 14px; color: var(--muted); font-size: 10.5px; line-height: 1.55; }

.empty-base-notice {
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed color-mix(in srgb, var(--blue) 45%, var(--line));
  border-radius: 18px;
  background: color-mix(in srgb, var(--sky) 54%, var(--panel));
}
.empty-base-notice h3 { margin: 0 0 6px; font-size: 16px; }
.empty-base-notice p { margin: 0 0 12px; color: var(--muted); font-size: 12px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 14, 26, .7);
}
.modal.open { display: flex; }
.modal-card {
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .32);
}
.user-modal-card { width: min(1050px, 100%); }
.upload-card { width: min(720px, 100%); }
.modal-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.modal-top h3 { margin: 10px 0 0; }
.close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  font-size: 20px;
}
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  border: 0;
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 850;
  color: var(--muted);
}
.tab.active { color: var(--blue); border-bottom: 3px solid var(--blue); }
.admin-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.2fr); gap: 18px; }
.admin-form {
  display: grid;
  gap: 11px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
}
.admin-form label, #uploadForm .field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 900;
}
.admin-form input, .admin-form select, #uploadForm select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  padding: 0 11px;
}
.form-actions, .upload-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-actions button:disabled { cursor: wait; opacity: .62; }
.primary-action, .secondary-action, .danger-action { min-height: 40px; border-radius: 11px; padding: 9px 12px; cursor: pointer; font-weight: 850; }
.secondary-action, .danger-action { border: 1px solid var(--line); background: var(--panel); }
.danger-action { color: var(--red); }
.admin-list { display: grid; align-content: start; gap: 9px; max-height: 520px; overflow: auto; }
.row-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.row-card h4 { margin: 0; font-size: 12px; }
.row-card p { margin: 4px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.4; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions button { border: 1px solid var(--line); border-radius: 9px; background: var(--bg); padding: 6px 8px; cursor: pointer; font-size: 10px; }
.contacts-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.contacts-head h4 { margin: 0; }
.contacts-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.contacts-list { max-height: 560px; }
.contact-admin-card { align-items: start; }
.contact-admin-card.is-new { border-left: 4px solid var(--blue); }
.contact-admin-title { display: flex; align-items: center; gap: 8px; }
.contact-admin-copy small { display: block; margin-top: 7px; color: var(--muted); font-size: 9.5px; }
.dropzone {
  margin-top: 14px;
  display: grid;
  gap: 7px;
  place-items: center;
  text-align: center;
  min-height: 170px;
  border: 1.5px dashed color-mix(in srgb, var(--blue) 55%, var(--line));
  border-radius: 18px;
  padding: 28px;
  background: linear-gradient(145deg, var(--panel), var(--sky));
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease, transform .2s ease;
}
.dropzone input { display: none; }
.drop-icon { font-size: 32px; }
.dropzone small { color: var(--muted); line-height: 1.5; }
.drop-file-status {
  min-height: 25px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.dropzone.is-dragging {
  border-color: var(--blue);
  background: var(--sky);
  box-shadow: 0 0 0 4px rgba(38, 135, 200, .14);
  transform: translateY(-2px);
}
.dropzone.has-file { border-color: var(--green); background: color-mix(in srgb, var(--green) 7%, var(--panel)); }
.dropzone.has-file .drop-icon, .dropzone.has-file .drop-file-status { color: var(--green); }
.dropzone.is-uploading { pointer-events: none; border-color: var(--orange); opacity: .78; }
.dropzone.is-uploading .drop-icon { color: var(--orange); }
.dropzone.is-imported { border-style: solid; border-color: var(--green); background: color-mix(in srgb, var(--green) 9%, var(--panel)); }
.dropzone.is-imported .drop-icon, .dropzone.is-imported .drop-file-status { color: var(--green); }
.dropzone.is-invalid { border-color: var(--red); background: color-mix(in srgb, var(--red) 7%, var(--panel)); }
.dropzone.is-invalid .drop-icon, .dropzone.is-invalid .drop-file-status { color: var(--red); }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.meta-item { padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: var(--bg); }
.meta-item small { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; font-weight: 850; margin-bottom: 5px; }
.modal-object { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--muted); line-height: 1.55; white-space: pre-wrap; }
.modal-links { display: flex; gap: 9px; margin-top: 18px; flex-wrap: wrap; }

@media (max-width: 1180px) {
  .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .field.wide { grid-column: span 2; }
  .grid3, .insights { grid-template-columns: 1fr; }
}
@media (max-width: 970px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .main { grid-column: 1; }
  .mobile-menu { display: grid; place-items: center; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 310px);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .24s ease;
    z-index: 800;
    overflow-y: auto;
  }
  .app.mobile-open .sidebar { transform: translateX(0); }
  .backdrop {
    position: fixed;
    inset: 0;
    z-index: 760;
    display: none;
    background: rgba(4, 16, 31, .52);
  }
  .app.mobile-open .backdrop { display: block; }
  body.menu-open { overflow: hidden; }
  .app.collapsed .brand-copy, .app.collapsed .nav-label, .app.collapsed .source-note { opacity: 1; width: auto; pointer-events: auto; }
  .app.collapsed .site-return span:last-child { display: inline; }
  .app.collapsed .sidebar-head { grid-template-columns: 48px minmax(0, 1fr) 36px; }
  .app.collapsed .collapse-btn { position: static; transform: none; }
  .grid2, .grid2.equal, .grid3, .admin-grid { grid-template-columns: 1fr; }
  .status-layout { grid-template-columns: 1fr; justify-items: center; }
  .topbar { align-items: flex-start; }
}
@media (max-width: 760px) {
  .content, .topbar { padding-left: 14px; padding-right: 14px; }
  .topbar { flex-direction: column; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .company-select { width: 100%; }
  .user-chip { max-width: 100%; }
  .filters { grid-template-columns: 1fr; }
  .clear-btn { width: 100%; }
  .field.wide { grid-column: auto; }
  .kpis { grid-template-columns: 1fr; }
  .sync-box { grid-template-columns: 1fr 1fr; }
  .movement { grid-template-columns: 54px 1fr; }
  .movement-value, .movement .link-btn { grid-column: 2; text-align: left; justify-self: start; }
  .loss-grid { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .auth-card { padding: 20px; }
  .title h2 { font-size: 17px; }
  .panel, .filters-card { border-radius: 16px; padding: 14px; }
  .sync-box { grid-template-columns: 1fr; }
}
