@layer tokens, reset, base, layout, components, dashboard;

@layer tokens {
  :root {
    color-scheme: dark;
    --bg: oklch(0.12 0.012 265);
    --bg-elev: oklch(0.16 0.014 265);
    --surface: color-mix(in oklab, white 6%, var(--bg));
    --surface-2: color-mix(in oklab, white 9%, var(--bg));
    --line: color-mix(in oklab, white 10%, transparent);
    --text: oklch(0.97 0.005 100);
    --muted: oklch(0.72 0.02 265);
    --accent: oklch(0.9 0.19 132);
    --accent-dim: color-mix(in oklab, var(--accent) 18%, transparent);
    --cyan: oklch(0.82 0.1 210);
    --ok: oklch(0.82 0.16 155);
    --warn: oklch(0.82 0.16 75);
    --bad: oklch(0.68 0.2 25);
    --radius: 1rem;
    --font: "Syne", "Sora", system-ui, sans-serif;
    --body: "Manrope", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
    --shadow: 0 24px 60px color-mix(in oklab, black 45%, transparent);
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; min-height: 100%; }
  img { max-width: 100%; }
  button, input, select, textarea { font: inherit; }
}

@layer base {
  body {
    font-family: var(--body);
    color: var(--text);
    background:
      radial-gradient(900px 480px at 0% -10%, color-mix(in oklab, var(--accent) 12%, transparent), transparent 50%),
      var(--bg);
    letter-spacing: -.01em;
  }
  a { color: var(--accent); text-decoration: none; }
  h1, h2, h3 { font-family: var(--font); letter-spacing: -.04em; margin: 0 0 .4rem; font-weight: 700; }
  p { margin: 0 0 1rem; }
}

@layer layout {
  .kicker {
    font-family: var(--mono);
    font-size: .72rem;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
  }
  .muted { color: var(--muted); font-size: .86rem; }
  .mono { font-family: var(--mono); letter-spacing: .04em; }
  .center { text-align: center; }

  .app {
    display: grid;
    grid-template-columns: 248px 1fr;
    min-height: 100vh;
  }
  .workspace { min-width: 0; display: flex; flex-direction: column; }
  .topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 14px;
    padding: 16px clamp(16px, 3vw, 40px) 0;
  }
  .topbar .who { text-align: right; }
  .topbar .who span { display: block; font-weight: 700; font-size: .92rem; line-height: 1.2; }
  .topbar .who small { color: var(--muted); font-size: .75rem; }
  .sidebar {
    background: color-mix(in oklab, black 35%, var(--bg));
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
  }
  .brand {
    display: flex; gap: 12px; align-items: center;
    color: var(--text); margin: 2px 8px 28px;
  }
  .brand strong { display: block; font-family: var(--font); font-size: 1.05rem; }
  .brand small { display: block; color: var(--muted); font-weight: 500; font-family: var(--mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
  .brand-logo {
    width: 40px; height: 40px; border-radius: 12px;
    display: block; flex: 0 0 auto;
  }
  .brand-logo.lg { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 18px; }
  .brand-mark {
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--accent); color: #111;
    display: grid; place-items: center; font-weight: 800; font-family: var(--font);
  }
  .brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.15rem; }
  .nav-label {
    font-family: var(--mono);
    font-size: .65rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: color-mix(in oklab, var(--muted) 70%, transparent);
    padding: 16px 12px 6px;
  }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar nav a {
    color: var(--muted);
    padding: 10px 12px;
    border-radius: 10px;
    font-weight: 600;
    display: flex; align-items: center; gap: 10px;
  }
  .sidebar nav a svg { width: 18px; height: 18px; flex: 0 0 auto; }
  .sidebar nav a:hover { background: var(--surface); color: var(--text); }
  .sidebar nav a.is-active {
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 35%, transparent);
  }

  .main { padding: 12px clamp(16px, 3vw, 40px) 72px; }
  .page-head { margin-bottom: 22px; }
  .page-head.split, .split { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
  .page-head h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
  .page-head p { color: var(--muted); }
}

