@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/inter-700.woff2") format("woff2");
}

:root {
  --bg: #070b14;
  --bg-elev: #0c1220;
  --card: #121a2c;
  --card-2: #161f34;
  --ink: #e8eef8;
  --muted: #8b97ad;
  --line: rgba(148, 163, 184, 0.14);
  --accent: #3b82f6;
  --accent-ink: #f8fbff;
  --green: #3dd68c;
  --green-dim: rgba(61, 214, 140, 0.14);
  --red: #f07178;
  --red-dim: rgba(240, 113, 120, 0.12);
  --amber: #f5a524;
  --amber-dim: rgba(245, 165, 36, 0.12);
  --cyan: #38bdf8;
  --cyan-dim: rgba(56, 189, 248, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(245, 165, 36, 0.12);
  --error: #fb7185;
  --ok: #3dd68c;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 16px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px 20px 56px;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(59, 130, 246, 0.12), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(61, 214, 140, 0.08), transparent 45%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex: 0 0 36px;
  background:
    linear-gradient(135deg, #3dd68c 0%, #3b82f6 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 20px rgba(59, 130, 246, 0.35);
  position: relative;
}
.mark::after {
  content: "";
  position: absolute;
  inset: 9px 8px 8px 9px;
  border-right: 2.5px solid #071018;
  border-bottom: 2.5px solid #071018;
  transform: rotate(45deg);
  border-radius: 0 0 2px 0;
  opacity: .85;
}

h1, h2 { margin: 0 0 6px; }
h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
h2 {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.muted { color: var(--muted); }
.small { font-size: 0.78rem; }
.hidden { display: none !important; }
.error { color: var(--error); font-weight: 600; }
.error.banner, .warn {
  padding: 10px 14px;
  border-radius: 12px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
}
.warn { background: var(--warn-bg); color: var(--warn); }

label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: 0.88rem; }
input[type=password], input[type=date] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #0b1120;
  color: var(--ink);
  color-scheme: dark;
}
input[type=password]:focus, input[type=date]:focus {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 1px;
  border-color: transparent;
}

button, .ghost {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}
button:disabled { opacity: .6; cursor: wait; }
button.ghost, a.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
a.ghost:hover, button.ghost:hover { background: rgba(255,255,255,0.04); }
#btn-sync { box-shadow: 0 8px 20px rgba(59, 130, 246, 0.28); }

.top, .filters, .progress, .orders, .saldo {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.meta { margin: 0 0 16px; min-height: 0; }
.meta:empty, .meta:not(:has(*:not(.hidden)):not(:has(#sync-msg:not(:empty)))) { margin-bottom: 0; }
/* keep layout stable even if empty */
.meta { min-height: 0; }
#sync-msg:empty { display: none; }

.top, .filters, .progress, .orders { padding: 16px 18px; margin-bottom: 16px; }
.top, .progress-head, .top-actions {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.sync-status { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.sync-status strong { font-size: 0.9rem; font-weight: 600; }

/* Login */
.login-body {
  min-height: 100vh;
  max-width: none;
  padding: 24px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(800px 400px at 20% 10%, rgba(59, 130, 246, 0.22), transparent 55%),
    radial-gradient(700px 360px at 90% 90%, rgba(61, 214, 140, 0.14), transparent 50%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(100%, 400px);
  padding: 32px 28px 28px;
  background: linear-gradient(180deg, #161f34 0%, #10182a 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.03);
}
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { margin-bottom: 2px; font-size: 1.35rem; }
.login-lead { margin: 0 0 8px; color: var(--muted); }
.login-card button { width: 100%; margin-top: 18px; padding: 12px 16px; }

/* Hero saldo */
.saldo {
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 24px 22px 18px;
  border: 1px solid rgba(61, 214, 140, 0.28);
  background:
    linear-gradient(180deg, rgba(61, 214, 140, 0.10) 0%, rgba(18, 26, 44, 0.96) 48%),
    var(--card);
}
.saldo::before {
  content: "";
  position: absolute;
  inset: auto auto -40% -10%;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(61, 214, 140, 0.16), transparent 70%);
  pointer-events: none;
}
.kicker {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
}
.saldo .amount.total {
  font-size: clamp(2rem, 6vw, 3.15rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 8px 0 4px;
  color: #f4fbf7;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.hero-note { margin: 8px 0 0; font-size: 0.88rem; max-width: 52rem; }
.saldo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0 8px;
}
.saldo-tile {
  background: rgba(7, 11, 20, 0.45);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.saldo-grid .amount { font-size: 1.25rem; margin: 6px 0 0; }
.unit { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.saldo .modal-line { margin-top: 10px; font-size: 0.82rem; }

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elev);
}
.presets, .custom { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.custom label { margin: 0; font-weight: 500; color: var(--muted); font-size: 0.78rem; text-transform: none; letter-spacing: 0; display: flex; flex-direction: column; gap: 4px; }
.custom input[type=date] { min-width: 10.2rem; }
.chip {
  background: #0b1220;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
  padding: 8px 14px;
  min-height: 38px;
}
.chip:hover { background: #151d30; }
.chip.active {
  background: rgba(61, 214, 140, 0.16);
  color: #d8ffeb;
  border-color: rgba(61, 214, 140, 0.4);
}
.chip.apply { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* Metric cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card {
  padding: 16px 16px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--line);
}
.card.tone-jual::before, .card.tone-profit::before { background: var(--green); }
.card.tone-fee::before, .card.tone-pajak::before, .card.tone-expense::before { background: var(--amber); }
.card.tone-beli::before { background: var(--cyan); }
.card.tone-share::before { background: var(--accent); }
.card.highlight { box-shadow: var(--shadow), inset 0 0 0 1px rgba(61, 214, 140, 0.18); }
.amount {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 4px 0;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.card.tone-jual .amount, .card.tone-profit .amount { color: var(--green); }
.card.tone-fee .amount, .card.tone-pajak .amount, .card.tone-expense .amount { color: var(--amber); }
.sub { margin: 0; color: var(--muted); font-size: 0.86rem; }

/* Progress */
.progress-head span { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.bar {
  height: 10px;
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 8px;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f5a524, #3dd68c);
  border-radius: 999px;
  min-width: 0;
  transition: width .3s ease;
}
.bar-fill.ok { background: linear-gradient(90deg, #22c55e, #3dd68c); }

/* Table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
tbody tr:hover { background: rgba(255,255,255,0.02); }
.mono { font-family: var(--mono); font-size: 0.78rem; white-space: nowrap; color: #c5d0e6; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-jual { background: var(--green-dim); color: var(--green); }
.badge-beli { background: var(--cyan-dim); color: var(--cyan); }

footer { margin-top: 24px; }

@media (max-width: 720px) {
  body { padding: 14px 12px 40px; }
  .amount { font-size: 1.2rem; }
  .top-actions { width: 100%; }
  .sync-status { align-items: flex-start; flex: 1; }
  .filters { padding: 14px; }
  .custom, .presets { width: 100%; }
  .custom { flex-direction: column; align-items: stretch; }
  .custom label, .custom input[type=date], .custom .chip.apply { width: 100%; min-width: 0; }
  .custom input[type=date] { min-width: 0; }
  .chip { flex: 1 1 calc(50% - 8px); }
  .saldo { padding: 20px 16px 16px; }
  #btn-sync, a.ghost { flex: 1; }
}

@media (max-width: 420px) {
  .login-card { padding: 24px 18px; }
  h1 { font-size: 1.1rem; }
}

@media (max-width: 720px) {
  .orders table { min-width: 0; }
  .orders thead { display: none; }
  .orders tr {
    display: block;
    padding: 12px 4px 10px;
    border-bottom: 1px solid var(--line);
  }
  .orders tbody tr:last-child { border-bottom: 0; }
  .orders td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    border: 0;
    padding: 4px 0;
    text-align: right;
  }
  .orders td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    flex: 0 0 38%;
  }
  .orders td.mono { white-space: normal; word-break: break-all; text-align: right; }
}

.breakdown {
  list-style: none;
  margin: 12px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}
.breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 0.86rem;
  color: var(--ink);
}
.breakdown li span:first-child { color: var(--muted); }

.cumul {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cumul-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.card.tone-profit .cumul { color: var(--green); }
.card.tone-pajak .cumul { color: var(--amber); }

.card.hero {
  grid-column: 1 / -1;
  padding: 22px 22px 18px;
}
.card.hero .hero-amount {
  font-size: 2.2rem;
  margin: 2px 0 8px;
}
.period-tag {
  margin: 0 0 2px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.card.tone-net::before { background: var(--green); }
.card.tone-net .amount,
.card.tone-net .cumul { color: var(--green); }
.card.tone-net.is-negative::before { background: var(--red); }
.card.tone-net.is-negative {
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(240, 113, 120, 0.22);
}
.card.tone-net.is-negative .hero-amount,
.card.tone-net .cumul.is-negative,
.card.tone-expense .cumul { color: inherit; }
.card.tone-net.is-negative .hero-amount,
.card.tone-net .cumul.is-negative { color: var(--red); }
.card.tone-expense .cumul { color: var(--amber); }
@media (max-width: 720px) {
  .card.hero .hero-amount { font-size: 1.7rem; }
}

/* Friend panel — simple monthly layout */
.teman-body .hero-total {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 22px;
  margin-bottom: 16px;
  text-align: left;
}
.teman-body .hero-total h2 {
  margin-bottom: 8px;
  font-size: 0.8rem;
}
.teman-body .hero-total .hero-amount {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 0 0 10px;
  color: var(--green);
}
.teman-body .hero-total.is-negative .hero-amount,
.teman-body .neg {
  color: var(--red);
}
.teman-body .rumus {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.teman-body .bulan-section,
.teman-body .opex-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  margin-bottom: 16px;
}
.teman-body .bulan-section h2,
.teman-body .opex-section h2,
.teman-body .orders h2 {
  margin-bottom: 12px;
}
.teman-body .bulan-wrap { margin: 0; overflow-x: auto; }
.teman-body .bulan-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}
.teman-body .bulan-table th,
.teman-body .bulan-table td {
  padding: 12px 10px;
  font-size: 0.92rem;
  vertical-align: top;
}
.teman-body .bulan-table th {
  white-space: normal;
  line-height: 1.3;
  max-width: 8.5rem;
}
.teman-body .bulan-table td.num,
.teman-body .bulan-table th.num {
  text-align: right;
}
.teman-body .bulan-table .fee-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}
.teman-body .bulan-table .total-row td {
  font-weight: 700;
  border-top: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.95rem;
}
.teman-body .opex-month {
  padding: 12px 0 4px;
}
.teman-body .opex-month + .opex-month {
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.teman-body .opex-month h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
}
.teman-body .opex-month .breakdown {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.teman-body .opex-total {
  margin: 8px 0 0;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.teman-body .month-filters .presets { width: 100%; }
.teman-body .card.tone-net::before { background: var(--green); }
.teman-body .card.tone-net .amount { color: var(--green); }
.teman-body .card.tone-net.is-negative::before { background: var(--red); }
.teman-body .card.tone-net.is-negative {
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(240, 113, 120, 0.22);
}
.teman-body .card.tone-net.is-negative .amount,
.teman-body .neg { color: var(--red); }
.teman-body .card.tone-net.highlight .amount { font-size: 1.55rem; }

@media (max-width: 720px) {
  .teman-body .hero-total .hero-amount { font-size: 1.85rem; }
  .teman-body .bulan-table { min-width: 0; }
  .teman-body .bulan-table thead { display: none; }
  .teman-body .bulan-table tr {
    display: block;
    padding: 14px 4px 12px;
    border-bottom: 1px solid var(--line);
  }
  .teman-body .bulan-table tbody tr:first-child { padding-top: 4px; }
  .teman-body .bulan-table tfoot tr {
    border-bottom: 0;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-top: 8px;
    padding: 14px 8px;
  }
  .teman-body .bulan-table .total-row td { border-top: 0; background: transparent; }
  .teman-body .bulan-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    border: 0;
    padding: 5px 0;
    text-align: right;
  }
  .teman-body .bulan-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    flex: 0 0 46%;
    white-space: normal;
  }
  .teman-body .bulan-table td[data-label="Bulan"] {
    display: block;
    text-align: left;
    padding-bottom: 8px;
  }
  .teman-body .bulan-table td[data-label="Bulan"]::before { display: none; }
  .teman-body .bulan-table td.num { text-align: right; }
}
