/* ===================== Órbita — design system ===================== */
:root {
  /* dark (padrão) */
  --bg: #0f0e16; --surface: #17161f; --surface2: #201e2b; --border: #2b2937;
  --text: #f4f3f8; --muted: #a4a1b4; --faint: #78758a;
  --primary: #8b7dff; --gain: #1fce90; --gainbg: rgba(31,206,144,0.15);
  --loss: #ff6b6f; --lossbg: rgba(255,107,111,0.15);
  --warn: #f5b207; --warnbg: rgba(245,178,7,0.14);
  --grad: linear-gradient(135deg, #6d5ef2, #4c74f0);
  --grad-shadow: rgba(109,94,242,0.35);
  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #f4f3fa; --surface: #ffffff; --surface2: #f3f1fa; --border: #e7e4f0;
  --text: #1a1826; --muted: #6f6b81; --faint: #928ea6;
  --primary: #6d5ef2; --gain: #0f9d63; --gainbg: #e6f6ee;
  --loss: #e5484d; --lossbg: #fdecea;
  --warn: #b8860b; --warnbg: rgba(245,178,7,0.16);
  --grad-shadow: rgba(109,94,242,0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { opacity: 0.82; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }

/* ===================== app shell ===================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  width: 236px; flex: 0 0 236px; padding: 18px 14px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 6px 16px; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: conic-gradient(from 210deg, #6d5ef2 0deg, #6d5ef2 120deg, #4c74f0 120deg, #4c74f0 240deg, #8b7dff 240deg);
  display: flex; align-items: center; justify-content: center;
}
.brand-mark::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em; color: var(--text); }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 12px; border-radius: 12px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted);
}
.nav-item svg { flex: 0 0 20px; }
.nav-item:hover { background: var(--surface2); opacity: 1; }
.nav-item.active {
  font-weight: 700; color: #fff; background: var(--grad);
  box-shadow: 0 6px 16px var(--grad-shadow);
}
.nav-item.active:hover { opacity: 1; }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.user-avatar {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--primary);
}
.user-name { font-size: 13px; font-weight: 700; color: var(--text); }
.user-sub { font-size: 11px; color: var(--faint); }
.nav-logout { margin: 0; }
.nav-logout button {
  width: 100%; display: flex; align-items: center; gap: 13px;
  padding: 11px 12px; border-radius: 12px; cursor: pointer;
  font-family: var(--font-body); font-size: 14px; font-weight: 600; color: var(--muted);
  background: transparent; border: none; text-align: left;
}
.nav-logout button:hover { background: var(--surface2); color: var(--loss); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
  height: 62px; flex: 0 0 62px; display: flex; align-items: center; gap: 14px;
  padding: 0 clamp(16px, 3vw, 30px); border-bottom: 1px solid var(--border);
  background: var(--bg); position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: clamp(18px, 2.4vw, 22px); font-weight: 700; margin: 0; color: var(--text); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; background: var(--surface);
  border: 1px solid var(--border); color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.hamburger { display: none; background: transparent; border: none; color: var(--text); cursor: pointer; padding: 6px; margin-left: -6px; }

.content { flex: 1; overflow-y: auto; padding: 32px clamp(24px, 4vw, 44px) 90px; }
.content-inner { max-width: 1180px; margin: 0 auto; }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 50; }

/* mobile */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%; width: 256px; z-index: 60;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
  body.nav-open .overlay { display: block; }
  .hamburger { display: flex; }
  .content { padding: 22px 16px 70px; }
}

/* ===================== headings / text ===================== */
.content h1 { font-size: clamp(20px, 3vw, 26px); margin: 0 0 14px; }
.content h2 { font-size: 16px; font-weight: 600; color: var(--text); margin: 28px 0 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.content > p, .content-inner > p { font-size: 13px; color: var(--muted); max-width: 780px; }
code { font-family: var(--font-mono); font-size: 0.86em; background: var(--surface2); padding: 0.12em 0.4em; border-radius: 5px; }

.page-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 6px; }

/* ===================== buttons ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  padding: 9px 15px; border-radius: 11px; cursor: pointer;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600; text-decoration: none;
}
.btn:hover { opacity: 0.9; }
.btn.primary {
  background: var(--grad); color: #fff; border: none; font-weight: 700;
  box-shadow: 0 6px 16px var(--grad-shadow);
}
.btn.danger { background: transparent; color: var(--loss); }

/* ===================== filter pills ===================== */
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 18px; }
.chip {
  padding: 7px 15px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); cursor: pointer; text-decoration: none;
}
.chip:hover { opacity: 1; color: var(--text); }
.chip.active { font-weight: 700; background: var(--grad); color: #fff; border-color: transparent; }
.chip.active:hover { color: #fff; }
.range-form { display: inline-flex; gap: 8px; margin-left: auto; }
.range-form input { width: auto; margin: 0; }

/* ===================== cards / tiles ===================== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 24px 26px; margin-bottom: 20px; max-width: 820px;
}

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 4px 0 8px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; }
.tile-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); }
.tile-value { display: block; font-family: var(--font-display); font-size: clamp(19px, 2.2vw, 23px); font-weight: 700; color: var(--text); margin-top: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tile-value.gain { color: var(--gain); }
.tile-value.loss { color: var(--loss); }
.tile a { font-size: 12px; font-weight: 600; }

/* hero tiles (primeiros dois do dashboard) */
.tile.hero { grid-column: span 2; border-radius: 20px; padding: 22px 24px; }
.tile.hero .tile-value { font-size: clamp(28px, 4vw, 40px); line-height: 1.05; }
.tile.hero-grad {
  background: var(--grad); border: none; color: #fff;
  box-shadow: 0 12px 30px rgba(76,116,240,0.28); position: relative; overflow: hidden;
}
.tile.hero-grad .tile-label { color: rgba(255,255,255,0.85); }
.tile.hero-grad .tile-value { color: #fff; }
.tile.hero-grad::after { content: ""; position: absolute; right: -30px; top: -30px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,0.08); }
@media (max-width: 720px) { .tile.hero { grid-column: span 1; } }

/* ===================== tables ===================== */
.table-scroll, .card.breakdown, table.edit-items { }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); margin: 4px 0 8px; }
.table-scroll table { min-width: 720px; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 13px 18px; text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--faint); font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 14px 18px; font-size: 14px; color: var(--text); border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
td.muted { color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }
.actions .btn { padding: 7px 14px; font-size: 12.5px; }

