/* ==========================================================================
   Trade Journal · tema escuro
   ========================================================================== */
:root {
  --bg: #080d16;
  --bg-soft: #0b1220;
  --panel: #0f172a;
  --panel-2: #131d33;
  --line: rgba(148, 163, 184, .14);
  --line-strong: rgba(148, 163, 184, .24);
  --text: #e6edf7;
  --muted: #8b9bb4;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, .12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .12);
  --amber: #fbbf24;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --radius: 16px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, .9);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(99, 102, 241, .16), transparent 60%),
    radial-gradient(900px 600px at 8% 108%, rgba(52, 211, 153, .07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.pos { color: var(--green) !important; }
.neg { color: var(--red) !important; }
.neu { color: var(--muted) !important; }
.warn { color: var(--amber) !important; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }

/* ------------------------------- layout ---------------------------------- */
.app {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  min-height: 100vh;
}
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0 30px 48px;
  max-width: 1500px;
  width: 100%;
}

/* ------------------------------- sidebar --------------------------------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  background: linear-gradient(180deg, rgba(15, 23, 42, .92), rgba(8, 13, 22, .92));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: .5px; color: #06131f;
  background: linear-gradient(135deg, var(--green), #22d3ee);
  box-shadow: 0 8px 20px -8px rgba(52, 211, 153, .7);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; }
.brand-text span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border: 1px solid transparent; border-radius: 11px;
  background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 500;
  text-align: left; transition: .15s;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; opacity: .9; }
.nav-item:hover { color: var(--text); background: rgba(148, 163, 184, .06); }
.nav-item.is-active {
  color: #eff6ff;
  background: linear-gradient(90deg, rgba(99, 102, 241, .22), rgba(99, 102, 241, .05));
  border-color: rgba(99, 102, 241, .35);
}
.nav-item.is-active svg { color: var(--accent-2); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.save-state {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--muted); padding: 0 4px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: #475569; flex: none; }
.dot.saving { background: var(--amber); animation: pulse 1s infinite; }
.dot.saved { background: var(--green); }
.dot.error { background: var(--red); }
@keyframes pulse { 50% { opacity: .25; } }

/* -------------------------------- topbar --------------------------------- */
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  padding: 26px 0 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar-title h1 { margin: 0; font-size: 24px; letter-spacing: -.4px; }
.topbar-title p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.period-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 6px; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(15, 23, 42, .7);
  flex-wrap: wrap;
}
.seg { display: flex; gap: 2px; background: rgba(2, 6, 23, .6); border-radius: 10px; padding: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
}
.seg button:hover { color: var(--text); }
.seg button.is-active { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset; }
.period-nav { display: flex; align-items: center; gap: 2px; }
.period-label {
  border: 0; background: transparent; color: var(--text);
  font-size: 12.5px; font-weight: 600; padding: 6px 4px; min-width: 128px; text-align: center;
}
.period-label:hover { color: var(--accent-2); }
.period-bar.is-all .period-nav .icon-btn:disabled { opacity: .3; }

/* -------------------------------- botões --------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-strong); background: var(--panel-2);
  color: var(--text); padding: 9px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 600; transition: .15s; text-decoration: none;
}
.btn:hover { border-color: rgba(148, 163, 184, .45); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff; box-shadow: 0 12px 24px -14px rgba(99, 102, 241, .9);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: linear-gradient(135deg, #b91c1c, #ef4444); border-color: transparent; color: #fff; }
.btn.danger.ghost { background: transparent; color: #fca5a5; border-color: rgba(248, 113, 113, .3); }
.btn.danger.ghost:hover { background: var(--red-soft); }
.btn-block { width: 100%; }
.btn .plus { font-size: 17px; line-height: 1; margin-top: -1px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 15px;
}
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.icon-btn:hover { background: rgba(148, 163, 184, .1); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn:disabled { opacity: .3; }

.link-btn {
  border: 0; background: none; color: var(--accent-2);
  font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; padding: 2px;
}
.btn-row { display: flex; gap: 8px; align-items: center; }
.btn-row.wrap { flex-wrap: wrap; }

/* --------------------------------- view ---------------------------------- */
.view { padding-top: 22px; display: flex; flex-direction: column; gap: 18px; }

/* --------------------------------- kpis ---------------------------------- */
.kpi-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
}
.kpi {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, rgba(19, 29, 51, .95), rgba(12, 19, 33, .95));
  border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--line-strong);
}
.kpi.pos::after { background: var(--green); }
.kpi.neg::after { background: var(--red); }
.kpi.warn::after { background: var(--amber); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kpi-value { display: block; margin-top: 8px; font-size: 21px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.goal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.goal-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 8px; }
.goal-track { height: 7px; border-radius: 999px; background: rgba(148, 163, 184, .12); overflow: hidden; }
.goal-track i { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #818cf8); border-radius: 999px; }
.goal-track i.ok { background: linear-gradient(90deg, #10b981, #34d399); }

/* -------------------------------- cards ---------------------------------- */
.card {
  background: linear-gradient(170deg, rgba(17, 26, 46, .9), rgba(10, 16, 29, .9));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px 0;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.1px; }
.card-sub { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; }
.card-body { padding: 14px 18px 18px; }
.grid-2 { display: grid; grid-template-columns: 1.25fr .9fr; gap: 18px; align-items: start; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.side-col { display: flex; flex-direction: column; gap: 18px; }

/* -------------------------------- charts --------------------------------- */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap.small { max-width: 340px; margin: 0 auto; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid { stroke: rgba(148, 163, 184, .10); stroke-width: 1; }
.chart-svg .zero { stroke: rgba(148, 163, 184, .35); stroke-width: 1; stroke-dasharray: 4 5; }
.chart-svg .axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart-svg .dot { fill: rgba(52, 211, 153, .9); }
.chart-svg .legend { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.chart-svg .donut-total { fill: var(--text); font-size: 15px; font-weight: 700; font-family: var(--font); }
.chart-svg .donut-cap { fill: var(--muted); font-size: 9px; font-family: var(--font); text-transform: uppercase; letter-spacing: .5px; }
.chart-empty {
  display: grid; place-items: center; min-height: 180px; text-align: center;
  color: var(--muted); font-size: 12.5px; border: 1px dashed var(--line); border-radius: 12px; padding: 20px;
}
.legend-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; margin-top: 8px; flex-wrap: wrap; }
.dot-legend { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #64748b; }
.dot-legend.pos { background: var(--green); }
.dot-legend.neg { background: var(--red); }
.dot-legend.neu { background: #64748b; margin-left: 10px; }
.spark { width: 100px; height: 30px; }

/* -------------------------------- barras --------------------------------- */
.bar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 108px; gap: 10px; align-items: center; padding: 7px 0; }
.bar-label { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 7px; border-radius: 999px; background: rgba(148, 163, 184, .1); overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 999px; background: #64748b; }
.bar-track i.pos { background: linear-gradient(90deg, #10b981, #34d399); }
.bar-track i.neg { background: linear-gradient(90deg, #ef4444, #f87171); }
.bar-value { text-align: right; font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.bar-meta { display: flex; gap: 10px; color: var(--muted); font-size: 10.5px; margin: -4px 0 6px 106px; }

/* -------------------------------- calendário ----------------------------- */
.calendar { display: flex; flex-direction: column; gap: 6px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-head span { text-align: center; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; padding-bottom: 2px; }
.cal-cell {
  position: relative; min-height: 44px; border-radius: 9px;
  border: 1px solid var(--line); background: rgba(15, 23, 42, .55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text); font-size: 11px; transition: .15s;
}
.cal-cell.void { border-color: transparent; background: transparent; }
.cal-cell:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.cal-cell .cal-day { color: var(--muted); font-size: 10px; }
.cal-cell .cal-value { font-size: 9.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-cell.win { background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .28); }
.cal-cell.win .cal-value { color: var(--green); }
.cal-cell.loss { background: rgba(248, 113, 113, .10); border-color: rgba(248, 113, 113, .26); }
.cal-cell.loss .cal-value { color: var(--red); }
.cal-cell.flat { background: rgba(148, 163, 184, .08); }
.cal-cell.today { box-shadow: 0 0 0 2px rgba(99, 102, 241, .55) inset; }
.cal-legend { display: flex; gap: 16px; color: var(--muted); font-size: 10.5px; margin-top: 12px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.sw.win { background: rgba(52, 211, 153, .7); }
.sw.loss { background: rgba(248, 113, 113, .7); }
.sw.flat { background: rgba(148, 163, 184, .5); }

/* -------------------------------- mini lista ----------------------------- */
.mini-list { display: flex; flex-direction: column; gap: 4px; }
.mini-item {
  display: grid; grid-template-columns: 44px 92px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  background: transparent; border: 0; border-radius: 8px; padding: 8px 6px; text-align: left;
  color: var(--text); font-size: 12.5px;
}
.mini-item:hover { background: rgba(148, 163, 184, .07); }
.mini-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.mini-asset { font-weight: 700; }
.mini-asset em { color: var(--muted); font-style: normal; font-weight: 500; font-size: 10.5px; margin-left: 4px; }
.mini-reason { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { padding: 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: rgba(148, 163, 184, .1); white-space: nowrap; }
.pill.pos { background: var(--green-soft); }
.pill.neg { background: var(--red-soft); }

/* -------------------------------- toolbar -------------------------------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar select, .search {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font-size: 12.5px; color: var(--text);
}
.toolbar select { min-width: 150px; }
.toolbar select:focus, .search:focus-within, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: rgba(99, 102, 241, .65); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.search { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; max-width: 420px; padding: 0 12px; }
.search svg { width: 16px; height: 16px; fill: var(--muted); flex: none; }
.search input { background: transparent; border: 0; outline: none; padding: 10px 0; width: 100%; font-size: 12.5px; color: var(--text); }
.search input::placeholder { color: #64748b; }
.toolbar .btn { margin-left: auto; }

.result-strip {
  display: flex; gap: 20px; flex-wrap: wrap; align-items: center;
  padding: 11px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(15, 23, 42, .65); font-size: 12.5px; color: var(--muted);
}
.result-strip b { color: var(--text); margin-left: 4px; }

/* -------------------------------- tabela --------------------------------- */
.table-card { overflow: hidden; }
.table-wrap { overflow: auto; max-height: 68vh; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #0d1526; color: var(--muted); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .5px; font-weight: 650; text-align: left; padding: 12px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table tbody td { padding: 11px 12px; border-bottom: 1px solid rgba(148, 163, 184, .07); vertical-align: middle; }
.table tbody tr:hover td { background: rgba(148, 163, 184, .045); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td small { color: var(--muted); font-size: 10.5px; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions .icon-btn { width: 28px; height: 28px; }
.asset-badge {
  display: inline-block; padding: 3px 7px; border-radius: 6px;
  background: rgba(99, 102, 241, .14); border: 1px solid rgba(99, 102, 241, .3);
  color: #c7d2fe; font-weight: 700; font-size: 11px; letter-spacing: .3px;
}
.dir { font-size: 11.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px; }
.dir.long { color: var(--green); background: var(--green-soft); }
.dir.short { color: var(--red); background: var(--red-soft); }
.tag {
  display: inline-block; padding: 2px 7px; border-radius: 999px; margin-left: 6px;
  background: rgba(148, 163, 184, .1); border: 1px solid var(--line);
  color: var(--muted); font-size: 10px; white-space: nowrap;
}
.tag.ghost { background: transparent; }
.reason-col { min-width: 260px; max-width: 420px; }
.reason { color: #c3cfe2; font-size: 12px; }
.analysis-item .tag { margin-left: 8px; }

/* --------------------------------- empty --------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 60px 24px; border: 1px dashed var(--line);
  border-radius: var(--radius); background: rgba(15, 23, 42, .4);
}
.empty-ico { font-size: 34px; margin-bottom: 8px; }
.empty h3 { margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 0 18px; color: var(--muted); max-width: 520px; line-height: 1.55; }
.empty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ------------------------------- análises -------------------------------- */
.analises-head h2, .report-head h2 { margin: 0; font-size: 19px; letter-spacing: -.3px; }
.analises-head p, .report-head p { margin: 4px 0 0; }
.analysis-list { display: flex; flex-direction: column; gap: 14px; }
.analysis-block {
  background: linear-gradient(170deg, rgba(17, 26, 46, .9), rgba(10, 16, 29, .9));
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.analysis-block > header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, .5);
}
.analysis-block h4 { margin: 0; font-size: 13.5px; }
.analysis-block header span { font-size: 11.5px; }
.analysis-block header strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.analysis-item {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) 108px; gap: 12px;
  width: 100%; text-align: left; background: transparent; border: 0;
  border-bottom: 1px solid rgba(148, 163, 184, .06); padding: 12px 16px; color: var(--text);
}
.analysis-item:last-child { border-bottom: 0; }
.analysis-item:hover { background: rgba(148, 163, 184, .045); }
.ai-side { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.ai-side small { color: var(--muted); font-size: 10.5px; }
.ai-reason { color: #cbd6e6; font-size: 12.5px; line-height: 1.5; }
.ai-result { text-align: right; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.ai-result small { display: block; color: var(--muted); font-weight: 500; font-size: 10.5px; }
.stat-line {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid rgba(148, 163, 184, .07); font-size: 12.5px;
}
.stat-line:last-child { border-bottom: 0; }
.stat-line b { font-variant-numeric: tabular-nums; }
.analises-head { display: flex; justify-content: space-between; }

/* ------------------------------- relatório ------------------------------- */
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.summary { margin: 0; line-height: 1.7; color: #cbd6e6; font-size: 13.5px; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.check-list li { position: relative; padding-left: 24px; line-height: 1.5; font-size: 12.5px; color: #cbd6e6; }
.check-list li::before {
  content: "✓"; position: absolute; left: 0; top: -1px;
  width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10px; font-weight: 800; background: var(--green-soft); color: var(--green);
}
.check-list.fix li::before { content: "!"; background: var(--red-soft); color: var(--red); }
.card-head .dot-legend { margin-right: 6px; }
.ind-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.ind {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(15, 23, 42, .5);
}
.ind span { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
.ind b { font-size: 14.5px; font-variant-numeric: tabular-nums; }

/* -------------------------------- config --------------------------------- */
.conn { display: flex; flex-direction: column; gap: 10px; }
.conn-row { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid rgba(148, 163, 184, .07); font-size: 12.5px; }
.conn-row span { color: var(--muted); }
.hint { color: var(--muted); font-size: 11.5px; line-height: 1.55; margin: 14px 0 0; }
.hint b { color: #cbd6e6; }
.pv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; margin-bottom: 12px; }
.pv-item { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.pv-item input, .inline-form input, .field input, .field select, .field textarea {
  width: 100%; background: rgba(8, 13, 22, .75); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; color: var(--text); font-size: 12.5px;
}
.inline-form { display: flex; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 130px; width: auto; }

/* --------------------------------- forms --------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .2px; }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline input { width: 140px; }
.form-section { padding: 4px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.form-section:last-of-type { border-bottom: 0; }
.form-section h4 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.manual-row { display: flex; align-items: center; gap: 18px; margin-top: 12px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }
.calc-preview {
  display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; padding: 11px 14px;
  border: 1px dashed var(--line-strong); border-radius: 10px;
  background: rgba(2, 6, 23, .35); font-size: 11.5px; color: var(--muted);
}
.calc-preview b { color: var(--text); margin-left: 4px; font-variant-numeric: tabular-nums; }
.counter { font-size: 10.5px; color: var(--muted); align-self: flex-end; }
.counter.ok { color: var(--green); }
.counter.bad { color: var(--amber); }

/* --------------------------------- modal --------------------------------- */
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 23, .72);
  backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 560px; background: #0d1526;
  border: 1px solid var(--line-strong); border-radius: 18px;
  box-shadow: 0 40px 80px -30px #000;
  animation: modal-in .18s ease-out;
}
.modal.wide { max-width: 860px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 20px 22px 14px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head p { margin: 4px 0 0; font-size: 12px; }
.modal-body { padding: 18px 22px; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 0; border-top: 1px solid var(--line); margin-top: 16px;
}
.modal .modal-body .modal-foot { padding-bottom: 0; }

/* --------------------------------- auth ---------------------------------- */
.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 70% 10%, rgba(99, 102, 241, .2), transparent 60%),
    radial-gradient(700px 400px at 20% 100%, rgba(52, 211, 153, .1), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: linear-gradient(170deg, rgba(19, 29, 51, .96), rgba(9, 14, 25, .98));
  border: 1px solid var(--line-strong); border-radius: 20px;
  padding: 26px; box-shadow: 0 40px 90px -40px #000;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand strong { display: block; font-size: 16px; }
.auth-brand span { color: var(--muted); font-size: 12px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: rgba(2, 6, 23, .5); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.auth-tabs button { border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 8px; font-size: 12.5px; font-weight: 600; }
.auth-tabs button.is-active { background: var(--panel-2); color: var(--text); }
.auth-card .field { margin-bottom: 12px; }
.auth-card .btn { margin-top: 4px; }
.auth-msg { min-height: 18px; margin: 10px 0 0; font-size: 11.5px; line-height: 1.5; }
.auth-msg.error { color: var(--red); }
.auth-msg.ok { color: var(--green); }
.auth-foot { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* --------------------------------- toasts -------------------------------- */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 240px; max-width: 380px;
  background: #111c30; border: 1px solid var(--line-strong); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 11px 14px; font-size: 12.5px; color: var(--text);
  box-shadow: 0 20px 40px -18px #000; animation: toast-in .2s ease-out;
}
.toast.ok { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.info { border-left-color: var(--accent); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------- responsivo ------------------------------ */
@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-side { grid-template-columns: 1fr; }
  .side-col { flex-direction: row; flex-wrap: wrap; }
  .side-col .card { flex: 1 1 300px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease-out;
    box-shadow: 30px 0 60px -30px #000;
  }
  .sidebar.open { transform: none; }
  .main { padding: 0 16px 40px; }
  .topbar { padding-top: 18px; }
  .period-bar { width: 100%; justify-content: space-between; }
  .period-label { min-width: 0; }
  .grid-2, .grid-side { grid-template-columns: 1fr; }
  .form-grid, .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar .btn { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .topbar-actions { width: 100%; }
  .period-bar { padding: 5px; gap: 6px; }
  .seg button { padding: 7px 8px; }
  .period-label { font-size: 11px; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .analysis-item { grid-template-columns: 76px minmax(0, 1fr); }
  .ai-result { grid-column: 2; text-align: left; }
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; max-width: none; }
}