@layer components {
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    padding: 11px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease;
  }
  .btn:hover { transform: translateY(-1px); background: var(--surface-2); }
  .btn-primary { background: var(--accent); border-color: transparent; color: #111; }
  .btn-primary:hover { background: color-mix(in oklab, var(--accent) 86%, white); color: #111; }
  .btn-sm { padding: 7px 12px; font-size: .82rem; }
  .btn-whatsapp { width: 100%; margin-top: 14px; background: #16a34a; border-color: #16a34a; color: #fff; }
  .btn-block { width: 100%; }

  .form label, label { display: block; font-size: .76rem; font-weight: 700; margin: 12px 0 6px; color: var(--muted); }
  input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: color-mix(in oklab, black 25%, var(--bg));
    color: var(--text);
  }
  input:focus, select:focus, textarea:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
  }
  textarea { resize: vertical; }
  .hint { color: var(--muted); font-size: .88rem; margin-top: 16px; }

  .flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; border: 1px solid var(--line); }
  .flash-success { background: color-mix(in oklab, var(--ok) 16%, var(--bg)); color: var(--ok); }
  .flash-error { background: color-mix(in oklab, var(--bad) 16%, var(--bg)); color: color-mix(in oklab, var(--bad) 80%, white); }

  .badge {
    display: inline-block; font-size: .72rem; font-weight: 700;
    padding: 3px 8px; border-radius: 999px;
    background: var(--surface-2); color: var(--muted);
    font-family: var(--mono);
  }
  .badge.good { background: color-mix(in oklab, var(--ok) 18%, transparent); color: var(--ok); }
  .badge.bad { background: color-mix(in oklab, var(--bad) 18%, transparent); color: color-mix(in oklab, var(--bad) 85%, white); }

  .stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
  }
  .stats article,
  .panel,
  .kpi-grid article,
  .insight,
  .action-card,
  .period-grid article {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: none;
    color: var(--text);
    backdrop-filter: blur(16px);
  }
  .stats article { padding: 16px 18px; }
  .stats article span {
    display: block; color: var(--muted); font-family: var(--mono);
    font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  }
  .stats article strong { font-family: var(--font); font-size: 1.5rem; }
  .stats article.ok { border-color: color-mix(in oklab, var(--ok) 35%, var(--line)); }
  .stats article.warn { border-color: color-mix(in oklab, var(--bad) 35%, var(--line)); }

  .panel { padding: 18px; margin-bottom: 16px; }
  .panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
  .panel header h3, .panel h3 { color: var(--text); font-size: 1.05rem; }
  .panel p { color: var(--muted); }
  .panel.highlight {
    background: color-mix(in oklab, var(--accent) 8%, var(--surface));
    border-color: color-mix(in oklab, var(--accent) 28%, var(--line));
  }
  .grid-2 { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; }
  .grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 14px; align-items: end; }
  .grid-form.align-top { align-items: start; }
  .grid-form.align-top .hint { margin-top: 8px; line-height: 1.35; }
  .campaign-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px 14px;
    align-items: start;
    margin: 4px 0 8px;
  }
  .campaign-fields > div { min-width: 0; }
  .campaign-fields label { margin-top: 12px; }
  .campaign-fields .hint { margin-top: 8px; min-height: 2.6em; line-height: 1.35; }
  .align-end { display: flex; align-items: end; }
  .full { grid-column: 1 / -1; }

  table { width: 100%; border-collapse: collapse; font-size: .92rem; color: var(--text); }
  th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
  th { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; color: var(--muted); }
  tr:hover td { background: color-mix(in oklab, white 4%, transparent); }

  .log-list { list-style: none; margin: 0; padding: 0; }
  .log-list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
  .cta-row { display: flex; gap: 10px; flex-wrap: wrap; }
  .inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .inline-form input, .inline-form select { width: auto; min-width: 120px; }
  .checks { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
  .check {
    display: flex; gap: 8px; align-items: center;
    background: var(--bg-elev); border: 1px solid var(--line);
    padding: 8px 10px; border-radius: 10px; margin: 0; font-weight: 600; color: var(--text);
  }
  .check input { width: auto; }
  .steps { margin: 0; padding-left: 18px; color: var(--muted); }
  .steps li { margin: 8px 0; }
  .price { font-family: var(--font); font-size: 2rem; margin: 0 0 12px; }
  .code-input { font-size: 1.2rem; letter-spacing: .08em; text-transform: uppercase; font-family: var(--mono); }

  .action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 20px; }
  .action-card { display: block; padding: 18px; transition: border-color .15s ease; }
  .action-card:hover { border-color: var(--accent); color: var(--text); }
  .action-card.primary { background: var(--accent); color: #111; border-color: transparent; }
  .action-card.primary .muted, .action-card.primary h3 { color: #111; }
  .action-card h3 { margin: 0 0 6px; }
  .action-card .muted { margin: 0; }
  .action-ico {
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--accent-dim); color: var(--accent);
    display: grid; place-items: center; margin-bottom: 12px;
  }
  .action-card.primary .action-ico { background: color-mix(in oklab, black 12%, transparent); color: #111; }

  .auth-body {
    min-height: 100vh;
    display: grid; place-items: center; padding: 24px;
    background:
      radial-gradient(700px 360px at 85% 0%, color-mix(in oklab, var(--accent) 16%, transparent), transparent 50%),
      var(--bg);
  }
  .auth-wrap { width: min(1040px, 100%); display: grid; grid-template-columns: 1.08fr .92fr; gap: 48px; align-items: center; }
  .auth-brand h1 { font-size: clamp(2.4rem, 5vw, 3.4rem); margin-bottom: 10px; }
  .auth-brand .auth-lead {
    color: var(--text);
    font-size: 1.14rem;
    line-height: 1.45;
    max-width: 420px;
    margin-bottom: 8px;
  }
  .auth-points {
    list-style: none;
    margin: 22px 0 0;
    padding: 0;
    display: grid;
    gap: 16px;
    max-width: 420px;
  }
  .auth-points li {
    color: var(--muted);
    font-size: .95rem;
    line-height: 1.45;
    padding-left: 14px;
    border-left: 2px solid var(--accent);
  }
  .auth-points strong {
    display: block;
    color: var(--text);
    font-family: var(--font);
    font-size: 1.02rem;
    margin-bottom: 2px;
  }
  .auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 32px;
    backdrop-filter: blur(20px);
  }
  .auth-card h2, .auth-card .page-head h2 { color: var(--text); }
  .auth-card .page-head p { color: var(--muted); }
  .pay-box {
    display: grid; grid-template-columns: 1fr 180px; gap: 16px;
    background: var(--bg-elev); border: 1px solid var(--line);
    border-radius: 16px; padding: 16px; margin: 16px 0;
  }
  .qr-hold { display: grid; place-items: center; }
  .copy-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
  #pix-qr, #store-qr { background: #fff; padding: 10px; border-radius: 14px; }
  .error-box { text-align: center; padding: 24px; }

  .qr-studio {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(240px, 1fr);
    gap: 22px;
    align-items: start;
  }
  .qr-poster {
    position: relative;
    overflow: hidden;
    background:
      radial-gradient(680px 280px at 100% -10%, color-mix(in oklab, var(--accent) 38%, transparent), transparent 58%),
      radial-gradient(420px 220px at -10% 110%, color-mix(in oklab, var(--accent) 16%, transparent), transparent 55%),
      #101214;
    color: #f6f7f2;
    border: 1px solid color-mix(in oklab, var(--accent) 28%, var(--line));
    border-radius: 28px;
    padding: 28px 24px 26px;
    text-align: center;
    box-shadow: var(--shadow);
  }
  .qr-poster-glow {
    position: absolute; inset: auto -40px -80px auto;
    width: 180px; height: 180px;
    background: var(--accent);
    filter: blur(70px);
    opacity: .28;
    pointer-events: none;
  }
  .qr-brand {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    text-align: left; margin-bottom: 22px;
  }
  .qr-brand strong { display: block; font-family: var(--font); font-size: 1.15rem; line-height: 1.15; }
  .qr-brand small { color: color-mix(in oklab, white 55%, var(--accent)); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .68rem; }
  .qr-logo, .qr-mark {
    width: 64px; height: 64px; border-radius: 18px; flex: 0 0 auto;
    object-fit: cover; background: #fff;
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 55%, transparent);
  }
  .qr-mark {
    display: grid; place-items: center;
    background: var(--accent); color: #111;
    font-family: var(--font); font-weight: 800; font-size: 1.15rem;
  }
  .qr-kicker {
    position: relative;
    display: inline-block;
    margin: 0 0 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: color-mix(in oklab, var(--accent) 18%, transparent);
    color: var(--accent);
    font-weight: 800;
    font-size: .72rem;
    letter-spacing: .12em;
    text-transform: uppercase;
  }
  .qr-poster h3 {
    position: relative;
    font-size: clamp(1.55rem, 4vw, 2.05rem);
    line-height: 1.12;
    margin: 0 0 10px;
  }
  .qr-lead { position: relative; color: color-mix(in oklab, white 72%, transparent); margin: 0 0 18px; }
  .qr-frame {
    position: relative;
    display: grid; place-items: center;
    margin: 0 auto 18px;
    padding: 16px;
    width: min(100%, 280px);
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 16px 40px color-mix(in oklab, black 45%, transparent);
  }
  .qr-poster #store-qr { background: transparent; padding: 0; border-radius: 0; }
  .qr-poster #store-qr img, .qr-poster #store-qr canvas { display: block; width: 220px; height: 220px; }
  .qr-steps {
    position: relative;
    list-style: none; padding: 0; margin: 0 0 14px;
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
    font-size: .78rem; font-weight: 700;
  }
  .qr-steps li {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    color: color-mix(in oklab, white 82%, transparent);
  }
  .qr-steps span {
    width: 28px; height: 28px; border-radius: 999px;
    display: grid; place-items: center;
    background: var(--accent); color: #111; font-weight: 800;
  }
  .qr-foot { position: relative; margin: 0; color: var(--accent); font-weight: 700; font-size: .9rem; }
  .qr-toolbar h3 { margin-top: 0; }
  .qr-toolbar .btn + .btn { margin-top: 8px; }
  .qr-url { margin-top: 14px; font-size: .72rem; word-break: break-all; color: var(--muted); }
  .logo-preview {
    width: 72px; height: 72px; object-fit: cover; border-radius: 16px;
    border: 1px solid var(--line); margin-bottom: 10px; background: #fff;
    display: block;
  }
  .error-box { text-align: center; padding: 24px; }

  .public-body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }
  .scratch-app {
    width: min(420px, 100%);
    margin: 0 auto;
    padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  }
  .scratch-hero { text-align: center; margin-bottom: 18px; }
  .scratch-hero[hidden], #step-phone[hidden], #step-scratch[hidden] { display: none !important; }
  .scratch-app.is-scratching {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100dvh;
    padding-top: 16px;
  }
  .scratch-app.is-scratching .scratch-hero,
  .scratch-app.is-scratching #step-phone { display: none !important; }
  .scratch-play { padding: 20px 16px 22px; }
  .scratch-app.is-scratching .foil-wrap,
  .scratch-app.is-scratching .prize-face { min-height: min(58dvh, 420px); }
  #hello {
    margin: 0 0 12px;
    text-align: center;
    font-weight: 700;
    line-height: 1.35;
  }
  .scratch-visual {
    width: 100%;
    aspect-ratio: 1;
    max-height: min(320px, 72vw);
    object-fit: cover;
    object-position: center;
    border-radius: 24px;
    border: 1px solid var(--line);
    margin-bottom: 16px;
    background: #0a0a0a;
  }
  .scratch-hero h1 {
    font-size: clamp(1.45rem, 6vw, 1.9rem);
    line-height: 1.15;
    margin: 0;
  }
  .scratch-lead {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: .98rem;
    line-height: 1.4;
  }
  .scratch-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 24px; padding: 18px;
  }
  .foil-wrap { position: relative; margin-top: 12px; border-radius: 20px; overflow: hidden; min-height: 240px; background: #111; }
  .prize-face {
    position: relative;
    overflow: hidden;
    min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 24px;
    background: radial-gradient(circle at 50% 20%, color-mix(in oklab, var(--accent) 55%, white), var(--accent) 60%, #1a1a12);
    color: #111;
  }
  .prize-logo {
    position: absolute;
    left: 50%; top: 50%;
    width: 78%;
    height: 78%;
    transform: translate(-50%, -50%);
    object-fit: contain;
    opacity: .2;
    pointer-events: none;
    filter: drop-shadow(0 8px 18px rgba(0,0,0,.12));
  }
  .prize-copy { position: relative; z-index: 1; }
  .prize-copy small { font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .72rem; }
  .prize-copy p { margin: 8px 0 0; font-weight: 600; }
  .prize-face.is-revealed { animation: prizePop .5s ease; }
  @keyframes prizePop {
    0% { transform: scale(.97); }
    45% { transform: scale(1.03); }
    100% { transform: scale(1); }
  }
  .prize-face strong { font-size: 1.8rem; font-family: var(--font); }
  .confetti-layer {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 60;
    display: none;
  }
  .code-pill {
    margin-top: 12px; background: #111; color: var(--accent);
    padding: 10px 14px; border-radius: 999px; font-weight: 800; font-family: var(--mono);
  }
  .scratch-save { margin-top: 16px; }
  .scratch-save .code-label {
    font-size: .76rem; font-weight: 700; color: var(--muted); margin: 0 0 8px;
    text-transform: uppercase; letter-spacing: .08em;
  }
  .code-save {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  }
  .code-save strong {
    font-family: var(--mono); font-size: 1.35rem; letter-spacing: .12em;
    background: color-mix(in oklab, black 30%, var(--bg));
    border: 1px solid var(--line);
    padding: 10px 14px; border-radius: 12px;
  }
  .code-save .btn { white-space: nowrap; }
  .scratch-next {
    margin: 14px 0 0;
    color: var(--text);
    font-size: .95rem;
    line-height: 1.5;
  }
  .scratch-expire {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: color-mix(in oklab, var(--warn) 16%, var(--bg));
    border: 1px solid color-mix(in oklab, var(--warn) 40%, var(--line));
    color: color-mix(in oklab, var(--warn) 85%, white);
    font-weight: 700;
    font-size: .92rem;
    line-height: 1.4;
  }
  .scratch-expire[hidden] { display: none !important; }
  #foil { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
  .scratch-hint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: #fff; pointer-events: none; font-weight: 700; }
  .error { color: var(--bad); font-weight: 700; }

  .period-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .period-grid article { padding: 14px 16px; }
  .period-grid strong { font-size: 1.8rem; display: block; font-family: var(--font); }
  .mini-stats { margin: 8px 0 0; padding-left: 16px; color: var(--muted); font-size: .86rem; }
  .mini-stats b { color: var(--text); }

  .filter-bar, .filter-grid { display: grid; gap: 10px; margin-bottom: 16px; }
  .filter-bar { grid-template-columns: 1fr auto auto; align-items: end; }
  .filter-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
  .filter-actions { display: flex; gap: 8px; align-items: end; }

  .client-box {
    background: var(--accent-dim); border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--line));
    border-radius: 14px; padding: 12px 14px; margin: 10px 0;
    display: flex; flex-direction: column; gap: 2px;
  }
  .client-box.warn { background: color-mix(in oklab, var(--warn) 14%, var(--bg)); border-color: color-mix(in oklab, var(--warn) 40%, var(--line)); }
  .client-box.bad { background: color-mix(in oklab, var(--bad) 14%, var(--bg)); border-color: color-mix(in oklab, var(--bad) 40%, var(--line)); }
  .client-box.ok { background: color-mix(in oklab, var(--ok) 14%, var(--bg)); border-color: color-mix(in oklab, var(--ok) 40%, var(--line)); }
  .client-box[hidden], #name-wrap[hidden], .pay-preview[hidden], #client-inactive[hidden] { display: none !important; }
  .pay-preview {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
    margin: 12px 0; padding: 12px; border-radius: 12px;
    background: var(--accent-dim); border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--line));
    font-size: .86rem; color: var(--muted);
  }
  .pay-preview strong { display: block; color: var(--text); font-size: 1rem; margin-top: 2px; }

  .modal {
    position: fixed; inset: 0; z-index: 80;
    display: grid; place-items: center;
    padding: 16px;
  }
  .modal[hidden] { display: none !important; }
  .modal-backdrop {
    position: absolute; inset: 0;
    background: color-mix(in oklab, black 58%, transparent);
  }
  .modal-card {
    position: relative;
    width: min(480px, 100%);
    max-height: min(92vh, 840px);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px 18px 22px;
    box-shadow: var(--shadow);
  }
  .modal-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  }
  .modal-head h3 { margin: 0; font-size: 1.25rem; }
  .modal-lead { color: var(--muted); margin: 8px 0 4px; font-size: .92rem; line-height: 1.45; }
  body.modal-open { overflow: hidden; }

  .type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 16px; }
  .type-card {
    border: 1px solid var(--line); border-radius: 16px; padding: 14px; cursor: pointer;
    background: var(--bg-elev); display: flex; flex-direction: column; gap: 6px; margin: 0; font-weight: 500;
  }
  .type-card strong { font-size: .98rem; }
  .type-card span { color: var(--muted); font-size: .82rem; }
  .type-card input { display: none; }
  .type-card:has(input:checked) {
    background: var(--accent-dim);
    border-color: var(--accent);
  }
}

