/* =========================================================================
   Mair Capital — gaya antarmuka
   Palet: kertas hangat + aksen emerald. Angka memakai tabular-nums supaya
   kolom tetap sejajar saat dibaca cepat.
   ========================================================================= */

:root {
    --paper:        #f5f4f0;
    --surface:      #ffffff;
    --surface-alt:  #faf9f6;
    --ink:          #161d1a;
    --ink-soft:     #5c6763;
    /* Kontras 4,94:1 di atas surface-alt — teks sekunder tetap harus terbaca. */
    --ink-faint:    #656f6b;
    --line:         #e2e0d9;
    --line-strong:  #cdcabf;

    --accent:       #0b6b53;
    --accent-soft:  #e3f0ea;
    --accent-ink:   #075441;

    --positive:     #0a7048;
    --positive-bg:  #e6f4ec;
    --negative:     #b02a1f;
    --negative-bg:  #fbeae7;
    --warn:         #92600a;
    --warn-bg:      #fdf3e0;

    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 1px 2px rgba(22,29,26,.05), 0 8px 24px -16px rgba(22,29,26,.28);

    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper:       #101413;
        --surface:     #171d1b;
        --surface-alt: #1c2321;
        --ink:         #e8ece9;
        --ink-soft:    #9aa5a0;
        --ink-faint:   #8a938f;
        --line:        #2a3230;
        --line-strong: #3a4441;

        --accent:      #4bbf98;
        --accent-soft: #14312a;
        --accent-ink:  #7fd8b8;

        --positive:    #4cc38a;
        --positive-bg: #143024;
        --negative:    #f0776a;
        --negative-bg: #35201d;
        --warn:        #e0b25e;
        --warn-bg:     #322a17;

        --shadow:      0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.7);
    }
}

* { box-sizing: border-box; }

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

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

/* Satu cincin fokus yang konsisten untuk semua elemen yang bisa dijangkau
   keyboard. :focus-visible dipakai supaya cincin tidak muncul saat diklik mouse. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Hormati pengaturan "kurangi gerakan" milik pengguna. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.012em; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p  { margin: 0 0 10px; }

/* ------------------------------------------------------------------ shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px 18px;
    color: var(--ink);
    text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    font-weight: 700;
    font-size: 15px;
}
.brand-text { font-size: 15px; letter-spacing: -.02em; color: var(--ink-soft); }
.brand-text strong { color: var(--ink); font-weight: 700; }
.brand-lg .brand-mark { width: 38px; height: 38px; font-size: 19px; }
.brand-lg .brand-text { font-size: 19px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.nav-item:hover { background: var(--surface-alt); color: var(--ink); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item.is-active svg { opacity: 1; }

.nav-divider { height: 1px; background: var(--line); margin: 12px 8px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; }

.sub-chip {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600;
    color: var(--ink-soft);
    background: var(--surface-alt);
}
.sub-chip:hover { text-decoration: none; border-color: var(--line-strong); }
/* Ukuran eksplisit: <small> bawaan browser akan turun ke 10px dari induk 12px. */
.sub-chip small { font-size: 12px; font-weight: 400; color: var(--ink-faint); width: 100%; }
.sub-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.sub-active .dot, .sub-trialing .dot { background: var(--positive); }
.sub-past_due .dot { background: var(--warn); }
.sub-expired .dot, .sub-canceled .dot { background: var(--negative); }

