/* Carbon Management Platform — prototype stylesheet
   Palet seri chart tervalidasi dengan dataviz validate_palette.js (light & dark). */

:root {
  color-scheme: light;
  --navy: #1b2a5e;
  --navy-2: #24397d;
  --green: #1e6b3c;
  --green-dark: #123f24;

  --page: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #7c8798;
  --grid: #e6e9ee;
  --axis: #cbd3dd;
  --border: rgba(15, 23, 42, 0.10);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .18);

  /* seri kategorikal — light */
  --s1: #2a5fb0;
  --s2: #1e8a4c;
  --s3: #eda100;
  --s4: #4a3aa7;
  --total: #64748b;

  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --good-text: #006300;

  --r: 12px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d1016;
    --surface: #161a22;
    --surface-2: #1d222c;
    --ink: #ffffff;
    --ink-2: #c8cedb;
    --muted: #8b94a5;
    --grid: #242a35;
    --axis: #39414f;
    --border: rgba(255, 255, 255, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --s1: #3987e5;
    --s2: #199e70;
    --s3: #c98500;
    --s4: #9085e9;
    --total: #94a3b8;
    --good-text: #0ca30c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d1016;
  --surface: #161a22;
  --surface-2: #1d222c;
  --ink: #ffffff;
  --ink-2: #c8cedb;
  --muted: #8b94a5;
  --grid: #242a35;
  --axis: #39414f;
  --border: rgba(255, 255, 255, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --s1: #3987e5;
  --s2: #199e70;
  --s3: #c98500;
  --s4: #9085e9;
  --total: #94a3b8;
  --good-text: #0ca30c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
a { color: inherit; }

/* ---------- Landing ---------- */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 520px at 88% -12%, rgba(30, 107, 60, .16), transparent 62%),
    radial-gradient(900px 460px at 6% 6%, rgba(27, 42, 94, .14), transparent 60%),
    var(--page);
}
.landing-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 20px clamp(20px, 5vw, 56px);
}
.landing-main {
  flex: 1; width: min(1180px, 100%); margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) clamp(20px, 5vw, 56px) 64px;
}
.landing-hero { max-width: 720px; margin-bottom: 40px; }
.landing-hero h1 { font-size: clamp(30px, 4.6vw, 46px); letter-spacing: -.025em; }
.landing-hero .lede { font-size: 17px; color: var(--ink-2); margin-top: 14px; }
.roles { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.role-card {
  display: block; text-decoration: none; padding: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease;
}
.role-card:hover { transform: translateY(-3px); box-shadow: 0 14px 34px -14px rgba(15, 23, 42, .32); }
.role-card .ico {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; margin-bottom: 14px; background: var(--surface-2); border: 1px solid var(--border);
}
.role-card h3 { font-size: 17px; margin-bottom: 6px; }
.role-card p { color: var(--ink-2); font-size: 13.5px; }
.role-card ul { margin: 12px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.role-card .go { margin-top: 16px; font-weight: 600; color: var(--green); font-size: 13.5px; }
:root[data-theme="dark"] .role-card .go, .landing .role-card .go { color: var(--s2); }
.landing-foot {
  border-top: 1px solid var(--border); padding: 18px clamp(20px, 5vw, 56px);
  color: var(--muted); font-size: 12.5px;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
}

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--green-dark); color: #eaf3ec; padding: 18px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar.navy { background: var(--navy); color: #e8ecf7; }
.sidebar .brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  color: inherit; padding: 6px 8px 16px;
}
.sidebar .brand .mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); font-weight: 700; font-size: 15px;
}
.sidebar .brand b { display: block; font-size: 14px; letter-spacing: .01em; }
.sidebar .brand span { display: block; font-size: 11px; opacity: .72; }
.sidebar .nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  opacity: .58; padding: 14px 10px 6px;
}
.sidebar a.nav {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  text-decoration: none; color: inherit; font-size: 13.5px; opacity: .86;
}
.sidebar a.nav:hover { background: rgba(255, 255, 255, .09); opacity: 1; }
.sidebar a.nav.active { background: rgba(255, 255, 255, .16); opacity: 1; font-weight: 600; }
.sidebar a.nav .ic { width: 18px; text-align: center; }
.sidebar .soon { margin-left: auto; font-size: 9.5px; letter-spacing: .04em; opacity: .7;
  border: 1px solid rgba(255, 255, 255, .3); border-radius: 999px; padding: 1px 6px; }
.sidebar .help {
  margin-top: auto; background: rgba(255, 255, 255, .08); border-radius: 10px;
  padding: 12px; font-size: 12px; line-height: 1.5;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 28px); background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 17px; font-weight: 650; }
.topbar .sub { font-size: 12.5px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.content { padding: clamp(16px, 3vw, 26px); display: flex; flex-direction: column; gap: 18px; }

/* ---------- Cards & grid ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px;
}
.card > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card > header .hint { font-size: 12px; color: var(--muted); margin-left: auto; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 1100px) { .g-main { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: 12.5px; color: var(--ink-2); }
.stat .value { font-size: 30px; font-weight: 660; letter-spacing: -.02em; line-height: 1.1; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.stat .delta { font-size: 12.5px; display: flex; align-items: center; gap: 5px; }
.delta.down { color: var(--good-text); }
.delta.up { color: var(--critical); }
.stat .spark { margin-top: 8px; }
.hero-value { font-size: clamp(38px, 5vw, 52px); font-weight: 680; letter-spacing: -.03em; line-height: 1; }

/* ---------- Meter ---------- */
.meter { height: 8px; border-radius: 999px; background: var(--grid); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--s2); }

