/*
 * dashboard.css — "paper ledger" redesign (konsep: dashboard_redesign_preview.html).
 * Palet kertas + tinta, tipografi Spectral / IBM Plex Sans / IBM Plex Mono,
 * ledger-row untuk KPI (hairline, bukan card), stempel tinta untuk status.
 *
 * PENTING: semua nama class/id yang dipakai JS (index.js/detail.js/common.js)
 * dipertahankan — ini murni restyle, data flow tidak berubah.
 */

:root {
  --paper: #EDEAE2;
  --paper-card: #F5F3EC;
  --ink: #20242B;
  --ink-soft: #5B5E63;
  --ink-blue: #2B4570;
  --stamp-green: #3C6E47;
  --stamp-red: #9C3B2E;
  --line: #C9C3B4;
  --line-soft: #DAD5C8;

  /* Alias kompatibilitas untuk inline-style lama di detail.js */
  --border-light: var(--line-soft);

  --wrap-max: 1080px;
  --serif: "Spectral", Georgia, serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  /* Tekstur garis kertas tipis */
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.012) 0px, rgba(0, 0, 0, 0.012) 1px,
    transparent 1px, transparent 2px
  );
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 40px 24px 64px;
}

.wrap { max-width: var(--wrap-max); margin: 0 auto; }

a { color: var(--ink-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Masthead ───────────────────────────────────────────────── */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 14px;
  margin-bottom: 6px;
}
.masthead__left { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.masthead h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 27px;
  letter-spacing: -0.01em;
  margin: 0;
}
.masthead__nav { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }
.masthead__nav a { color: var(--ink-soft); }
.masthead__nav a.active { color: var(--ink); font-weight: 600; border-bottom: 1.5px solid var(--ink); }
.masthead__nav .sep { color: var(--line); margin: 0 8px; }

/* Refresh badge (id=#refresh-badge) styled as ledger "updated" stamp */
.updated {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.badge__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-soft); display: inline-block;
}
#refresh-badge.badge--ok .badge__dot { background: var(--stamp-green); }
#refresh-badge.badge--err { color: var(--stamp-red); }
#refresh-badge.badge--err .badge__dot { background: var(--stamp-red); }

/* ── Eyebrow + section headings ─────────────────────────────── */
.eyebrow {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 500; margin: 28px 0 6px;
}
.section-title {
  font-family: var(--serif); font-size: 19px; font-weight: 600;
  margin: 0 0 4px;
}
.section-sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 16px; }
.block { margin-top: 34px; }

/* ── Ledger KPI row (.ledger container, cells=.kpi; dipakai Overview & Detail) ─── */
.ledger {
  display: flex;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.kpi {
  flex: 1 1 0;
  min-width: 110px;
  padding: 16px 16px;
  border-right: 1px solid var(--line-soft);
}
.kpi:last-child { border-right: none; }
.kpi__label {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 6px;
  /* Reserve 2 lines so single/double-line labels keep values baseline-aligned */
  min-height: 2.9em; line-height: 1.35;
}
.kpi__value {
  font-family: var(--mono); font-size: 22px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.kpi__value.pos { color: var(--stamp-green); }
.kpi__value.neg { color: var(--stamp-red); }
.kpi__sub {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-soft);
  margin-top: 6px; letter-spacing: 0.01em;
}

/* ── Chart frame ────────────────────────────────────────────── */
.card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 18px;
  /* Izinkan menyusut di bawah lebar intrinsik canvas Chart.js saat jadi
     grid/flex item (grid-2) — cegah overflow horizontal di viewport sempit. */
  min-width: 0;
}
.chart-wrap { position: relative; width: 100%; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
table.tj { width: 100%; border-collapse: collapse; min-width: 720px; }
table.tj thead th {
  text-align: right;
  font-family: var(--sans);
  font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 500;
  padding: 9px 10px; border-bottom: 1.5px solid var(--ink);
  white-space: nowrap; background: transparent;
}
table.tj thead th:first-child, table.tj tbody td:first-child { text-align: left; }
table.tj tbody td {
  padding: 10px 10px; border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums;
  text-align: right; white-space: nowrap; color: var(--ink);
}
table.tj tbody td strong { font-weight: 600; }
table.tj tbody tr:hover { background: rgba(43, 69, 112, 0.04); }
table.tj th.sortable { cursor: pointer; user-select: none; }
table.tj th.sortable:hover { color: var(--ink); }

.pos { color: var(--stamp-green); }
.neg { color: var(--stamp-red); }
.muted { color: var(--ink-soft); }

/* ── Ink stamps (id classes .pill/.pill--* from detail.js) ──── */
.pill {
  display: inline-block;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 9px; border: 1.5px solid currentColor; border-radius: 3px;
  transform: rotate(-3deg); filter: url(#roughen); color: var(--ink-soft);
}
.pill--win { color: var(--stamp-green); }
.pill--loss { color: var(--stamp-red); transform: rotate(2deg); }
.pill--bep { color: var(--ink-soft); transform: rotate(-1.5deg); }

/* ── Filter buttons (#status-filters .filter-btn) ───────────── */
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-btn {
  font-family: var(--mono); font-size: 12px;
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 3px;
  padding: 5px 14px; cursor: pointer;
}
.filter-btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.filter-btn.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ── Insight cards → paper notes ────────────────────────────── */
.insight-week { margin-bottom: 26px; }
.insight-week__title {
  font-family: var(--serif); font-size: 15px; font-weight: 600;
  color: var(--ink); margin-bottom: 12px;
  padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.insight-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.insight-card {
  background: var(--paper-card);
  border-left: 2px solid var(--ink-blue);
  border-radius: 0 6px 6px 0;
  padding: 14px 16px;
}
.insight-card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.insight-card__tick { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.insight-card__body { color: var(--ink-soft); font-size: 12.5px; line-height: 1.6; }

/* ── Buttons / links ────────────────────────────────────────── */
.btn {
  display: inline-block;
  font-family: var(--mono); font-size: 13px;
  color: var(--ink); border: 1.5px solid var(--ink);
  border-radius: 3px; padding: 9px 18px; background: transparent;
}
.btn:hover { background: var(--ink); color: var(--paper); text-decoration: none; }

.foot {
  margin-top: 44px; padding-top: 16px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); text-align: center;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .ledger { border-bottom: none; }
  .kpi {
    flex: 1 1 45%; min-width: 45%;
    border-bottom: 1px solid var(--line-soft);
  }
}
@media (max-width: 520px) {
  body { padding: 28px 16px 48px; }
  .kpi { flex-basis: 100%; min-width: 100%; border-right: none; }
  .masthead { flex-direction: column; align-items: flex-start; gap: 10px; }
}
