/* Mailand by AK Technology — design tokens and components */
:root {
  --bg: #F3F5F9; --surface: #FFFFFF; --surface-2: #F8F9FC; --sunken: #EEF1F6;
  --ink: #0F1B2D; --ink-2: #33405A; --muted: #5E6B80; --faint: #8C97AA;
  --line: #E2E6EE; --line-2: #D3D9E4;
  --primary: #3A36DB; --primary-hover: #2D29B8; --primary-ink: #FFFFFF; --primary-soft: #ECEBFF; --primary-text: #2F2BC2;
  --green: #0E9F6E; --green-soft: #E3F6EE; --green-text: #067251;
  --amber: #C77700; --amber-soft: #FFF3DC; --amber-text: #8F5400;
  --red: #D92D20; --red-soft: #FDECEA; --red-text: #B42318;
  --blue: #2F6FEB; --blue-soft: #E7F0FF;
  --violet: #7A4DF0;
  --shadow-1: 0 1px 2px rgba(15, 27, 45, .05);
  --shadow-2: 0 1px 2px rgba(15, 27, 45, .05), 0 6px 24px -8px rgba(15, 27, 45, .12);
  --shadow-pop: 0 2px 6px rgba(15, 27, 45, .08), 0 24px 60px -12px rgba(15, 27, 45, .28);
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", "Onest", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --side: 252px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0F1E; --surface: #111830; --surface-2: #141C36; --sunken: #0D1326;
    --ink: #E9EDF7; --ink-2: #C3CBDD; --muted: #93A0B8; --faint: #6D7A94;
    --line: #222B46; --line-2: #2D3756;
    --primary: #6F6BFF; --primary-hover: #8783FF; --primary-ink: #FFFFFF; --primary-soft: #1F1F4D; --primary-text: #A9A6FF;
    --green: #2BC48A; --green-soft: #0F2E26; --green-text: #5DDBA9;
    --amber: #F0A43A; --amber-soft: #33260E; --amber-text: #F5BE6E;
    --red: #F2665B; --red-soft: #3A1717; --red-text: #F69990;
    --blue-soft: #14244A;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px -10px rgba(0, 0, 0, .5); --shadow-pop: 0 24px 60px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0F1E; --surface: #111830; --surface-2: #141C36; --sunken: #0D1326;
  --ink: #E9EDF7; --ink-2: #C3CBDD; --muted: #93A0B8; --faint: #6D7A94;
  --line: #222B46; --line-2: #2D3756;
  --primary: #6F6BFF; --primary-hover: #8783FF; --primary-ink: #FFFFFF; --primary-soft: #1F1F4D; --primary-text: #A9A6FF;
  --green: #2BC48A; --green-soft: #0F2E26; --green-text: #5DDBA9;
  --amber: #F0A43A; --amber-soft: #33260E; --amber-text: #F5BE6E;
  --red: #F2665B; --red-soft: #3A1717; --red-text: #F69990;
  --blue-soft: #14244A;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px -10px rgba(0, 0, 0, .5); --shadow-pop: 0 24px 60px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-soft); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; } svg.i.lg { width: 22px; height: 22px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; } .mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; } .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-name { font: 700 19px/1 var(--display); letter-spacing: -.02em; }
.brand-sub { font-size: 11px; color: var(--faint); margin-top: 3px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.nav-group { margin-top: 14px; }
.nav-title { font-size: 12px; color: var(--faint); padding: 0 10px 6px; font-weight: 500; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2); font-weight: 500; position: relative; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--primary-soft); color: var(--primary-text); }
.nav a.on svg { stroke: var(--primary-text); }
.nav a svg { stroke: var(--muted); }
.nav .count { margin-left: auto; font-size: 11.5px; font-weight: 600; background: var(--primary); color: #fff; border-radius: 99px; padding: 1px 7px; min-width: 20px; text-align: center; }
.side-foot { border-top: 1px solid var(--line); padding: 12px 14px; }
.engine-pill { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot.live { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid transparent; }
.top.scrolled { border-bottom-color: var(--line); }
.search-btn { display: flex; align-items: center; gap: 10px; width: min(420px, 100%); height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--faint); cursor: pointer; text-align: left; }
.search-btn:hover { border-color: var(--line-2); }
.kbd { font: 500 11px var(--font); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--muted); background: var(--surface-2); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--surface); }
.icon-btn .badge-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid var(--bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); display: grid; place-items: center; font-weight: 700; font-size: 12.5px; overflow: hidden; border: 0; cursor: pointer; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu-toggle { display: none; }
.content { padding: 26px 28px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }
.content.wide { max-width: 1400px; }

