/* KARA Cost & Pricing
   Tata letak: kerangka aplikasi satu kolom; kepala lengket berisi merek dan tab,
   isi berupa kartu kerja di atas kisi halus. Terang = warna pekat untuk ruang terang;
   gelap = kisi neon cyan x pink. */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #e6edf4;
  --line: #c4d0dc;
  --fg: #0a1422;
  --muted: #47566b;
  --primary: #006878;
  --primary-fg: #ffffff;
  --accent: #b01279;
  --good: #0a7340;
  --warn: #8a5200;
  --bad: #b3261e;
  --info: #1d4f91;
  --grid: rgba(0, 104, 120, 0.07);
  --glow: none;
  --seg-fee: #b01279;
  --seg-pack: #8a5200;
  --seg-hpp: #47566b;
  --seg-cm: #006878;

  --font-display: 'Orbitron', 'Eurostile', 'Bank Gothic', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-data: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --radius: 6px;
  --gap: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #06080e;
    --surface: #0d111b;
    --surface-2: #151b2a;
    --line: #25314b;
    --fg: #e4f1ff;
    --muted: #8da0bd;
    --primary: #00e5ff;
    --primary-fg: #00151a;
    --accent: #ff3ec9;
    --good: #3dffa2;
    --warn: #ffc857;
    --bad: #ff6b6b;
    --info: #7fb4ff;
    --grid: rgba(0, 229, 255, 0.055);
    --glow: 0 0 14px rgba(0, 229, 255, 0.28);
    --seg-fee: #ff3ec9;
    --seg-pack: #ffc857;
    --seg-hpp: #6f819f;
    --seg-cm: #00e5ff;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #06080e;
  --surface: #0d111b;
  --surface-2: #151b2a;
  --line: #25314b;
  --fg: #e4f1ff;
  --muted: #8da0bd;
  --primary: #00e5ff;
  --primary-fg: #00151a;
  --accent: #ff3ec9;
  --good: #3dffa2;
  --warn: #ffc857;
  --bad: #ff6b6b;
  --info: #7fb4ff;
  --grid: rgba(0, 229, 255, 0.055);
  --glow: 0 0 14px rgba(0, 229, 255, 0.28);
  --seg-fee: #ff3ec9;
  --seg-pack: #ffc857;
  --seg-hpp: #6f819f;
  --seg-cm: #00e5ff;
  color-scheme: dark;
}

:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
h1,
h2,
h3 {
  margin: 0;
  text-wrap: balance;
}
h1 {
  font-size: 1.35rem;
  font-weight: 700;
}
h2 {
  font-size: 1.02rem;
  font-weight: 700;
}
h3 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
}
p {
  margin: 0;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.strong {
  font-weight: 700;
}
.good {
  color: var(--good);
}
.bad {
  color: var(--bad);
}
.warn {
  color: var(--warn);
}

/* kepala */
.app-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}
.brand b {
  color: var(--primary);
  text-shadow: var(--glow);
}
.brand span {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--accent);
}
.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.status {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 0;
}
.status.busy {
  color: var(--info);
}
.status.bad {
  color: var(--bad);
}
.tabs {
  flex-basis: 100%;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font: 600 0.9rem var(--font-body);
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover {
  color: var(--fg);
}
.tab[aria-current='page'] {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* halaman */
.page {
  max-width: 1240px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 20px 48px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.page-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 68ch;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}
@media (max-width: 860px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.card.empty {
  max-width: 62ch;
  padding: 28px 22px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* form */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 12px;
  align-items: start;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.hint {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}
.in {
  width: 100%;
  min-width: 0;
  font: 500 0.92rem var(--font-body);
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 9px;
}
.in.num {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}
.in::placeholder {
  color: var(--muted);
  opacity: 0.75;
}
.in:focus-visible,
.btn:focus-visible,
.tab:focus-visible,
summary:focus-visible,
.check input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  box-shadow: var(--glow);
}
select.in {
  padding-right: 4px;
}
.in.area {
  font-family: var(--font-data);
  font-size: 0.8rem;
  resize: vertical;
}
.affix {
  display: flex;
  align-items: center;
  gap: 4px;
}
.affix span {
  color: var(--muted);
  font-size: 0.85rem;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
  cursor: pointer;
}
.check input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  margin: 0;
}
.checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.btn {
  appearance: none;
  font: 600 0.88rem var(--font-body);
  border-radius: 4px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-fg);
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary:hover {
  box-shadow: var(--glow);
}
.btn.ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--line);
}
.btn.ghost:hover {
  border-color: var(--primary);
}
.btn.danger {
  color: var(--bad);
  background: transparent;
  border-color: var(--line);
}
.btn.danger:hover {
  border-color: var(--bad);
}
.btn.small {
  padding: 4px 8px;
  font-size: 0.8rem;
}
.file-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
}
.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.confirm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--bad);
  white-space: nowrap;
}
.chip {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  color: var(--muted);
  white-space: nowrap;
}
.chip.good {
  color: var(--good);
}
.chip.warn {
  color: var(--warn);
  white-space: normal;
}
.chip.bad {
  color: var(--bad);
}
.chip.info {
  color: var(--info);
}
.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--fg);
}
.notice.good {
  border-left-color: var(--good);
}
.notice.warn {
  border-left-color: var(--warn);
}
.notice.bad {
  border-left-color: var(--bad);
}

