:root {
  --bg: #0A0B0D;
  --surface: #0F1114;
  --surface-2: #14161A;
  --surface-3: #16181C;
  --line: #1C1E23;
  --line-2: #2A2D34;
  --text: #ECEDEF;
  --text-2: #C9CCD2;
  --muted: #9298A2;
  --faint: #6E747E;
  --accent: #D4FF3A;
  --accent-ink: #0A0B0D;
  --red: #FF6B6B;
  --amber: #F5B841;
  --green: #4ADE80;
  --radius: 20px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1 1 auto; }
.stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stack-10 { display: flex; flex-direction: column; gap: 10px; }
.stack-14 { display: flex; flex-direction: column; gap: 14px; }
.stack-16 { display: flex; flex-direction: column; gap: 16px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* urgência: cada estado define --u */
.u-overdue, .u-critical { --u: var(--red); --u-soft: rgba(255, 107, 107, .14); }
.u-soon { --u: var(--amber); --u-soft: rgba(245, 184, 65, .14); }
.u-ok { --u: var(--green); --u-soft: rgba(74, 222, 128, .12); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--u, currentColor); flex: none; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  font: 500 13px var(--sans); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #1B1E23; border-color: #343841; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: #E2FF7A; border-color: transparent; }
.btn-light { background: var(--text); color: var(--bg); border-color: transparent; font-weight: 600; }
.btn-light:hover { background: #fff; color: var(--bg); }
.btn-danger { color: var(--red); background: transparent; border-color: rgba(255, 107, 107, .35); }
.btn-danger:hover { background: rgba(255, 107, 107, .1); }
.btn-ghost { background: transparent; }
.btn-link { background: none; border: 0; color: var(--accent); padding: 0 4px; height: auto; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-lg { height: 44px; padding: 0 18px; border-radius: 12px; font-size: 14px; }
.btn-sm { height: 34px; padding: 0 12px; }
.btn-icon { width: 40px; padding: 0; }
.cell-actions .btn-icon { width: 34px; height: 34px; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(10, 11, 13, .85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.search {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 1px solid #22252B; border-radius: 10px; background: #111317; color: var(--muted);
  flex: 0 1 300px; min-width: 180px;
}
.search:focus-within { border-color: #3A3E46; }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font: inherit; }
.search kbd { font-size: 11px; padding: 2px 6px; border: 1px solid var(--line-2); border-radius: 6px; }

/* ---------- layout ---------- */
.container { max-width: 1360px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 64px; display: flex; flex-direction: column; gap: 20px; }
.grid-top, .grid-main { display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch; }
.grid-main { align-items: flex-start; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.pad { padding: 18px 24px; }
.pad-lg { padding: 22px 24px; }
.dots { background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px); background-size: 14px 14px; }
.eyebrow { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ---------- hero ---------- */
.hero {
  flex: 999 1 560px; min-width: 0; padding: 28px 32px;
  display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-end; justify-content: space-between;
}
.hero .dot { box-shadow: 0 0 0 4px var(--u-soft); }
.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
.hero-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.countdown { display: flex; align-items: baseline; gap: 14px; }
.countdown .num { font-size: clamp(88px, 11vw, 128px); line-height: .9; font-weight: 700; letter-spacing: -0.06em; color: var(--u); font-variant-numeric: tabular-nums; }
.countdown .unit { font-size: 22px; color: var(--muted); }
.hero-meta { display: flex; flex-direction: column; gap: 4px; }
.hero-meta strong { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.hero-actions { display: flex; flex-direction: column; gap: 10px; min-width: 220px; }
.hero.empty { flex-direction: column; align-items: flex-start; gap: 16px; padding: 48px; }
.hero.empty h1 { font-size: clamp(26px, 3.4vw, 40px); max-width: 720px; line-height: 1.15; }
.hero.empty p { max-width: 560px; margin: 0; font-size: 15px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }

/* ---------- KPIs ---------- */
.kpis { flex: 1 1 300px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.kpi { border-radius: 16px; padding: 18px 20px; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.kpi div { display: flex; flex-direction: column; gap: 6px; }
.kpi .muted { font-size: 13px; }
.kpi strong { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.tag { font-size: 11px; color: var(--muted); padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.tag-red { color: var(--red); background: rgba(255, 107, 107, .12); }

/* ---------- linha do tempo ---------- */
.timeline { padding: 22px 28px 20px; }
.legend { display: flex; gap: 16px; font-size: 11px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.rail-scroll { overflow-x: auto; margin-top: 8px; }
.rail { position: relative; height: 140px; min-width: 720px; margin: 0 40px; }
.rail-line { position: absolute; left: 0; right: 0; top: 56px; height: 2px; background: repeating-linear-gradient(90deg, var(--line-2) 0 6px, transparent 6px 12px); }
.pt { position: absolute; top: 0; bottom: 0; width: 0; }
.pt .dot { position: absolute; left: -6px; top: 51px; width: 12px; height: 12px; box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--u-soft); }
.pt-label { position: absolute; top: 0; left: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; white-space: nowrap; }
.pt-label b { font-size: 12px; font-weight: 600; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.pt-label span { font-size: 11px; color: var(--muted); }
.pt.below .pt-label { top: 78px; }
.rail-ticks { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); }
.rail-ticks .today { color: var(--accent); }

/* ---------- lista ---------- */
.list { flex: 999 1 640px; min-width: 0; overflow: hidden; }
.list .card-head { border-bottom: 1px solid var(--line); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.tabs button { height: 32px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font: 500 13px var(--sans); cursor: pointer; }
.tabs button span { opacity: .6; font-size: 11px; }
.tabs button[aria-selected="true"] { background: #1F2228; color: var(--text); }
.tr {
  display: grid; grid-template-columns: 2.3fr 1.5fr 1.1fr 1fr 1fr auto;
  gap: 16px; align-items: center; padding: 14px 24px; border-top: 1px solid #16181C;
}
.tr:not(.th):hover { background: var(--surface-2); }
.th { padding: 12px 24px; border-top: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.cell-item { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid #23262C; font-size: 12px; font-weight: 700; color: var(--text-2);
  box-shadow: inset 0 -2px 0 var(--cat);
}
.cell-cycle { display: flex; flex-direction: column; gap: 6px; }
.bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar div { height: 100%; background: var(--u); border-radius: 4px; }
.cell-price { font-weight: 500; }
.cell-auto { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.cell-auto .dot { width: 6px; height: 6px; background: currentColor; }
.cell-auto.manual { color: var(--amber); }
.cell-due { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; color: var(--u); background: var(--u-soft); white-space: nowrap; }
.cell-actions { display: flex; gap: 4px; justify-content: flex-end; }

@media (max-width: 860px) {
  .th { display: none; }
  .tr {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "item due" "cycle price" "auto actions";
    row-gap: 12px; padding: 16px 18px;
  }
  .cell-item { grid-area: item; }
  .cell-due { grid-area: due; align-items: flex-end; }
  .cell-cycle { grid-area: cycle; }
  .cell-price { grid-area: price; text-align: right; }
  .cell-auto { grid-area: auto; }
  .cell-actions { grid-area: actions; }
  .pad { padding: 16px 18px; }
}
@media (max-width: 600px) {
  .search kbd, .topbar .btn-primary span { display: none; }
  .topbar .btn-primary { width: 40px; padding: 0; }
  .search { order: 10; flex: 1 1 100%; }
  .hero { padding: 22px; gap: 20px; }
  .hero-actions { min-width: 0; width: 100%; }
  .hero.empty { padding: 28px 22px; }
  .timeline { padding: 18px; }
}

/* ---------- lateral ---------- */
.aside { flex: 1 1 320px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.split { display: flex; height: 10px; gap: 3px; border-radius: 6px; overflow: hidden; }
.cat-row { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); }
.cat-row > span:first-child { display: flex; align-items: center; gap: 8px; }
.sq { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.status .dot { width: 6px; height: 6px; background: currentColor; }
.s-ok { color: var(--green); } .s-soon { color: var(--amber); } .s-critical { color: var(--red); } .s-muted { color: var(--muted); }
.file-box { display: flex; align-items: center; gap: 12px; background: var(--surface-3); border: 1px solid #23262C; border-radius: 14px; padding: 12px 14px; }
.file-icon { width: 36px; height: 36px; flex: none; border-radius: 10px; background: rgba(212, 255, 58, .1); color: var(--accent); display: grid; place-items: center; }
.aside .btn-link { align-self: flex-start; }

/* ---------- diálogos ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 6, 8, .7); backdrop-filter: blur(4px); animation: fade .16s ease-out;
}
.dialog {
  width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  padding: 24px; border: 1px solid var(--line-2); border-radius: 20px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6); animation: pop .16s ease-out;
}
.dialog:focus { outline: none; }
.dialog-sm { width: min(440px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.dialog-head h2 { font-size: 18px; }
.dialog-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--text); font: 14px var(--sans); color-scheme: dark;
}
.field textarea { height: auto; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.danger-zone p { margin: 4px 0 0; }
.history { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; }
.history li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
@media (max-width: 520px) { .form-grid { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 12px;
  background: #1A1C21; border: 1px solid var(--line-2); box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  animation: pop .16s ease-out;
}
.toast.error { border-color: rgba(255, 107, 107, .4); }

/* ---------- Blazor ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
label.btn { position: relative; }
.validation-message { color: var(--red); font-size: 12px; font-weight: 400; }
.field .invalid { border-color: var(--red); }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); font: 14px var(--sans); }
.boot-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); margin: 0 auto 14px; animation: boot 1.2s ease-in-out infinite; }
@keyframes boot { 50% { transform: scale(.86); opacity: .7; } }
#blazor-error-ui {
  display: none; position: fixed; inset: auto 16px 16px; z-index: 100; padding: 12px 16px; border-radius: 12px;
  background: #2A1515; border: 1px solid rgba(255, 107, 107, .4); color: var(--text);
}
#blazor-error-ui .reload { color: var(--accent); margin-left: 8px; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; color: var(--muted); }
