@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/inter-latin-variable.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --nav: #07101f;
  --nav-2: #0e2037;
  --ink: #101722;
  --muted: #687385;
  --line: #dde4ee;
  --soft: #f5f7fa;
  --card: #ffffff;
  --field: #ffffff;
  --page: #eef3f8;
  --table-head: #f9fbfd;
  --hover: #effaf9;
  --teal: #008f82;
  --teal-2: #15c7d8;
  --teal-deep: #007467;
  --red: #ff544f;
  --amber: #f59e0b;
  --green: #0ca66f;
  --shadow: 0 18px 54px rgba(14, 32, 55, 0.12);
  --control-shadow: 0 10px 24px rgba(14, 32, 55, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --nav: #050812;
  --nav-2: #0a1320;
  --ink: #eef6ff;
  --muted: #91a0b6;
  --line: rgba(180, 199, 224, 0.18);
  --soft: #101827;
  --card: #111b2b;
  --field: #0c1524;
  --page: #08111f;
  --table-head: #0d1726;
  --hover: rgba(21, 199, 216, 0.09);
  --teal: #15b8a6;
  --teal-2: #27d7e8;
  --teal-deep: #0b8f82;
  --red: #ff6b68;
  --amber: #f7b84b;
  --green: #36d399;
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.36);
  --control-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 78% -12%, rgba(21, 199, 216, .15), transparent 30rem),
    var(--page);
  color: var(--ink);
  transition: background-color .2s ease, color .2s ease;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 0%, rgba(21, 199, 216, .18), transparent 34rem),
    radial-gradient(circle at 82% 75%, rgba(255, 84, 79, .16), transparent 30rem),
    linear-gradient(135deg, #07101f, #102235);
}
.login-card {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  color: white;
  box-shadow: 0 26px 80px rgba(0,0,0,.3);
  backdrop-filter: blur(18px);
}
.login-logo { width: 190px; filter: drop-shadow(0 12px 22px rgba(0,0,0,.25)); }
.login-card h1 { margin: 26px 0 8px; font-size: 36px; line-height: 1; }
.login-card p { margin: 0 0 22px; color: #b8c6d8; line-height: 1.5; }
.login-card form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 750; }
.login-card label { color: #d8e6f6; }
input, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  outline: 0;
}
input { min-height: 42px; padding: 0 12px; }
textarea { padding: 10px 12px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--teal-2); box-shadow: 0 0 0 4px rgba(21,199,216,.13); }
.login-card input { border-color: rgba(255,255,255,.18); background: rgba(6,14,30,.55); color: white; }
.login-card button, #manualForm button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: white;
  font-weight: 850;
  box-shadow: 0 12px 24px rgba(0,143,130,.2);
}
.message { min-height: 18px; color: var(--red); font-size: 12px; font-weight: 750; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}
.sidebar {
  min-height: 100vh;
  padding: 20px 16px;
  background:
    linear-gradient(180deg, rgba(21,199,216,.1), transparent 32%),
    linear-gradient(180deg, var(--nav), #050b16);
  color: #dbe8f7;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
}
.brand { display: grid; gap: 12px; padding: 4px 4px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand img { width: 164px; }
.brand span { color: #8ef7ff; font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
nav { display: grid; align-content: start; gap: 8px; }
.nav-item {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b8c6d8;
  text-align: left;
  font-weight: 750;
}
.nav-item.active { background: linear-gradient(135deg, var(--teal), #008074); color: white; }
.user-box {
  display: grid;
  gap: 5px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.user-box small { color: #8798ad; }
#logoutBtn {
  width: fit-content;
  margin-top: 8px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  color: #dbe8f7;
  padding: 8px 12px;
  font-weight: 750;
}

.workspace { min-width: 0; padding: 24px; }
.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: 28px; }
.topbar p { margin: 5px 0 0; color: var(--muted); }
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}
.import-form { margin: 0; }
#importBtn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: white;
  padding: 0 15px;
  font-size: 14px;
  font-weight: 850;
  white-space: nowrap;
  box-shadow: 0 12px 24px rgba(0,143,130,.22);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
#importBtn:hover { transform: translateY(-1px); filter: brightness(1.03); box-shadow: 0 16px 30px rgba(0,143,130,.28); }
#importBtn:disabled { cursor: wait; opacity: .72; transform: none; }
.button-icon {
  width: 16px;
  height: 16px;
  position: relative;
  display: inline-block;
  border: 2px solid currentColor;
  border-radius: 5px;
}
.button-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  width: 6px;
  height: 6px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: translateX(-50%) rotate(45deg);
}
.range-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  box-shadow: var(--control-shadow);
}
.range-controls input {
  width: 150px;
  min-height: 38px;
  border-radius: 8px;
  border-color: transparent;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}
.segmented {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}
.segmented button {
  min-width: 76px;
  min-height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
.segmented button:hover { color: var(--ink); background: color-mix(in srgb, var(--teal) 10%, transparent); }
.segmented button.active { background: var(--teal); color: white; box-shadow: 0 8px 18px rgba(0,143,130,.22); }
.segmented button:disabled, .range-controls input:disabled, #searchInput:disabled {
  cursor: wait;
  opacity: .64;
}
.theme-toggle {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  color: var(--ink);
  padding: 0 13px;
  font-size: 14px;
  font-weight: 850;
  box-shadow: var(--control-shadow);
}
.theme-toggle-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f7c948, #f59e0b);
  box-shadow: inset -6px -6px 0 rgba(255, 255, 255, .28);
}
:root[data-theme="dark"] .theme-toggle-icon {
  background: #d7e9ff;
  box-shadow: inset -9px -3px 0 #25334a;
}

#dashboardView {
  position: relative;
}
.dashboard-loading {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  justify-content: center;
  margin: -4px 0 12px;
  pointer-events: none;
}
.loading-pill {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  border: 1px solid color-mix(in srgb, var(--teal) 42%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  box-shadow: var(--control-shadow);
  backdrop-filter: blur(12px);
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--teal) 22%, transparent);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.is-loading .kpis,
.is-loading .content-grid {
  opacity: .58;
  filter: saturate(.82);
  transition: opacity .18s ease, filter .18s ease;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpis article {
  min-height: 116px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(14,32,55,.05);
}
.kpis span, .kpis small { color: var(--muted); }
.kpis span { display: block; font-size: 13px; }
.kpis strong { display: block; margin: 12px 0; font-size: 25px; line-height: 1; }
.kpis small { font-size: 12px; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
}
.table-panel, .detail-panel, .access-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.panel-head {
  min-height: 64px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.panel-head h2, .detail-panel h2 { margin: 0; font-size: 18px; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.panel-head input { width: min(320px, 42vw); }
.panel-head button, .access-panel button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  padding: 0 14px;
  font-weight: 850;
}
.access-panel button.danger-button {
  min-height: 34px;
  background: color-mix(in srgb, var(--red) 12%, transparent);
  color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 32%, transparent);
  padding: 0 12px;
  box-shadow: none;
}
.access-panel button.danger-button:hover {
  background: var(--red);
  color: white;
}
.access-panel button.danger-button:disabled {
  cursor: wait;
  opacity: .68;
}
.table-wrap { overflow: auto; max-height: calc(100vh - 310px); }
table { width: 100%; border-collapse: collapse; min-width: 900px; font-size: 13px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; }
th { position: sticky; top: 0; z-index: 1; background: var(--table-head); color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
tbody tr { transition: background .15s ease; }
tbody tr:hover, tbody tr.selected { background: var(--hover); }
.campaign-name { display: grid; gap: 3px; font-weight: 850; }
.campaign-name small { color: var(--muted); font-weight: 600; }
.money, .number { font-variant-numeric: tabular-nums; font-weight: 800; }
.badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 850;
}
.badge.auto { color: var(--green); background: rgba(12,166,111,.1); border: 1px solid rgba(12,166,111,.24); }
.badge.manual { color: var(--amber); background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); }
code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  padding: 4px 7px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}
.access-panel { overflow: hidden; }
.access-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.access-summary strong { color: var(--ink); }

.detail-panel { padding: 18px; }
.empty-detail { height: 100%; display: grid; place-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-detail p { margin: 0; line-height: 1.45; }
#manualForm { display: grid; gap: 13px; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.detail-meta { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .table-wrap { max-height: none; }
}
@media (max-width: 1380px) {
  .topbar { grid-template-columns: 1fr; }
  .topbar-actions { justify-content: flex-start; flex-wrap: wrap; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; grid-template-rows: auto; }
  nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .topbar-actions, .range-controls { width: 100%; }
  .range-controls { flex-wrap: wrap; }
  .range-controls input { flex: 1 1 150px; }
  .segmented { flex: 1 1 100%; }
  .segmented button { flex: 1; }
  #importBtn, .theme-toggle { flex: 1 1 180px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-head { align-items: stretch; flex-direction: column; }
  .panel-head input { width: 100%; }
}
