/* ==========================================================================
   EYEV · DW Analytics — design system
   Tokens lifted verbatim from eyev.health (accent #e42464, Inter variable).
   ========================================================================== */
@font-face {
  font-family: 'Inter';
  src: url('../assets/inter-variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
}

:root {
  --accent: #e42464;
  --accent-dark: #b01a4e;
  --accent-soft: rgba(228, 36, 100, 0.10);
  --accent-softer: rgba(228, 36, 100, 0.05);
  --background: #f0f0f0;
  --foreground: #0a090c;
  --foreground-2: #19171d;
  --ivory: #fcffeb;
  --line: rgba(10, 9, 12, 0.12);
  --line-strong: rgba(10, 9, 12, 0.20);
  --muted: #59555f;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --shadow: 0 22px 60px rgba(10, 9, 12, 0.14);
  --shadow-sm: 0 2px 8px rgba(10, 9, 12, 0.06);
  --ok: #1f8a4c;
  --warn: #b8860b;
  --danger: #b00020;
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  /* categorical palette anchored on the brand pink */
  --c1: #e42464; --c2: #19171d; --c3: #f08aab; --c4: #5b6cff; --c5: #1f8a4c;
  --c6: #b8860b; --c7: #8a5cf6; --c8: #0fa3b1; --c9: #b01a4e; --c10: #59555f;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--foreground);
  background: var(--background);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.012em; margin: 0; font-weight: 680; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.02rem; }
small { color: var(--muted); }
::selection { background: var(--accent-soft); }

/* ---- boot ---- */
.boot { min-height: 100vh; display: grid; place-items: center; gap: 18px; }
.boot img { border-radius: 14px; }
.boot-spin, .spin {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- buttons ---- */
.btn {
  font: inherit; font-weight: 580; cursor: pointer; border: 1px solid transparent;
  border-radius: 999px; padding: 9px 16px; background: var(--surface); color: var(--foreground);
  display: inline-flex; align-items: center; gap: 8px; transition: all .14s ease; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 8px 22px rgba(228,36,100,.28); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--surface); border-color: var(--line-strong); }
.btn.subtle { background: var(--accent-soft); color: var(--accent-dark); }
.btn.subtle:hover { background: rgba(228,36,100,.16); }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(176,0,32,.3); }
.btn.danger:hover { background: rgba(176,0,32,.07); }
.btn.sm { padding: 5px 11px; font-size: 0.82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---- forms ---- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 560; margin-bottom: 6px; font-size: 0.86rem; color: var(--foreground-2); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--foreground); transition: border .14s, box-shadow .14s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2359555f' stroke-width='1.6' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card.pad { padding: 18px 20px; }