/* kalkulator */
.line {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
}
.line-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px 10px;
}
.line-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 520px) {
  .stats {
    grid-template-columns: minmax(0, 1fr);
  }
}
.stat {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  background: var(--surface-2);
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  overflow-wrap: anywhere;
}
.stat.good .stat-value {
  color: var(--primary);
  text-shadow: var(--glow);
}
.stat.bad .stat-value {
  color: var(--bad);
}
.stat-sub {
  font-size: 0.78rem;
  color: var(--muted);
}
.alloc {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.alloc-bar {
  display: flex;
  height: 14px;
  border-radius: 3px;
  overflow: hidden;
  gap: 2px;
}
.seg {
  flex-basis: 0;
  min-width: 2px;
}
.seg-fee {
  background: var(--seg-fee);
}
.seg-pack {
  background: var(--seg-pack);
}
.seg-hpp {
  background: var(--seg-hpp);
}
.seg-cm {
  background: var(--seg-cm);
  box-shadow: var(--glow);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.8rem;
  color: var(--muted);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.legend b {
  color: var(--fg);
  font-family: var(--font-data);
  font-weight: 600;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
}

/* tabel */
.scroll-x {
  overflow-x: auto;
  max-width: 100%;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.tbl th,
.tbl td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.tbl thead th {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  vertical-align: bottom;
}
.tbl tbody th {
  font-weight: 600;
}
.tbl .n {
  text-align: right;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tbl tbody tr:last-child td,
.tbl tbody tr:last-child th {
  border-bottom: 0;
}
.tbl.dense td {
  padding: 4px 5px;
  vertical-align: middle;
}
.tbl.dense .in {
  padding: 5px 7px;
  font-size: 0.86rem;
  min-width: 96px;
}
.tbl.dense .in.wide {
  min-width: 210px;
}
.tbl.dense .in.short {
  min-width: 68px;
  width: 78px;
}
.tbl.dense .in.code {
  min-width: 104px;
  font-family: var(--font-data);
}
.tbl.dense select.in {
  min-width: 150px;
}
.tbl.dense td.bad .in {
  border-color: var(--bad);
  color: var(--bad);
}
.tbl.dense td.warn .in {
  border-color: var(--warn);
}
.row-actions {
  white-space: nowrap;
}
.tbl .chip {
  white-space: nowrap;
}
.breakdown td:first-child .muted {
  font-size: 0.8rem;
  margin-left: 4px;
}
.breakdown tr.sub td {
  font-weight: 700;
  background: var(--surface-2);
}
.breakdown tr.total td {
  font-weight: 700;
  color: var(--primary);
  border-top: 2px solid var(--primary);
  font-size: 1rem;
}
.kv td:first-child {
  width: 62%;
}
.modes th[scope='row'] {
  white-space: nowrap;
  color: var(--muted);
  font-weight: 600;
}

/* produk */
details.prod {
  padding: 0;
  gap: 0;
}
details.prod > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
details.prod > summary::-webkit-details-marker {
  display: none;
}
details.prod[open] > summary {
  border-bottom: 1px solid var(--line);
}
details.prod > *:not(summary) {
  margin: 12px 16px 0;
}
details.prod > *:last-child {
  margin-bottom: 16px;
}
.prod-name {
  font-weight: 700;
}
.prod-name::before {
  content: '+';
  display: inline-block;
  width: 1.1em;
  color: var(--primary);
  font-family: var(--font-data);
}
details.prod[open] .prod-name::before {
  content: '−';
}
.prod-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.82rem;
  color: var(--muted);
  align-items: center;
}
.bulk {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
details.paste summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.88rem;
}
details.paste[open] {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .tab,
  .in {
    transition: border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
  }
}

/* iklan & performa */
.stats.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 860px) {
  .stats.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 520px) {
  .stats.four {
    grid-template-columns: minmax(0, 1fr);
  }
}
.tbl td.ad-name {
  min-width: 210px;
  max-width: 320px;
  white-space: normal;
  font-weight: 600;
}
.tbl td.ad-name .hint {
  font-weight: 400;
}
.tbl.ads td {
  vertical-align: top;
}
.notes {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}
.tbl tr.total-row td {
  border-top: 2px solid var(--primary);
  font-weight: 700;
}

.ad-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 2px;
}
.tbl td.ad-name select.ad-link {
  margin-top: 6px;
  width: 100%;
  font-weight: 400;
}
.tbl.ads input.short {
  min-width: 84px;
}

.status.action {
  color: var(--warn);
  cursor: pointer;
  text-decoration: underline;
}