@layer dashboard {
  .bento {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
    margin-bottom: 16px;
  }
  .bento > * { margin: 0; }
  .span-12 { grid-column: span 12; }
  .span-8 { grid-column: span 8; }
  .span-6 { grid-column: span 6; }
  .span-4 { grid-column: span 4; }
  .span-3 { grid-column: span 3; }

  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 0;
  }
  .kpi-grid article { padding: 16px 18px; }
  .kpi-grid span {
    display: flex; justify-content: space-between; gap: 8px;
    color: var(--muted); font-family: var(--mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  }
  .kpi-grid strong { display: block; font-family: var(--font); font-size: 1.45rem; margin: 8px 0 4px; }
  .kpi-grid small { color: var(--muted); }
  .delta { font-size: .72rem; padding: 2px 7px; border-radius: 999px; font-weight: 800; font-family: var(--mono); }
  .delta.up { background: color-mix(in oklab, var(--ok) 18%, transparent); color: var(--ok); }
  .delta.down { background: color-mix(in oklab, var(--bad) 18%, transparent); color: color-mix(in oklab, var(--bad) 85%, white); }
  .up-txt { color: var(--ok); }

  .metric-console {
    font-family: var(--mono);
    font-size: .78rem;
    background: color-mix(in oklab, black 40%, var(--bg));
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
  }
  .metric-console header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-bottom: 1px solid var(--line); margin: 0;
  }
  .metric-console header h3 { font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; margin: 0; color: var(--muted); }
  .dots { display: flex; gap: 6px; }
  .dots i { width: 8px; height: 8px; border-radius: 50%; background: #3f3f46; display: block; }
  .dots i:first-child { background: #f87171; }
  .dots i:nth-child(2) { background: #fbbf24; }
  .dots i:last-child { background: var(--accent); }
  .metric-console .body { padding: 16px; }
  .live { color: var(--accent); }

  .insight-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 0; }
  .insight { padding: 16px 18px; border-top: 0; border-left: 3px solid var(--accent); }
  .insight.tone-green { border-left-color: var(--ok); }
  .insight.tone-gold { border-left-color: var(--warn); }
  .insight.tone-warn { border-left-color: var(--warn); }
  .insight.tone-blue { border-left-color: var(--cyan); }
  .insight h3 { font-size: 1rem; margin-bottom: 6px; }
  .insight p { margin: 0; color: var(--muted); font-size: .9rem; }

  .funnel { display: grid; gap: 10px; }
  .funnel-row { display: grid; grid-template-columns: 1fr 52px; gap: 10px; align-items: center; }
  .funnel-row span { font-size: .8rem; color: var(--muted); }
  .funnel-bar { grid-column: 1 / -1; background: color-mix(in oklab, white 6%, transparent); border-radius: 999px; height: 8px; overflow: hidden; }
  .funnel-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
  .funnel-row strong { font-family: var(--mono); font-size: .9rem; text-align: right; }

  .hour-bars { display: flex; gap: 5px; align-items: end; height: 130px; }
  .hour-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
  .hour-fill { flex: 1; width: 100%; background: color-mix(in oklab, white 6%, transparent); border-radius: 6px 6px 2px 2px; display: flex; align-items: end; overflow: hidden; }
  .hour-fill i { display: block; width: 100%; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; opacity: .55; }
  .hour-col.is-peak .hour-fill i { opacity: 1; }
  .hour-col small { color: var(--muted); font-size: .65rem; font-family: var(--mono); }

  .hero-gain { display: none; }

  .exec { max-width: 1280px; }
  .exec-head { margin-bottom: 18px; }
  .exec-head h2 { font-size: clamp(1.7rem, 3.2vw, 2.35rem); }
  .exec-head p { color: var(--muted); max-width: 42rem; margin: 0; }

  .exec-filters {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px 18px;
    margin-bottom: 18px;
  }
  .period-chips {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 14px;
  }
  .chip {
    display: inline-flex; align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: color-mix(in oklab, black 18%, var(--bg));
    color: var(--muted);
    font-weight: 700;
    font-size: .82rem;
  }
  .chip:hover { color: var(--text); background: var(--surface-2); }
  .chip.is-on {
    background: var(--accent);
    border-color: transparent;
    color: #111;
  }
  .exec-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr auto;
    gap: 12px 14px;
    align-items: end;
  }
  .exec-form label { margin-top: 0; }
  .exec-form .align-end { display: flex; align-items: end; }
  .exec-form .btn { white-space: nowrap; }

  .exec-kpis {
    display: grid;
    grid-template-columns: 1.35fr 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
  }
  .exec-kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .exec-kpi.is-hero {
    background:
      linear-gradient(180deg, color-mix(in oklab, var(--accent) 10%, transparent), transparent 58%),
      var(--surface);
    border-color: color-mix(in oklab, var(--accent) 28%, var(--line));
  }
  .kpi-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--accent-dim);
    color: var(--accent);
    margin-bottom: 12px;
  }
  .kpi-icon svg { width: 18px; height: 18px; }
  .exec-kpi span {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .exec-kpi strong {
    display: block;
    font-family: var(--font);
    font-size: clamp(1.55rem, 2.4vw, 2.15rem);
    letter-spacing: -.04em;
    margin: 8px 0 10px;
    line-height: 1.05;
  }
  .exec-kpi.is-hero strong { font-size: clamp(1.85rem, 3vw, 2.55rem); color: var(--text); }
  .exec-kpi p {
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.45;
    margin: 0 0 auto;
    padding-bottom: 12px;
  }
  .exec-kpi .delta { margin-top: 12px; width: fit-content; }
  .down-txt { color: color-mix(in oklab, var(--bad) 85%, white); }

  .exec-chart { margin-bottom: 16px; }
  .exec-chart canvas { width: 100% !important; max-height: 320px; }

  .exec-split {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(260px, .9fr);
    gap: 14px;
    margin-bottom: 16px;
  }
  .rank-sort {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin: 0 0 14px;
  }
  .rank-sort a {
    color: var(--muted);
    font-size: .8rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
  }
  .rank-sort a.is-on, .rank-sort a:hover {
    color: #111;
    background: var(--accent);
    border-color: transparent;
  }
  .exec-rank { min-width: 0; }
  .exec-rank .rank-table { min-width: 560px; }
  .rank-table .pos { width: 72px; font-size: 1.05rem; }
  .rank-table tr.is-on td {
    background: var(--accent-dim);
  }
  .rank-table a { color: var(--text); font-weight: 700; }
  .rank-table a:hover { color: var(--accent); }

  .exec-best {
    border-color: color-mix(in oklab, var(--accent) 26%, var(--line));
    background:
      linear-gradient(180deg, color-mix(in oklab, var(--accent) 8%, transparent), transparent 42%),
      var(--surface);
  }
  .exec-best .best-name {
    font-family: var(--font);
    font-size: 1.55rem;
    letter-spacing: -.04em;
    margin: 4px 0 14px;
    color: var(--text);
  }
  .best-stats { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
  .best-stats li { color: var(--muted); }
  .best-stats strong { color: var(--text); font-family: var(--font); font-size: 1.05rem; }

  .exec-summary p {
    font-size: 1.02rem;
    line-height: 1.65;
    color: var(--text) !important;
    margin: 0;
    max-width: 70ch;
  }
}

@media (max-width: 1100px) {
  .span-8, .span-6, .span-4, .span-3 { grid-column: span 12; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .exec-kpis { grid-template-columns: 1fr 1fr; }
  .exec-kpi.is-hero { grid-column: 1 / -1; }
  .exec-form { grid-template-columns: 1fr 1fr; }
  .exec-split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 20;
    padding: 10px 10px 8px;
    backdrop-filter: blur(16px);
    background: color-mix(in oklab, black 55%, var(--bg));
  }
  .brand { margin: 0 4px 8px; }
  .brand small { display: none; }
  .sidebar nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar nav a {
    white-space: nowrap;
    padding: 10px 12px;
    min-height: 42px;
    font-size: .86rem;
  }
  .nav-label { display: none; }
  .grid-2, .auth-wrap, .pay-box, .period-grid, .type-grid, .campaign-fields, .filter-bar, .insight-grid, .exec-form, .exec-kpis, .qr-studio { grid-template-columns: 1fr; }
  .topbar { padding: 10px 16px 0; }
  .main { padding: 12px 16px 40px; }
  .panel { overflow-x: auto; }
  .cta-row { width: 100%; }
  .cta-row .btn { flex: 1; }
  .hour-bars { overflow-x: auto; }
  .inline-form { width: 100%; }
  .inline-form input, .inline-form select { min-width: 0; flex: 1; }
}
@media (max-width: 720px) {
  .page-head h2 { font-size: 1.45rem; }
  .auth-body { padding: 16px; align-items: start; }
  .auth-card { padding: 22px 18px; }
  .auth-brand h1 { font-size: 2rem; }
  .kpi-grid strong { font-size: 1.25rem; }
  table { font-size: .86rem; }
  th, td { padding: 10px 6px; }
  .pay-preview { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar .who small { display: none; }
  .scratch-visual { max-height: 240px; }
  .btn, .btn-block { min-height: 46px; }
  .workspace .topbar { padding: 8px 12px 0; }
}

@media print {
  @page { size: A5 portrait; margin: 10mm; }
  body { background: #fff !important; }
  .sidebar, .topbar, .page-head, .qr-toolbar, .flash { display: none !important; }
  .workspace, .main { padding: 0 !important; margin: 0 !important; }
  .qr-studio { display: block; }
  .qr-poster {
    box-shadow: none;
    max-width: none;
    min-height: calc(100vh - 20mm);
    break-inside: avoid;
  }
}