/* ------------------------------------------------------------------- main */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 18px 26px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.topbar-sub { margin: 0; font-size: 12px; color: var(--ink-faint); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.usermenu { position: relative; }
.usermenu summary {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; list-style: none;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    border: 1px solid var(--line);
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-name { font-size: 13px; font-weight: 500; }
.avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
}
.usermenu-panel {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 200px; z-index: 20;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px;
}
.usermenu-email { font-size: 12px; color: var(--ink-faint); margin-bottom: 8px; word-break: break-all; }
.usermenu-panel a, .usermenu-panel .linklike {
    display: block; width: 100%; text-align: left;
    padding: 6px 8px; border-radius: var(--radius-sm);
    color: var(--ink); font-size: 13px;
}
.usermenu-panel a:hover, .usermenu-panel .linklike:hover { background: var(--surface-alt); text-decoration: none; }
.linklike { background: none; border: 0; cursor: pointer; font: inherit; color: var(--negative); }

.content { padding: 22px 26px 40px; flex: 1; }
.foot { padding: 16px 26px 26px; font-size: 12px; color: var(--ink-faint); }

/* --------------------------------------------------------------- messages */

.banner {
    margin: 0; padding: 11px 26px;
    background: var(--accent-soft); color: var(--accent-ink);
    font-size: 13px;
    border-bottom: 1px solid var(--line);
}
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner a { font-weight: 600; color: inherit; text-decoration: underline; }

.toast {
    margin: 16px 26px -6px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid transparent;
}
.toast-success { background: var(--positive-bg); color: var(--positive); border-color: color-mix(in srgb, var(--positive) 22%, transparent); }
.toast-error   { background: var(--negative-bg); color: var(--negative); border-color: color-mix(in srgb, var(--negative) 22%, transparent); }
.auth-card .toast { margin: 0 0 16px; }

/* ------------------------------------------------------------------ cards */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 15px; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--ink-faint); }
.card-body { padding: 16px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-alt); font-size: 12px; color: var(--ink-soft); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ------------------------------------------------------------------ stats */

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-weight: 600; }
.stat-value { font-size: 23px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-note  { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data thead th {
    background: var(--surface-alt);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
    font-weight: 650;
    position: sticky; top: 0; z-index: 1;
}
table.data tbody tr:hover { background: var(--surface-alt); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tfoot td { font-weight: 650; background: var(--surface-alt); border-top: 2px solid var(--line-strong); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-faint); }
/* Baris keterangan di bawah nilai utama dalam sel tabel. */
.sub-line { font-size: 12px; line-height: 1.35; color: var(--ink-faint); font-weight: 400; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.wrap { white-space: normal; }

.positive { color: var(--positive); }
.negative { color: var(--negative); }
.neutral  { color: var(--ink-faint); }

/* ------------------------------------------------------------------ pills */

.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px; font-weight: 600;
    background: var(--surface-alt);
    color: var(--ink-soft);
    border: 1px solid var(--line);
    white-space: nowrap;
}
.pill-buy       { background: var(--positive-bg); color: var(--positive); border-color: transparent; }
.pill-sell      { background: var(--negative-bg); color: var(--negative); border-color: transparent; }
.pill-good      { background: var(--positive-bg); color: var(--positive); border-color: transparent; }
.pill-bad       { background: var(--negative-bg); color: var(--negative); border-color: transparent; }
.pill-warn      { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill-accent    { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.pill-code      { font-family: var(--mono); font-weight: 700; letter-spacing: .02em; }

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 13px; }
.field label {
    display: block;
    font-size: 12px; font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 5px;
}
.field .hint { font-size: 12px; color: var(--ink-faint); font-weight: 400; margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=file], select, textarea {
    width: 100%;
    padding: 8px 10px;
    font: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
input[type=file] { padding: 7px 10px; background: var(--surface-alt); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px;
    font: inherit; font-size: 13.5px; font-weight: 600;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-danger { color: var(--negative); border-color: color-mix(in srgb, var(--negative) 35%, var(--line)); }
.btn-danger:hover { background: var(--negative-bg); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .5; cursor: not-allowed; }

.segment { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segment label { position: relative; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span {
    display: block; padding: 8px 18px; cursor: pointer;
    font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
    background: var(--surface);
}
.segment label + label span { border-left: 1px solid var(--line-strong); }
.segment input:checked + span { background: var(--accent); color: #fff; }
.segment input:focus-visible + span { box-shadow: inset 0 0 0 2px var(--accent-ink); }

/* ------------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
    padding: 9px 15px;
    font-size: 13.5px; font-weight: 600;
    color: var(--ink-soft);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tab .count { font-size: 12px; color: var(--ink-faint); font-weight: 500; }

/* ---------------------------------------------------------------- filters */

.filters {
    display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.filters .field { margin: 0; min-width: 140px; flex: 0 1 auto; }
.filters .spacer { flex: 1; }
.filters .actions { display: flex; gap: 8px; }

/* ----------------------------------------------------------------- empty */

.empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--ink-faint);
}
.empty h2 { color: var(--ink); margin-bottom: 6px; }
.empty p { max-width: 460px; margin-inline: auto; }
.empty-error { padding-top: 70px; }
.error-code { font-size: 54px; font-weight: 700; color: var(--line-strong); margin: 0; line-height: 1; }

/* ------------------------------------------------------------------- auth */

.auth-shell { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-aside {
    background: var(--accent);
    color: #fff;
    padding: 46px 44px;
    display: flex; flex-direction: column; justify-content: center;
    background-image: radial-gradient(circle at 88% 8%, rgba(255,255,255,.14), transparent 42%),
                      radial-gradient(circle at 6% 92%, rgba(0,0,0,.16), transparent 46%);
}
.auth-aside .brand { color: #fff; margin-bottom: 30px; padding: 0; }
.auth-aside .brand-mark { background: rgba(255,255,255,.18); }
.auth-aside .brand-text, .auth-aside .brand-text strong { color: #fff; }
.auth-aside h2 { font-size: 27px; line-height: 1.28; max-width: 15ch; margin-bottom: 26px; letter-spacing: -.02em; }
.auth-points { list-style: none; padding: 0; margin: 0 0 26px; display: grid; gap: 13px; max-width: 46ch; }
.auth-points li { display: flex; gap: 11px; font-size: 14px; color: rgba(255,255,255,.9); line-height: 1.5; }
.auth-points span {
    flex: 0 0 22px; height: 22px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
}
.auth-note { font-size: 12.5px; color: rgba(255,255,255,.7); margin: 0; }

.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { color: var(--ink-faint); font-size: 13.5px; margin-bottom: 22px; }
.auth-alt { margin-top: 18px; font-size: 13px; color: var(--ink-soft); text-align: center; }

@media (max-width: 860px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

.plain-shell {
    max-width: 560px;
    margin: 0 auto;
    padding: 56px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.plain-shell .brand { padding-bottom: 12px; }

/* ------------------------------------------------------------------ misc */

.inline-form { display: inline; }
.stack { display: grid; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { margin: 26px 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-weight: 650; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-faint); }
.callout {
    padding: 12px 14px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-bottom: 14px;
}
.callout strong { color: var(--ink); }

.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.price-tag {
    display: flex; align-items: baseline; gap: 6px;
    font-size: 30px; font-weight: 700; letter-spacing: -.03em;
}
.price-tag small { font-size: 13px; font-weight: 500; color: var(--ink-faint); letter-spacing: 0; }

/* ------------------------------------------------------------------ print */

.print-page { max-width: 1000px; margin: 0 auto; padding: 30px 24px; background: var(--surface); }
.print-actions { display: flex; gap: 8px; margin-bottom: 22px; }
.print-head { border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 18px; }
.print-head h1 { font-size: 20px; }
.print-head p { margin: 4px 0 0; font-size: 12px; color: var(--ink-soft); }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; color: #000; font-size: 10.5px; }
    .print-page { padding: 0; max-width: none; }
    table.data th, table.data td { padding: 4px 6px; border-bottom: 1px solid #ccc; }
    table.data thead th { background: #eee; color: #000; }
}

@media (max-width: 900px) {
    .shell { flex-direction: column; }

    /* Sidebar menjadi satu strip navigasi mendatar yang bisa digeser, supaya
       konten langsung terlihat tanpa harus melewati seluruh daftar menu. */
    .sidebar {
        width: 100%; flex: none; height: auto;
        position: sticky; top: 0; z-index: 30;
        flex-direction: row; align-items: center; gap: 8px;
        padding: 8px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        overflow-x: auto; overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .sidebar::-webkit-scrollbar { display: none; }
    .brand { padding: 0 4px 0 0; flex: 0 0 auto; }
    .brand-text { display: none; }
    .nav { flex-direction: row; flex-wrap: nowrap; gap: 4px; }
    .nav-item { white-space: nowrap; flex: 0 0 auto; }
    .nav-divider { display: none; }
    .sidebar-foot { margin: 0; padding: 0; flex: 0 0 auto; }
    .sub-chip { flex-wrap: nowrap; white-space: nowrap; }
    .sub-chip small { display: none; }

    .content, .topbar, .banner, .toast { padding-inline: 16px; }
    .toast { margin-inline: 16px; }

    /* Di layar sentuh, tinggi elemen yang bisa ditekan dinaikkan ke 44px dan
       jaraknya direnggangkan supaya tidak salah tekan. */
    .btn, .usermenu summary, .nav-item, .segment span,
    input[type=text], input[type=email], input[type=password], input[type=number],
    input[type=date], input[type=search], select {
        min-height: 44px;
    }
    .btn, .segment span { display: inline-flex; align-items: center; }
    .btn-sm { min-height: 40px; padding: 8px 12px; font-size: 13px; }
    .form-actions, .filters .actions, .card-head .actions { gap: 10px; }
    /* Tombol aksi di dalam tabel ditumpuk agar tidak berdempetan. */
    table.data td .inline-form { display: block; margin-top: 6px; }
}

@media (max-width: 560px) {
    .topbar { flex-wrap: wrap; }
    .usermenu-name { display: none; }
    .filters .field { min-width: 100%; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