/* ---- badges / chips ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 620; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.accent { background: var(--accent-soft); color: var(--accent-dark); border-color: transparent; }
.badge.ok { background: rgba(31,138,76,.10); color: var(--ok); border-color: transparent; }
.badge.owner { background: var(--foreground); color: #fff; border-color: transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 560; font-size: 0.82rem; }
.chip button { border: none; background: none; cursor: pointer; color: inherit; font-size: 1rem; line-height: 1; padding: 0; opacity: .7; }
.chip button:hover { opacity: 1; }
.chip.dim { background: var(--surface-2); color: var(--foreground-2); }

/* ==================== APP LAYOUT ==================== */
.app-shell { display: grid; grid-template-columns: 248px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; grid-template-areas: "brand topbar" "sidebar main"; }
.brand { grid-area: brand; display: flex; align-items: center; gap: 11px; padding: 0 18px; height: 62px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--surface); }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand .wm { font-weight: 760; letter-spacing: -0.02em; font-size: 1.05rem; }
.brand .wm b { color: var(--accent); }
.brand .sub { font-size: 0.66rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.topbar { grid-area: topbar; display: flex; align-items: center; justify-content: space-between; height: 62px; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--line); gap: 16px; }
.topbar .page-title { font-weight: 680; font-size: 1.05rem; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.sidebar { grid-area: sidebar; background: var(--surface); border-right: 1px solid var(--line); padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-group { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; padding: 14px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--foreground-2); font-weight: 540; cursor: pointer; transition: background .12s; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 640; }
.nav-item .ic { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item.active .ic { opacity: 1; }

.main { grid-area: main; padding: 24px 28px 60px; overflow-x: hidden; max-width: 1500px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .lead { color: var(--muted); margin-top: 4px; max-width: 70ch; }

/* ---- avatar / menu ---- */
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--foreground); color: #fff; display: grid; place-items: center; font-weight: 680; font-size: 0.82rem; cursor: pointer; }
.iconbtn { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.iconbtn:hover { background: var(--surface-2); }
.dot { position: absolute; top: 6px; right: 7px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.62rem; font-weight: 700; display: grid; place-items: center; }
.menu { position: absolute; top: 54px; right: 0; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; z-index: 50; }
.menu .mi { padding: 9px 12px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.menu .mi:hover { background: var(--surface-2); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.popwrap { position: relative; }

/* ==================== GRIDS / TILES ==================== */
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; grid-auto-rows: 150px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px; display: flex; flex-direction: column; min-height: 0; position: relative; }
.tile h3 { font-size: 0.92rem; color: var(--foreground-2); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile .canvas-wrap { position: relative; flex: 1; min-height: 0; }
.tile canvas { max-width: 100%; }
.tile .tile-tools { position: absolute; top: 10px; right: 12px; display: none; gap: 6px; }
.tile:hover .tile-tools { display: flex; }

.kpi { display: flex; flex-direction: column; justify-content: center; }
.kpi .kpi-val { font-size: 2.1rem; font-weight: 740; letter-spacing: -0.02em; line-height: 1.05; }
.kpi .kpi-label { color: var(--muted); font-weight: 560; font-size: 0.86rem; }
.kpi.accent .kpi-val { color: var(--accent); }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cards-grid.wide { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.tilecard { cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; }
.tilecard:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.tilecard .meta { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }

/* ==================== TABLES ==================== */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.grid { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.grid th, table.grid td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid th { background: var(--surface-2); font-weight: 620; color: var(--foreground-2); position: sticky; top: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em; }
table.grid tr:last-child td { border-bottom: none; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover { background: var(--accent-softer); }

/* ==================== BUILDER ==================== */
.builder { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.builder .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: sticky; top: 12px; }
.builder .panel h4 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 16px 0 8px; }
.builder .panel h4:first-child { margin-top: 0; }
.fieldpool { display: flex; flex-wrap: wrap; gap: 7px; }
.pill { padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 0.82rem; font-weight: 540; transition: all .12s; }
.pill:hover { border-color: var(--accent); color: var(--accent-dark); }
.pill.dim { border-style: dashed; }
.viz-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.viz-opt { aspect-ratio: 1; border: 1px solid var(--line-strong); border-radius: 10px; display: grid; place-items: center; cursor: pointer; background: var(--surface); }
.viz-opt:hover { border-color: var(--accent); }
.viz-opt.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.viz-opt svg { width: 22px; height: 22px; }
.preview-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px; min-height: 440px; display: flex; flex-direction: column; }
.preview-canvas { flex: 1; min-height: 360px; position: relative; }
.filter-row { display: grid; grid-template-columns: 1fr 0.8fr 1fr auto; gap: 6px; margin-bottom: 7px; align-items: center; }
.filter-row .btn { padding: 6px 9px; }

/* ==================== LOGIN ==================== */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side { background: linear-gradient(150deg, var(--foreground) 0%, #2a1822 55%, var(--accent-dark) 140%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brandbig { display: flex; align-items: center; gap: 14px; }
.auth-side .brandbig img { width: 44px; height: 44px; border-radius: 11px; }
.auth-side h1 { font-size: 2.4rem; max-width: 14ch; margin-top: auto; }
.auth-side p { color: rgba(255,255,255,.74); max-width: 42ch; }
.auth-side .stat { display: flex; gap: 26px; margin-top: 24px; }
.auth-side .stat b { font-size: 1.5rem; display: block; }
.auth-side .stat span { color: rgba(255,255,255,.6); font-size: 0.8rem; }
.auth-main { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }
.qr-box { display: grid; place-items: center; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.qr-box img, .qr-box canvas, .qr-box svg, .qr-box table { width: 196px; height: 196px; image-rendering: pixelated; }
.secret-key { font-family: ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 0.84rem; word-break: break-all; text-align: center; letter-spacing: .04em; }
.code-input input { letter-spacing: 0.5em; font-size: 1.4rem; text-align: center; font-weight: 640; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* ==================== MISC ==================== */
.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--foreground); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 540; max-width: 380px; animation: pop .2s ease; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(10,9,12,.42); display: grid; place-items: center; z-index: 150; padding: 20px; animation: pop .14s ease; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; }
.modal .m-head { padding: 20px 24px 0; display: flex; justify-content: space-between; align-items: center; }
.modal .m-body { padding: 16px 24px 24px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty img { width: 52px; opacity: .35; margin-bottom: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.flex { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-dark); font-weight: 540; margin-bottom: 18px; }
.banner.warn { background: rgba(184,134,11,.12); color: #8a6400; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }

/* ---- date-range slicer ---- */
.slicer-bar { margin-bottom: 18px; }
.slicer { display: flex; flex-direction: column; gap: 12px; }
.slicer .rs { position: relative; height: 30px; }
.slicer .rs .track { position: absolute; top: 12px; left: 0; right: 0; height: 6px; border-radius: 999px; background: var(--surface-2); }
.slicer .rs .fill { position: absolute; top: 12px; height: 6px; border-radius: 999px; background: var(--accent); }
.slicer .rs input[type=range] { position: absolute; top: 0; left: 0; width: 100%; height: 30px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; pointer-events: none; }
.slicer .rs input[type=range]:focus { outline: none; }
.slicer .rs input[type=range]::-webkit-slider-runnable-track { height: 6px; background: transparent; }
.slicer .rs input[type=range]::-moz-range-track { height: 6px; background: transparent; }
.slicer .rs input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: var(--shadow-sm); cursor: grab; }
.slicer .rs input[type=range]::-webkit-slider-thumb:active { cursor: grabbing; }
.slicer .rs input[type=range]::-moz-range-thumb { pointer-events: auto; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: grab; }
.slicer .ends { display: flex; justify-content: space-between; gap: 10px; }
.slicer .ends input[type=date] { width: auto; padding: 7px 10px; font-size: 0.84rem; font-family: var(--font); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--foreground); }
.slicer .ends input[type=date]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.slicer-presets { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "brand" "topbar" "main"; }
  .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; width: 248px; z-index: 120; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: var(--shadow); }
  .builder { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
}
