/*
 * Ethera ERP — sistem desain (Fase 22).
 * Arah: cerah dan tenang, kontras tinggi untuk angka, target sentuh ≥ 40px, fokus keyboard selalu terlihat.
 * Satu warna merek (hijau zamrud) + warna status; sisanya netral supaya data yang menonjol, bukan hiasan.
 * Kelas lama (.card, .grid, .flash, .badge, .muted, .num, button.primary/.secondary) tetap berlaku.
 */
@font-face {
    font-family: "Inter";
    src: url("/fonts/inter-latin-wght.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --brand: #0e7a61;
    --brand-strong: #0a5f4c;
    --brand-soft: #e9f7f2;
    --brand-ring: rgb(14 122 97 / .28);
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e6e8ec;
    --line-strong: #cfd4dc;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --good: #15803d; --good-soft: #ecfdf3;
    --warn: #a15c07; --warn-soft: #fff6e5;
    --bad: #b42318; --bad-soft: #fef1f0;
    --info: #1d4ed8; --info-soft: #eff4ff;
    --radius: 12px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgb(16 24 40 / .04), 0 1px 3px rgb(16 24 40 / .06);
    --shadow-lg: 0 12px 32px -12px rgb(16 24 40 / .18);
    --nav-w: 252px;
    /* Nama lama, supaya view yang memakai var(--line)/var(--ok)/var(--err) tetap benar. */
    --ok: var(--good); --err: var(--bad);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 1.55rem; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; margin: 0 0 1rem; }
h2 { font-size: 1.08rem; font-weight: 620; letter-spacing: -.005em; margin: 1.4rem 0 .7rem; }
h3 { font-size: .95rem; font-weight: 620; }
p { margin: .5rem 0; }
.muted { color: var(--muted); font-size: .88rem; }
:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-soft); }

