:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --surface: #fdfcf8;
  --ink: #1f1d19;
  --ink-2: #4c483f;
  --muted: #6f6a5f;
  --line: #e4dfd3;
  --line-strong: #cfc8b8;
  --accent: #c2410c;
  --accent-ink: #9a3412;
  --good: #166534;
  --bad: #b91c1c;
  --warn: #92400e;
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(60, 50, 30, 0.05), 0 8px 24px rgba(60, 50, 30, 0.06);
  --sans: 'Geist', ui-sans-serif, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: min(1240px, 100%); margin-inline: auto; padding-inline: 28px; }
.wordmark { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; text-decoration: none; }
.wordmark span { color: var(--accent); margin-inline: 1px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: #f3efe5; border-color: #b9b19e; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-primary:hover { background: #38342c; border-color: #38342c; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: rgba(60, 50, 30, 0.06); border-color: transparent; }
.btn-danger { color: var(--bad); border-color: #e7c3bb; }
.btn-danger:hover { background: #fbeeeb; border-color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: #991b1b; border-color: #991b1b; }
.btn-block { width: 100%; min-height: 48px; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: var(--r-sm); }

/* Form */
.field { display: grid; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); transition: border-color 0.15s ease;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #b0a892; }
.field input:disabled, .field select:disabled { background: #f3efe5; color: var(--muted); cursor: not-allowed; }
.field .hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.form-error { color: var(--bad); font-size: 14px; }
.slug-input { display: flex; align-items: stretch; }
.slug-input span {
  display: flex; align-items: center; padding-inline: 10px; font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  background: #f3efe5; border: 1px solid var(--line-strong); border-right: 0; border-radius: var(--r-md) 0 0 var(--r-md);
  white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis;
}
.field .slug-input input { border-radius: 0 var(--r-md) var(--r-md) 0; font-family: var(--mono); font-size: 14px; min-width: 0; }

/* Login */
.login-page { min-height: 100dvh; display: grid; grid-template-columns: 1.15fr 1fr; }
.login-side {
  display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px 56px;
  background: var(--ink); color: var(--bg);
}
.login-side .wordmark span { color: #ea7c45; }
.login-statement {
  max-width: 13ch; font-size: clamp(44px, 5.4vw, 76px); line-height: 1.02; font-weight: 600;
  letter-spacing: -0.035em; text-wrap: balance;
}
.login-main { display: grid; place-items: center; padding: 32px 24px; }
.login-form { width: min(380px, 100%); display: grid; gap: 18px; }
.login-form h1 { font-size: 26px; letter-spacing: -0.02em; font-weight: 600; margin-bottom: 6px; }
.login-mark { display: none; }

/* Topbar */
.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 28px; min-height: 64px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a {
  padding: 8px 12px; border-radius: var(--r-sm); text-decoration: none; color: var(--muted); font-weight: 500;
  white-space: nowrap; transition: color 0.15s ease, background-color 0.15s ease;
}
.tabs a:hover { color: var(--ink); background: rgba(60, 50, 30, 0.05); }
.tabs a[aria-current='page'] { color: var(--ink); background: rgba(60, 50, 30, 0.08); }

/* Composer: benda utama yang awak buat kat sini */
.composer { margin-top: 24px; background: var(--ink); color: var(--bg); border-radius: var(--r-lg); padding: 10px; box-shadow: var(--shadow); }
.composer-main { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.composer-label { padding-inline: 12px 8px; font-size: 13px; font-weight: 500; color: #b8b2a4; white-space: nowrap; }
.composer-input {
  width: 100%; min-height: 48px; padding: 10px 14px; background: #2d2a24; border: 1px solid transparent;
  border-radius: var(--r-md); color: #fff; font-family: var(--mono); font-size: 14.5px;
}
.composer-input::placeholder { color: #958f81; font-family: var(--sans); }
.composer-input:hover { border-color: #4d483e; }
.composer .btn-accent { min-height: 48px; padding-inline: 22px; }
.composer :focus-visible { outline-color: #ea7c45; }
.composer-options {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; padding: 14px 12px 8px;
  animation: reveal 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.composer-options .field label { color: #c9c3b5; }
.composer-options .field input, .composer-options .field select, .composer-options .field textarea { background: #2d2a24; border-color: #4d483e; color: #fff; }
.composer-options .field input::placeholder, .composer-options .field textarea::placeholder { color: #958f81; }
.composer-options .slug-input span { background: #38342c; border-color: #4d483e; color: #b8b2a4; }
.composer-options .hint { color: #b8b2a4; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.composer-note { grid-column: 1 / -1; font-size: 13px; color: #c9c3b5; }
.composer-note strong { color: #fff; font-weight: 600; }
.composer-error { padding: 8px 12px 6px; color: #fda98c; font-size: 14px; }
.composer-result {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 10px; padding: 10px 12px;
  background: #2d2a24; border-radius: var(--r-md); animation: reveal 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.composer-result .short { font-family: var(--mono); font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.composer-result .btn { background: var(--bg); color: var(--ink); border-color: var(--bg); }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } }

/* View */
.view { padding-block: 32px 80px; outline: none; }
.view-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.view-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; padding: 3px; background: rgba(60, 50, 30, 0.07); border-radius: var(--r-md); }
.seg button {
  min-height: 34px; padding: 4px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  font-weight: 500; font-size: 14px; cursor: pointer; transition: color 0.15s ease, background-color 0.15s ease;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(60, 50, 30, 0.12); }
.select-sm { min-height: 40px; max-width: 220px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 24px; min-width: 0; }
.panel h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.panel .sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack > .panel:last-child { flex: 1; }
.fit { align-self: start; }

/* Hero stat */
.hero { display: grid; grid-template-columns: minmax(250px, 3fr) 8fr; gap: 32px; }
.hero-stat .figure { font-family: var(--mono); font-size: clamp(52px, 6vw, 76px); font-weight: 500; letter-spacing: -0.05em; line-height: 1; margin-top: 10px; font-variant-numeric: tabular-nums; }
.delta { margin-top: 8px; font-size: 13px; color: var(--muted); }
.delta b { font-weight: 600; color: var(--ink); }
.minis { margin: 22px 0 0; display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.minis div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.minis dt { color: var(--muted); font-size: 13.5px; }
.minis dd { margin: 0; font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.minis dd.bad { color: var(--bad); }

/* Column chart */
.chart { position: relative; margin-top: 16px; }
.plot { position: relative; height: 230px; margin-left: 40px; }
.grid-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.grid-line span { position: absolute; right: calc(100% + 8px); top: -9px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.cols { position: absolute; inset: 0; display: grid; align-items: end; gap: 2px; }
.col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.col:hover { background: rgba(60, 50, 30, 0.05); }
.bar { width: 100%; max-width: 24px; background: var(--accent); border-radius: 4px 4px 0 0; transform-origin: bottom; animation: grow 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.peak { position: absolute; left: 50%; transform: translateX(-50%); padding-bottom: 3px; font-family: var(--mono); font-size: 12px; color: var(--ink-2); pointer-events: none; }
@keyframes grow { from { transform: scaleY(0); } }
.x-axis { position: relative; height: 22px; margin: 6px 0 0 40px; }
.x-axis span { position: absolute; transform: translateX(-50%); font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.tip {
  position: absolute; z-index: 5; padding: 6px 10px; background: var(--ink); color: var(--bg); border-radius: var(--r-sm);
  font-size: 12.5px; pointer-events: none; white-space: nowrap; transform: translate(-50%, -100%);
}
.tip b { font-family: var(--mono); font-weight: 500; margin-left: 6px; }
details.table-view { margin-top: 10px; font-size: 13px; color: var(--muted); }
details.table-view summary { cursor: pointer; width: fit-content; padding: 4px 0; }
details.table-view summary:hover { color: var(--ink); }
details.table-view .table-wrap { max-height: 240px; overflow: auto; margin-top: 6px; }

/* Horizontal bars */
.hbars { margin-top: 14px; display: grid; gap: 2px; }
.hbar { display: grid; grid-template-columns: minmax(96px, 36%) 1fr 62px; align-items: center; gap: 12px; min-height: 34px; padding-inline: 6px; margin-inline: -6px; border-radius: var(--r-sm); }
.hbar:hover { background: rgba(60, 50, 30, 0.04); }
.hbar-label { min-width: 0; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-label small { color: var(--muted); font-size: 12.5px; margin-left: 5px; }
.hbar-track { height: 16px; }
.hbar-fill { height: 100%; min-width: 3px; background: var(--accent); border-radius: 0 4px 4px 0; transform-origin: left; animation: growx 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes growx { from { transform: scaleX(0); } }
.hbar-value { text-align: right; font-family: var(--mono); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.hbars-empty { margin-top: 14px; font-size: 14px; color: var(--muted); }

/* Table */
.table-wrap { overflow-x: auto; margin-inline: -24px; padding-inline: 24px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(60, 50, 30, 0.025); }
th.num, td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; padding-right: 0; }
.truncate { display: block; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slug-cell { display: flex; align-items: center; gap: 8px; }
.slug-cell .slug { font-family: var(--mono); font-weight: 500; font-size: 14px; }
.tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.status.sent::before { background: var(--good); }
.status.failed { color: var(--bad); }
.status.failed::before { background: var(--bad); }
.status.pending::before { background: var(--warn); }
.off { opacity: 0.55; }

/* Empty + skeleton + error */
.empty { padding: 56px 24px; text-align: center; }
.empty h2 { font-size: 18px; letter-spacing: -0.01em; }
.empty p { margin: 6px auto 0; max-width: 46ch; color: var(--muted); }
.empty .btn { margin-top: 16px; }
.banner { padding: 14px 16px; background: #fbeeeb; border: 1px solid #e7c3bb; border-radius: var(--r-md); color: #7f1d1d; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.skeleton { background: linear-gradient(90deg, #ece7db 25%, #f4f0e6 50%, #ece7db 75%); background-size: 200% 100%; border-radius: var(--r-md); animation: shimmer 1.3s linear infinite; }
.sk-hero { height: 340px; } .sk-row { height: 260px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Tips block */
.tipbox { display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; align-items: center; margin-top: 16px; }
.code-line { grid-column: 1 / -1; padding: 10px 12px; background: #f3efe5; border-radius: var(--r-sm); font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; color: var(--ink-2); }

/* Pixel list */
.pixel-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.pixel-row:last-child { border-bottom: 0; }
.pixel-row h3 { font-size: 15px; font-weight: 600; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Drawer + confirm */
dialog { color: inherit; border: 0; padding: 0; }
dialog::backdrop { background: rgba(31, 29, 25, 0.42); }
.drawer { margin: 0 0 0 auto; width: min(500px, 100vw); height: 100dvh; max-height: none; max-width: none; background: var(--surface); box-shadow: -8px 0 40px rgba(60, 50, 30, 0.16); }
.drawer[open] { animation: slide 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer form { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.drawer-body { flex: 1; overflow-y: auto; display: grid; gap: 16px; align-content: start; padding: 20px 24px 28px; }
.drawer-section { padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 14px; }
.drawer-section h3 { font-size: 14px; font-weight: 600; }
.drawer-section > p { font-size: 13px; color: var(--muted); margin-top: -8px; }
.drawer-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--bg); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.confirm { width: min(420px, calc(100vw - 32px)); margin: auto; background: var(--surface); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow); }
.confirm h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.confirm p { margin-top: 8px; color: var(--ink-2); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%); padding: 10px 16px; background: var(--ink); color: var(--bg); border-radius: var(--r-md); font-size: 14px; box-shadow: var(--shadow); animation: reveal 0.2s ease; max-width: calc(100vw - 32px); }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .col-4, .col-5, .col-6, .col-7, .col-8 { grid-column: span 12; }
}

@media (max-width: 760px) {
  .wrap { padding-inline: 16px; }
  .login-page { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .login-mark { display: block; margin-bottom: 24px; }
  .topbar-inner { flex-wrap: wrap; gap: 4px 12px; padding-block: 10px 6px; }
  .topbar-inner .wordmark { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; margin-inline: -4px; }
  .composer { margin-top: 16px; }
  .composer-main { grid-template-columns: 1fr; }
  .composer-label { padding: 4px 4px 0; }
  .composer-options { padding-inline: 4px; }
  .composer-options > .field, .composer-note { grid-column: span 12; }
  .panel { padding: 18px 16px; }
  .table-wrap { margin-inline: -16px; padding-inline: 16px; }
  .hide-sm { display: none; }
  .hbar { grid-template-columns: minmax(84px, 38%) 1fr 48px; gap: 8px; }
  .plot, .x-axis { margin-left: 32px; }
  .select-sm { max-width: 100%; flex: 1; }
  .truncate { max-width: 170px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