/* status badges */
.status {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; background: var(--surface2); color: var(--muted);
}
.status-shipped { background: var(--gainbg); color: var(--gain); }
.status-canceled { background: var(--lossbg); color: var(--loss); }
.status-pending, .status-unshipped, .status-partiallyshipped, .status-invoiceunconfirmed, .status-pendingavailability {
  background: var(--warnbg); color: var(--warn);
}
.unmatched { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--warn); background: var(--warnbg); padding: 2px 8px; border-radius: 6px; margin-left: 4px; }
.reembolso { font-size: 11px; margin-top: 2px; }
.item-line { margin-bottom: 0.35rem; }

/* ===================== forms ===================== */
label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 16px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 7px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 11px; background: var(--surface2);
  color: var(--text); font-family: var(--font-body); font-size: 14px;
}
textarea { resize: vertical; }
textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }

.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.55); align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 24px 26px; width: 460px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions .btn { padding: 11px 20px; }
.edit-items input { width: 110px; margin: 0 0 0 auto; padding: 9px 10px; text-align: right; }

/* breakdown table (calculadora) */
.card.breakdown table td { padding: 9px 0; border-bottom: none; font-size: 13.5px; }
.card.breakdown tr.minus td { color: var(--muted); }
.card.breakdown tr.total td { padding-top: 14px; font-family: var(--font-display); font-size: 18px; font-weight: 700; border-top: 1px solid var(--border); }
.card.breakdown tr.total.gain td { color: var(--gain); }
.card.breakdown tr.total.loss td { color: var(--loss); }

/* alerts */
.alert { background: var(--warnbg); color: var(--warn); padding: 12px 16px; border-radius: 12px; font-size: 13.5px; max-width: 820px; margin: 8px 0; }
.empty { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem; text-align: center; color: var(--muted); }
.sync-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--faint); margin: 0 0 18px; }

/* backlink */
.backlink { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; margin-bottom: 16px; }

/* ===================== login ===================== */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(109,94,242,0.28), transparent 60%),
    radial-gradient(1000px 500px at 100% 110%, rgba(76,116,240,0.24), transparent 55%),
    var(--bg);
}
.login-card {
  width: 360px; max-width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 34px 32px; box-shadow: 0 30px 70px rgba(0,0,0,0.35);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-brand .brand-mark { width: 52px; height: 52px; flex: 0 0 52px; }
.login-brand .brand-mark::after { width: 18px; height: 18px; }
.login-brand .brand-name { font-size: 24px; }
.login-card label { margin-bottom: 18px; }
.login-card .btn.primary { width: 100%; padding: 13px; font-size: 14.5px; margin-top: 6px; }
.login-error { background: var(--lossbg); color: var(--loss); padding: 0.6rem 0.8rem; border-radius: 10px; font-size: 0.85rem; margin-bottom: 1rem; }