/* ---------- Kerangka workspace ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line);
    padding: 1rem .8rem 1.5rem; display: flex; flex-direction: column; gap: .2rem;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem 1rem; color: var(--ink); font-weight: 680; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark {
    width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 750;
    background: linear-gradient(135deg, #14a07e, var(--brand-strong)); box-shadow: 0 4px 10px -4px rgb(14 122 97 / .6);
}
.brand small { display: block; font-weight: 500; font-size: .75rem; color: var(--muted); letter-spacing: 0; }
.sidebar h3, nav h3 {
    font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: #94a3b8; margin: 1rem .6rem .3rem;
    display: flex; align-items: center; gap: .45rem;
}
.sidebar h3 svg { width: 14px; height: 14px; }
.sidebar a, nav a {
    display: flex; align-items: center; gap: .55rem; min-height: 38px; padding: .45rem .7rem; border-radius: var(--radius-sm);
    color: var(--ink-2); font-weight: 500; font-size: .92rem;
}
.sidebar a:hover, nav a:hover { background: #f1f5f9; color: var(--ink); text-decoration: none; }
.sidebar a.active, nav a.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 5; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0 1.75rem; background: rgb(245 247 250 / .85); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--line);
}
.topbar .who { display: flex; align-items: center; gap: .75rem; font-size: .9rem; color: var(--ink-2); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: .8rem;
    background: var(--brand-soft); color: var(--brand-strong); border: 1px solid #cdeee2;
}
.topbar form { display: inline; margin: 0; }
.topbar button { margin: 0; }
main { padding: 1.6rem 1.75rem 3rem; max-width: 1280px; width: 100%; }
.nav-toggle { display: none; }
.nav-open { display: none; }
.scrim { display: none; }

@media (max-width: 900px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .topbar > .muted { display: none; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 20; transform: translateX(-102%);
        transition: transform .2s ease; box-shadow: var(--shadow-lg);
    }
    .nav-toggle:checked ~ .shell .sidebar { transform: none; }
    .nav-toggle:checked ~ .shell .scrim { display: block; }
    .scrim { display: none; position: fixed; inset: 0; background: rgb(15 23 42 / .35); z-index: 15; }
    .nav-open { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
    .topbar { padding: 0 1rem; }
    main { padding: 1.1rem 1rem 3rem; }
    .topbar .who .name { display: none; }
}

/* ---------- Kartu, grid, judul halaman ---------- */
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .4rem 1rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: .25rem 0 0; }
.stack { display: grid; gap: 1rem; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Formulir ---------- */
label { display: block; margin: .75rem 0 .3rem; font-weight: 600; font-size: .85rem; color: var(--ink-2); }
input, select, textarea {
    width: 100%; min-height: 40px; padding: .5rem .7rem; font: inherit; font-size: .93rem; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 84px; }
input:hover, select:hover, textarea:hover { border-color: #b3bac6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--brand); transform: scale(1.1); margin-right: .35rem; }
input[readonly] { background: #f8fafc; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 1rem; padding: .8rem 1rem; }
legend { font-weight: 620; padding: 0 .35rem; }
fieldset label { display: inline-flex; gap: .35rem; align-items: center; margin: .25rem 1rem .25rem 0; font-weight: 500; }
.error { color: var(--bad); font-size: .85rem; margin-top: .3rem; }

/* ---------- Tombol ---------- */
button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 40px; margin-top: .9rem; padding: .5rem 1.05rem; border-radius: var(--radius-sm);
    border: 1px solid var(--brand); background: var(--brand); color: #fff;
    font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; text-decoration: none;
    box-shadow: 0 1px 2px rgb(16 24 40 / .08); transition: background .12s, box-shadow .12s, transform .06s;
}
button:hover, .button:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; text-decoration: none; }
button:active { transform: translateY(1px); }
button.secondary, .button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
button.secondary:hover, .button.secondary:hover { background: #f8fafc; border-color: #b3bac6; color: var(--ink); }
button.danger { background: var(--bad); border-color: var(--bad); }
button.ghost, .topbar button { background: transparent; color: var(--ink-2); border-color: var(--line); box-shadow: none; }
button.ghost:hover, .topbar button:hover { background: #eef1f5; color: var(--ink); border-color: var(--line-strong); }
button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Tabel ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
    position: sticky; top: 60px; z-index: 1; background: #f8fafc; color: var(--muted);
    font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
thead th:first-child { border-top-left-radius: 8px; } thead th:last-child { border-top-right-radius: 8px; }
tbody tr:hover td { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.card > table:only-child, .card > table:last-child { margin-bottom: -.2rem; }
.table-wrap { overflow-x: auto; }
/* Di dalam pembungkus gulir-samping, header lengket ikut pembungkus dan menutupi baris; biarkan statis. */
.table-wrap thead th { position: static; }

/* ---------- Status ---------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600; background: #f1f5f9; color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.badge.good, .badge.ok { background: var(--good-soft); color: var(--good); border-color: #c6ecd4; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f5dcb0; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #f6cdc9; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: #d2defc; }
.flash { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.flash::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: .45rem; background: currentColor; }
.flash.ok { background: var(--good-soft); color: #14532d; border-color: #c6ecd4; }
.flash.err { background: var(--bad-soft); color: #7a1a12; border-color: #f6cdc9; }
.flash.warn { background: var(--warn-soft); color: #6b3d05; border-color: #f5dcb0; }

/* ---------- Beranda ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: 1fr; } }
.kpi {
    position: relative; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1rem 1.1rem 1.05rem; color: var(--ink); overflow: hidden;
    transition: box-shadow .15s, border-color .15s, transform .15s;
}
a.kpi:hover { text-decoration: none; color: var(--ink); border-color: #c9d6d1; box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.kpi::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line-strong); }
.kpi.good::after { background: var(--good); } .kpi.warn::after { background: #e39a1b; } .kpi.bad::after { background: var(--bad); }
.kpi .label { font-size: .8rem; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; gap: .5rem; }
.kpi .value { font-size: 1.6rem; font-weight: 680; letter-spacing: -.02em; margin: .35rem 0 .15rem; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: .8rem; color: var(--muted); }
.kpi.warn .hint { color: var(--warn); } .kpi.bad .hint, .kpi.bad .value { color: var(--bad); }
.kpi .go { color: #94a3b8; }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { border-bottom: 1px solid var(--line); }
.todo li:last-child { border-bottom: 0; }
.todo a, .todo .item { display: flex; gap: .8rem; align-items: flex-start; padding: .8rem .25rem; color: var(--ink); }
.todo a:hover { text-decoration: none; background: #f8fafc; border-radius: 8px; }
.todo .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: .4rem; background: var(--line-strong); }
.todo .info .dot { background: var(--info); } .todo .warn .dot { background: #e39a1b; } .todo .bad .dot { background: var(--bad); }
.todo strong { display: block; font-weight: 620; }
.todo span { color: var(--muted); font-size: .86rem; }
.empty { text-align: center; padding: 1.6rem 1rem; color: var(--muted); }
.empty .icon { font-size: 1.6rem; display: block; margin-bottom: .3rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .col { fill: #bfe6d8; } .chart .col.last { fill: var(--brand); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#chart-fill); }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }

/* ---------- Halaman publik & masuk ---------- */
.public-main { max-width: 46rem; margin: 2.5rem auto; padding: 1.75rem 1.6rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.auth-main { max-width: 26rem; margin: 5rem auto; padding: 2rem 1.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); }
.auth-main .brand { padding: 0 0 1.2rem; }
@media (max-width: 48rem) { .public-main, .auth-main { margin: 0; border-radius: 0; border: 0; min-height: 100vh; } }
ul.list { list-style: none; padding: 0; }
ul.list li a { display: flex; justify-content: space-between; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: .5rem; color: var(--ink); font-weight: 550; }
ul.list li a:hover { border-color: var(--brand); background: var(--brand-soft); text-decoration: none; }
.bar { height: .5rem; background: var(--line); border-radius: 999px; overflow: hidden; } .bar > span { display: block; height: 100%; background: var(--brand); }
.route { padding: 1rem 1.1rem; border-radius: var(--radius); margin: 1rem 0; border: 1px solid; }
.route.green { background: var(--good-soft); border-color: #c6ecd4; } .route.yellow { background: var(--warn-soft); border-color: #f5dcb0; } .route.red { background: var(--bad-soft); border-color: #f6cdc9; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.unknown { color: var(--muted); }

/* ---------- Daftar (Fase 23) ---------- */
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .9rem; }
.toolbar input[type=search] { flex: 1 1 260px; max-width: 420px; }
.toolbar select { width: auto; flex: 0 0 auto; }
.toolbar button { margin-top: 0; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: .9rem; }
.pager .button { margin-top: 0; min-height: 34px; padding: .3rem .8rem; font-size: .85rem; }
.pager .disabled { opacity: .45; pointer-events: none; }
details.create { padding: 0; }
details.create > summary { list-style: none; cursor: pointer; padding: 1rem 1.25rem; font-weight: 620; display: flex; align-items: center; gap: .6rem; color: var(--brand-strong); }
details.create > summary::-webkit-details-marker { display: none; }
details.create > summary::before { content: "+"; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--brand-soft); font-weight: 700; }
details.create[open] > summary::before { content: "−"; }
details.create > .body { padding: .2rem 1.25rem 1.2rem; border-top: 1px solid var(--line); }
td.actions { text-align: right; white-space: nowrap; }

/* ---------- Pencarian global ---------- */
.global-search { flex: 1; max-width: 460px; position: relative; margin: 0 1rem; }
.global-search input { min-height: 38px; padding-left: 2.2rem; }
.global-search svg { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.global-search kbd { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); font: 600 .72rem/1 Inter, sans-serif; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 5px; padding: .2rem .4rem; background: #f8fafc; }
@media (max-width: 900px) { .global-search { margin: 0 .5rem; } .global-search kbd { display: none; } }
.results ul { list-style: none; margin: 0; padding: 0; }
.results li a { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem .4rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.results li:last-child a { border-bottom: 0; }
.results li strong { white-space: nowrap; }
.results li .muted { text-align: right; }
.results li a:hover { background: #f8fafc; text-decoration: none; }

/* ---------- Penyiapan & impor (Fase 24) ---------- */
.import-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.import-grid .card { margin-bottom: 0; }
.import-grid input[type=file] { padding: .45rem; background: #f8fafc; }
.steps-inline { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0 0 1rem; }
.steps-inline li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .85rem; font-size: .86rem; color: var(--ink-2); }
.checklist { list-style: none; margin: .5rem 0 0; padding: 0; }
.checklist li { display: flex; gap: .8rem; align-items: flex-start; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; border: 2px solid var(--line-strong); color: var(--muted); }
.checklist li.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.checklist li.done strong { color: var(--muted); text-decoration: line-through; text-decoration-color: #cbd5e1; }
.checklist li .go { margin-left: auto; white-space: nowrap; font-size: .88rem; }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: .6rem 0 .2rem; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #14a07e, var(--brand)); border-radius: 999px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
    .sidebar, .topbar, .nav-open, button, .toolbar, .pager, details.create { display: none !important; }
    .shell { display: block; } main { padding: 0; }
    .card, .kpi { box-shadow: none; break-inside: avoid; }
}