/* ---------- page header ---------- */
.ph { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.ph h1 { font: 650 30px/1.1 var(--display); letter-spacing: -.025em; margin: 0; }
.ph p { margin: 6px 0 0; color: var(--muted); max-width: 640px; }
.ph .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.back:hover { color: var(--ink); text-decoration: none; }
h2 { font: 600 16px/1.3 var(--font); margin: 0; letter-spacing: -.01em; }
h3 { font: 600 14px/1.3 var(--font); margin: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 4px 14px -4px color-mix(in srgb, var(--primary) 55%, transparent); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--red-text); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.xs { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: 7px; gap: 6px; }
.btn.icon { width: 34px; padding: 0; } .btn.sm.icon { width: 32px; } .btn.xs.icon { width: 28px; }
.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }
.btn.loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-weight: 600; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.lbl .opt { margin-left: auto; font-weight: 400; color: var(--faint); }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, textarea.input { width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; }
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover { border-color: var(--faint); }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.err { border-color: var(--red); }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238C97AA' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; }
.input-group { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); overflow: hidden; }
.input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-group .input { border: 0; box-shadow: none !important; }
.input-group .addon { padding: 0 12px; color: var(--muted); white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-section { font-weight: 650; font-size: 13.5px; margin: 6px 0 -2px; }

.switch { position: relative; width: 38px; height: 22px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 99px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.toggle-row { display: flex; align-items: flex-start; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); }
.toggle-row:first-child { border-top: 0; }
.toggle-row .t { flex: 1; } .toggle-row .t b { display: block; font-weight: 600; } .toggle-row .t span { color: var(--muted); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.seg { display: inline-flex; background: var(--sunken); padding: 3px; border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button, .tabs a { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.tabs button:hover, .tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs .on { color: var(--ink); border-bottom-color: var(--primary); }
.tabs .n { font-size: 11.5px; background: var(--sunken); color: var(--muted); border-radius: 99px; padding: 0 7px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 99px; padding: 5px 12px; font-weight: 500; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { border-color: var(--line-2); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip .n { opacity: .7; font-size: 12px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card.pad { padding: 20px; }
.card-h { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-h p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-b { padding: 18px 20px; }
.card-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }

.stat { padding: 18px 20px; position: relative; }
.stat .k { color: var(--muted); font-weight: 500; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat .k svg { stroke: var(--faint); }
.stat .v { font: 650 30px/1.1 var(--display); letter-spacing: -.03em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat .v small { font: 500 14px var(--font); color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.stat .s { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ---------- pipeline (dashboard signature) ---------- */
.pipe { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: relative; overflow: hidden; }
.pipe-step { padding: 22px 22px 20px; position: relative; }
.pipe-step + .pipe-step { border-left: 1px solid var(--line); }
.pipe-step .k { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.pipe-step .v { font: 650 40px/1 var(--display); letter-spacing: -.035em; margin-top: 12px; font-variant-numeric: tabular-nums; }
.pipe-step .s { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.pipe-step .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--sunken); }
.pipe-step.q .ico { color: var(--amber); background: var(--amber-soft); }
.pipe-step.s1 .ico { color: var(--primary-text); background: var(--primary-soft); }
.pipe-step.r .ico { color: var(--green-text); background: var(--green-soft); }
.pipe-step.rate .ico { color: var(--violet); background: color-mix(in srgb, var(--violet) 14%, transparent); }
.pipe-track { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--sunken); overflow: hidden; }
.pipe-track i { position: absolute; top: 0; bottom: 0; width: 22%; background: linear-gradient(90deg, transparent, var(--primary), transparent); animation: travel 3.2s cubic-bezier(.5,0,.5,1) infinite; }
.pipe-track.idle i { display: none; }
@keyframes travel { from { left: -22%; } to { left: 100%; } }
.pipe-step .arrow { position: absolute; right: -11px; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; z-index: 2; color: var(--faint); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.t th:first-child { padding-left: 20px; } .t td:first-child { padding-left: 20px; }
.t th:last-child, .t td:last-child { padding-right: 20px; }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: var(--surface-2); }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.t .chk { width: 36px; }

.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
a.list-item { color: inherit; } a.list-item:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--sunken); color: var(--ink-2); }
.badge.green { background: var(--green-soft); color: var(--green-text); }
.badge.amber { background: var(--amber-soft); color: var(--amber-text); }
.badge.red { background: var(--red-soft); color: var(--red-text); }
.badge.blue, .badge.primary { background: var(--primary-soft); color: var(--primary-text); }
.badge .dot { width: 6px; height: 6px; box-shadow: none; background: currentColor; }

/* ---------- progress ---------- */
.bar { height: 6px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s; }
.bar.green i { background: var(--green); } .bar.amber i { background: var(--amber); } .bar.red i { background: var(--red); }
.stackbar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--sunken); gap: 2px; }
.stackbar i { display: block; height: 100%; }
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; font: 650 20px var(--display); letter-spacing: -.02em; }

/* ---------- empty / skeleton ---------- */
.empty { text-align: center; padding: 48px 24px; }
.empty .art { width: 64px; height: 64px; border-radius: 18px; background: var(--primary-soft); color: var(--primary-text); display: grid; place-items: center; margin: 0 auto 16px; }
.empty h3 { font: 600 18px var(--display); letter-spacing: -.01em; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 18px; }
.skel { background: linear-gradient(90deg, var(--sunken) 0%, var(--surface-2) 50%, var(--sunken) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- overlay: modal, drawer, palette ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 15, 30, .42); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-pop); animation: rise .18s ease-out; border: 1px solid var(--line); }
.modal.lg { width: min(760px, 100%); } .modal.xl { width: min(980px, 100%); }
@keyframes rise { from { transform: translateY(10px) scale(.985); opacity: 0; } }
.modal-h { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 8px; }
.modal-h h2 { font: 650 19px/1.25 var(--display); letter-spacing: -.015em; }
.modal-h p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.modal-b { padding: 14px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; align-items: center; border-top: 1px solid var(--line); }
.drawer-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(10, 15, 30, .32); animation: fade .15s; }
.drawer { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; animation: slide .2s ease-out; border-left: 1px solid var(--line); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-h { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-b { padding: 18px 22px; overflow-y: auto; flex: 1; }
.palette { position: fixed; inset: 0; z-index: 120; background: rgba(10, 15, 30, .42); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; animation: fade .12s; }
.palette-box { width: min(620px, calc(100% - 32px)); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop); overflow: hidden; border: 1px solid var(--line); }
.palette-box .input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; height: 54px; font-size: 16px; padding: 0 18px; box-shadow: none !important; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--ink); }
.palette-item.on, .palette-item:hover { background: var(--primary-soft); text-decoration: none; }
.palette-item .type { font-size: 11.5px; color: var(--muted); width: 72px; flex: none; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-pop); display: flex; gap: 10px; align-items: center; font-weight: 500; animation: rise .2s ease-out; pointer-events: auto; max-width: min(520px, calc(100vw - 32px)); }
.toast.err { background: var(--red); color: #fff; }
.toast svg { flex: none; }

.menu { position: fixed; z-index: 150; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px; min-width: 190px; animation: fade .1s; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; color: var(--ink); font-weight: 500; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu .danger { color: var(--red-text); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .mh { padding: 8px 10px 6px; font-size: 12.5px; color: var(--muted); }

.alert { display: flex; gap: 12px; padding: 13px 16px; border-radius: 12px; background: var(--primary-soft); color: var(--ink); align-items: flex-start; }
.alert svg { margin-top: 1px; color: var(--primary-text); }
.alert.amber { background: var(--amber-soft); } .alert.amber svg { color: var(--amber-text); }
.alert.red { background: var(--red-soft); } .alert.red svg { color: var(--red-text); }
.alert.green { background: var(--green-soft); } .alert.green svg { color: var(--green-text); }
.alert b { display: block; margin-bottom: 2px; }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart .bar-r { fill: var(--primary); }
.chart .bar-r:hover { fill: var(--primary-hover); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; z-index: 160; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12.5px; padding: 7px 10px; border-radius: 8px; white-space: nowrap; box-shadow: var(--shadow-pop); }

/* ---------- editor ---------- */
.editor { border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); overflow: hidden; }
.editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.toolbar { display: flex; align-items: center; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.toolbar button { width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.toolbar button:hover { background: var(--sunken); }
.toolbar .sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 4px; }
.toolbar .var-btn { width: auto; padding: 0 10px; font-weight: 600; font-size: 12.5px; gap: 6px; display: flex; align-items: center; color: var(--primary-text); }
.rte { min-height: 220px; padding: 14px 16px; outline: none; line-height: 1.6; overflow-wrap: anywhere; }
.rte p { margin: 0 0 10px; } .rte p:last-child { margin-bottom: 0; }
.rte:empty::before { content: attr(data-placeholder); color: var(--faint); }
.rte ul, .rte ol { margin: 0 0 10px; padding-left: 22px; }
.subject-input { font-weight: 600; }

.email-preview { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.email-preview .eh { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; }
.email-preview .eh .subj { font-weight: 650; font-size: 15px; }
.email-preview .eb { padding: 18px; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 1.55; color: #1f2328; background: #fff; overflow-wrap: anywhere; }
.email-preview .eb p { margin: 0 0 12px; }
.email-preview pre { white-space: pre-wrap; font-family: Arial, sans-serif; margin: 0; }
.var { background: var(--primary-soft); color: var(--primary-text); border-radius: 5px; padding: 0 4px; font-weight: 600; }

/* ---------- sequence builder ---------- */
.seq { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.seq-list { display: flex; flex-direction: column; gap: 0; position: sticky; top: 76px; }
.seq-item { display: flex; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; cursor: pointer; position: relative; text-align: left; width: 100%; }
.seq-item:hover { border-color: var(--line-2); }
.seq-item.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.seq-item .n { width: 26px; height: 26px; border-radius: 8px; background: var(--sunken); display: grid; place-items: center; font-weight: 700; font-size: 12.5px; flex: none; color: var(--ink-2); }
.seq-item.on .n { background: var(--primary); color: #fff; }
.seq-item.off { opacity: .55; }
.seq-wait { display: flex; align-items: center; gap: 8px; padding: 8px 0 8px 26px; color: var(--muted); font-size: 12.5px; position: relative; }
.seq-wait::before { content: ""; position: absolute; left: 26px; top: 0; bottom: 0; border-left: 2px dashed var(--line-2); }
.seq-wait span { margin-left: 14px; background: var(--bg); padding: 2px 0; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.provider-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.provider { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface); text-align: left; align-items: flex-start; }
.provider:hover { border-color: var(--primary); background: var(--primary-soft); }
.provider .logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; color: #fff; }
.provider b { display: block; } .provider span { font-size: 12.5px; color: var(--muted); }
.mb-logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; font-size: 15px; }
.dropzone { border: 2px dashed var(--line-2); border-radius: 14px; padding: 30px 20px; text-align: center; cursor: pointer; transition: .15s; background: var(--surface-2); }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .art { width: 48px; height: 48px; border-radius: 14px; background: var(--surface); display: grid; place-items: center; margin: 0 auto 10px; color: var(--primary-text); box-shadow: var(--shadow-1); }
.check-row { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.check-row:first-child { border-top: 0; }
.check-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.check-ico.pass { background: var(--green-soft); color: var(--green-text); }
.check-ico.warn { background: var(--amber-soft); color: var(--amber-text); }
.check-ico.fail { background: var(--red-soft); color: var(--red-text); }
.code { font-family: var(--mono); font-size: 12px; background: var(--sunken); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; display: block; margin-top: 6px; }
.status-big { display: flex; gap: 16px; align-items: center; padding: 18px; border-radius: 14px; }
.status-big.deliverable { background: var(--green-soft); } .status-big.risky { background: var(--amber-soft); } .status-big.undeliverable { background: var(--red-soft); } .status-big.unknown { background: var(--sunken); }
.status-big .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); flex: none; }
.legend-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.legend-cards > div { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.legend-cards b { display: flex; align-items: center; gap: 8px; } .legend-cards span { font-size: 12.5px; color: var(--muted); display: block; margin-top: 4px; }
.steps-list { display: flex; flex-direction: column; gap: 0; }
.setup-step { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; color: inherit; background: var(--surface); }
.setup-step:hover { border-color: var(--primary); text-decoration: none; }
.setup-step.done { background: var(--surface-2); }
.setup-step.done b { text-decoration: line-through; color: var(--muted); }
.setup-step .n { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none; color: var(--muted); }
.setup-step.done .n { background: var(--green); border-color: var(--green); color: #fff; }
.setup-step.next { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.setup-step.next .n { background: var(--primary); border-color: var(--primary); color: #fff; }
.reply-item { display: flex; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); cursor: pointer; }
.reply-item:first-child { border-top: 0; }
.reply-item:hover { background: var(--surface-2); }
.reply-item.unread .who { font-weight: 700; }
.reply-item.unread::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin: 7px -4px 0 -12px; flex: none; }
.thread-msg { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.thread-msg.in { background: var(--green-soft); border-color: transparent; }
.thread-msg pre { white-space: pre-wrap; font: inherit; margin: 8px 0 0; }
.inbox { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); min-height: 560px; }
.inbox > div:first-child { border-right: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 220px); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(1200px 600px at 10% 10%, #4743F5 0%, #2A26B8 40%, #14125C 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art h1 { font: 650 44px/1.05 var(--display); letter-spacing: -.035em; max-width: 520px; margin: 0; }
.login-art p { opacity: .8; max-width: 440px; font-size: 15px; }
.login-form { display: grid; place-items: center; padding: 40px 24px; }
.login-form form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.flight { position: absolute; inset: 0; pointer-events: none; opacity: .9; }
.score-num { font: 650 44px/1 var(--display); letter-spacing: -.03em; }
.wcard-top { display: flex; gap: 14px; align-items: center; }
.help-tip { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--sunken); color: var(--muted); font-size: 11px; font-weight: 700; cursor: help; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); }
.sel-bar { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--primary-soft); border-bottom: 1px solid var(--line); }
.mini-steps { display: flex; gap: 4px; align-items: center; }
.mini-steps i { width: 18px; height: 6px; border-radius: 99px; background: var(--line-2); display: block; }
.day-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.day-pick button { width: 46px; height: 38px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; cursor: pointer; color: var(--muted); }
.day-pick button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.mapping td { padding: 8px 10px; }
.chk-list > div { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
  .seq { grid-template-columns: 1fr; } .seq-list { position: static; }
  .legend-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-pop); }
  .side.open { transform: none; }
  .menu-toggle { display: grid; }
  .top { padding: 0 16px; }
  .content { padding: 18px 16px 60px; }
  .pipe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipe-step:nth-child(3) { border-left: 0; } .pipe-step:nth-child(n+3) { border-top: 1px solid var(--line); }
  .pipe-step .arrow { display: none; }
  .g2, .g3, .grid2, .grid3 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; }
  .inbox { grid-template-columns: 1fr; } .inbox > div:first-child { max-height: 46vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .provider-grid { grid-template-columns: 1fr; }
  .ph h1 { font-size: 26px; }
  .search-btn .kbd { display: none; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr; } .legend-cards { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.search-btn > span.grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