/* ---------- Chart bits ---------- */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 10px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.legend .key { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.legend .key.dot { width: 10px; height: 10px; border-radius: 50%; }
.tip {
  position: absolute; pointer-events: none; z-index: 30; min-width: 132px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 10px 28px -10px rgba(15, 23, 42, .35); padding: 9px 11px; font-size: 12.5px;
  opacity: 0; transition: opacity .1s ease; transform: translate(-50%, -100%);
}
.tip.on { opacity: 1; }
.tip .t-h { font-weight: 650; margin-bottom: 5px; }
.tip .t-r { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tip .t-r b { font-variant-numeric: tabular-nums; font-weight: 600; }
.tip .t-k { width: 9px; height: 9px; border-radius: 2px; flex: none; }

.toggle-table {
  background: none; border: 0; color: var(--ink-2); font: inherit; font-size: 12px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 4px 0;
}

/* ---------- Table ---------- */
.tbl-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl .empty { color: var(--muted); text-align: center; padding: 26px; }

/* ---------- Forms ---------- */
label.f { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 9px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--s1); outline-offset: 1px; border-color: transparent; }
.field { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--axis);
  background: var(--surface); color: var(--ink); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--critical); border-color: var(--critical); background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Misc ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--ink-2); white-space: nowrap;
}
.badge.ok { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.badge.warn { color: #8a5b00; border-color: color-mix(in srgb, var(--warning) 55%, transparent); }
:root[data-theme="dark"] .badge.warn { color: var(--warning); }
.badge.s1 { color: var(--s1); border-color: color-mix(in srgb, var(--s1) 40%, transparent); }
.badge.s2 { color: var(--s2); border-color: color-mix(in srgb, var(--s2) 40%, transparent); }
.badge.s3 { color: #8a6100; border-color: color-mix(in srgb, var(--s3) 55%, transparent); }
:root[data-theme="dark"] .badge.s3 { color: var(--s3); }

.note {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--s1);
  border-radius: 8px; padding: 11px 13px; font-size: 12.5px; color: var(--ink-2);
}
.note.soon { border-left-color: var(--warning); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.list-clean { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rec {
  display: flex; gap: 11px; align-items: flex-start; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.rec .ic { font-size: 17px; line-height: 1.2; }
.rec b { display: block; font-size: 13px; }
.rec span { font-size: 12.5px; color: var(--ink-2); }
.rec .save { margin-left: auto; text-align: right; font-size: 12px; color: var(--good-text); font-weight: 600; white-space: nowrap; }
.rec .save.blk { display: block; margin: 5px 0 0; text-align: left; }

.steps { display: flex; flex-direction: column; gap: 0; }
.step { display: flex; gap: 12px; }
.step .rail { display: flex; flex-direction: column; align-items: center; }
.step .dot {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--axis); color: var(--muted);
}
.step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.now .dot { background: var(--surface); border-color: var(--s1); color: var(--s1); }
.step .line { flex: 1; width: 2px; background: var(--grid); margin: 3px 0; }
.step:last-child .line { display: none; }
.step .body { padding-bottom: 16px; }
.step .body b { font-size: 13px; }
.step .body span { display: block; font-size: 12.5px; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 12.5px; cursor: pointer; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--axis); background: var(--surface); color: var(--ink-2);
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 99;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.phone {
  width: 300px; border-radius: 30px; border: 9px solid var(--navy); background: var(--surface);
  padding: 14px 14px 18px; box-shadow: var(--shadow); flex: none;
}
.phone .bar { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-bottom: 10px; }

.badge-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.badge-item { text-align: center; padding: 14px 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.badge-item .em { font-size: 26px; display: block; }
.badge-item b { display: block; font-size: 12.5px; margin-top: 6px; }
.badge-item span { font-size: 11.5px; color: var(--muted); }
.badge-item.locked { opacity: .45; }

/* ---------- Report preview ---------- */
.report {
  background: #fff; color: #10131a; border: 1px solid var(--border); border-radius: 10px;
  padding: 34px 38px; max-width: 900px; margin: 0 auto; box-shadow: var(--shadow);
}
.report h1 { font-size: 21px; color: #1b2a5e; }
.report h2 { font-size: 15px; color: #1b2a5e; margin: 22px 0 8px; }
.report table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 8px 0 4px; }
.report th, .report td { border: 1px solid #d9dee7; padding: 6px 9px; text-align: left; }
.report th { background: #f1f4f9; font-weight: 600; }
.report td.num { text-align: right; font-variant-numeric: tabular-nums; }
.report .meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 20px; font-size: 12.5px; }
.report .meta div { display: flex; gap: 6px; }
.report .meta b { min-width: 120px; color: #4a5568; font-weight: 500; }
.report .seal {
  margin-top: 24px; border: 1px dashed #9aa5b8; border-radius: 10px; padding: 14px 16px;
  font-size: 12px; color: #4a5568;
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .report { border: 0; box-shadow: none; max-width: none; padding: 0; }
  body { background: #fff; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 6px; padding: 10px;
  }
  .sidebar .brand { padding: 4px 8px; }
  .sidebar .nav-label, .sidebar .help { display: none; }
  .sidebar a.nav { padding: 6px 9px; font-size: 12.5px; }
}
