/*
 * SIP (System Integration Project): keluarga visual admin_mycomet (sidebar putih, Segoe UI), aksen merah SBP
 * karena domainnya sbp.net.id. Diambil dari DNS Manager supaya semua alat internal terlihat satu keluarga.
 * Alasan keputusan:
 * - Merah logo #ed2124 hanya 4:1 di bawah teks putih, jadi tombol memakai #c8161d (5.6:1).
 *   Aksen hanya untuk aksi utama, menu aktif, dan batang timeline.
 * - Font sistem Segoe UI: sama dengan admin_mycomet, tanpa unduhan webfont.
 * - Monospace hanya untuk kode proyek dan username (dibaca per karakter).
 * - Warna status hanya pada badge status proyek nyata (draf, menunggu, revisi, provisioning).
 * - Tanpa bayangan besar: panel dipisah garis tipis, satu-satunya elevasi ada di tombol utama.
 */

:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #f2f4f7;
    --border: #e3e7ec;
    --text: #1f2a3a;
    --muted: #5f6b7d;
    --accent: #c8161d;
    --accent-hover: #a51218;
    --accent-text: #b3141a;
    --accent-soft: #fdecec;
    --focus: #ed2124;
    --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;

    --st-pending-bg: #fff3dc; --st-pending: #7a4a00;
    --st-applied-bg: #e3f5ec; --st-applied: #155c39;
    --st-failed-bg: #fde8e8; --st-failed: #a61b1b;
    --st-applying-bg: #e6effa; --st-applying: #1b5596;
    --st-closed-bg: #eceff3; --st-closed: #465264;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #12161c;
    --surface: #1a2028;
    --surface-2: #222a34;
    --border: #2d3640;
    --text: #e6e9ee;
    --muted: #a3adbb;
    --accent: #c8161d;
    --accent-hover: #a51218;
    --accent-text: #ff8a8a;
    --accent-soft: #3a1416;
    --focus: #ff5a5f;
    --st-pending-bg: #3b2c10; --st-pending: #f5c879;
    --st-applied-bg: #13372a; --st-applied: #7fdcae;
    --st-failed-bg: #401b1b; --st-failed: #ffa3a3;
    --st-applying-bg: #172e4a; --st-applying: #9cc7f5;
    --st-closed-bg: #262d36; --st-closed: #b9c2ce;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 14px; line-height: 1.5; background: var(--bg); color: var(--text); }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-text); }
code, .mono { font-family: var(--mono); font-size: 13px; }
a, button, summary, select, label[for], input[type="checkbox"], input[type="radio"], [role="button"] { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--surface); color: var(--text); padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); }
.skip-link:focus { top: 12px; }
.icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
/* Brand block as on myadmin and Watch: logo, then a small spaced caption with the app name. */
.brand { display: block; padding: 24px 24px 16px; text-decoration: none; color: var(--text); }
.brand img { display: block; height: 36px; width: auto; }
.brand > span { display: block; margin-top: 12px; font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.brand strong { color: var(--accent-text); font-weight: 600; }
.logo-dark { display: none !important; }
[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }
.menu-toggle { display: none; }
.sidebar-menu { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidebar nav { padding: 0 12px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 12px; margin: 2px 0; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 14px; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 11px; background: var(--st-pending-bg); color: var(--st-pending); font-size: 12px; font-weight: 600; text-align: center; }
.account { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); }
.account-initial { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-weight: 600; text-transform: uppercase; flex-shrink: 0; }
.account-name { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role { display: block; font-size: 12px; color: var(--muted); }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { background: var(--border); }

.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 36px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 22px; font-weight: 650; letter-spacing: -.4px; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.crumb a { color: var(--muted); display: inline-block; padding: 14px 0; margin: -14px 0; }
.crumb a:hover { color: var(--accent-text); }
.theme-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; }
.theme-toggle:hover { color: var(--text); background: var(--surface-2); }
[data-theme="dark"] [data-icon-light], :root:not([data-theme="dark"]) [data-icon-dark] { display: none; }
.content { padding: 28px 36px 40px; max-width: 1280px; }

/* ---------- elemen umum ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgb(200 22 29 / .18); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); box-shadow: none; }
.btn-primary:disabled { opacity: .55; box-shadow: none; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-secondary:active { background: var(--border); }
.btn-danger { background: var(--surface); border-color: var(--st-failed); color: var(--st-failed); }
.btn-danger:hover { background: var(--st-failed-bg); }
.btn-danger:active { background: var(--st-failed-bg); transform: translateY(1px); }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; border: 1px solid; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--st-applied-bg); color: var(--st-applied); border-color: color-mix(in srgb, var(--st-applied) 25%, transparent); }
.alert-error { background: var(--st-failed-bg); color: var(--st-failed); border-color: color-mix(in srgb, var(--st-failed) 25%, transparent); }
.alert-warning { background: var(--st-pending-bg); color: var(--st-pending); border-color: color-mix(in srgb, var(--st-pending) 25%, transparent); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-submitted { background: var(--st-pending-bg); color: var(--st-pending); }
.st-handed_over { background: var(--st-applied-bg); color: var(--st-applied); }
.st-revision { background: var(--st-failed-bg); color: var(--st-failed); }
.st-draft { background: var(--st-closed-bg); color: var(--st-closed); }
.type { display: inline-block; min-width: 52px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; font-family: var(--mono); font-size: 12px; text-align: center; color: var(--text); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.panel-pad { padding: 22px 24px; }
.panel h2 { font-size: 16px; font-weight: 650; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack > * + * { margin-top: 16px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 10px; }
.tab { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
.tab span { font-weight: 500; color: var(--muted); }
.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="date"], input[type="file"], select, textarea {
    min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface); color: var(--text); font: inherit; font-size: 14px; max-width: 100%;
}
textarea { min-height: 88px; resize: vertical; width: 100%; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--border)); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--st-failed); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; color: var(--muted); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- tabel ---------- */
/* relative: teks sr-only (absolute) di dalam tabel tidak boleh lolos dari area gulir dan melebarkan halaman. */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.row-link { color: var(--text); text-decoration: none; font-weight: 600; }
.row-link:hover { color: var(--accent-text); text-decoration: underline; }
.value { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
/* Aksi per baris: teks merah, bukan tombol penuh, supaya tabel ratusan record tidak penuh blok merah. */
.row-action { border: 0; background: none; font-family: inherit; display: inline-flex; align-items: center; min-height: 44px; margin: -12px 0; padding: 0 4px; color: var(--st-failed); font-size: 13px; font-weight: 600; text-decoration: none; }
.row-action:hover { text-decoration: underline; }
.row-action:active { opacity: .7; }

.empty { padding: 48px 24px; text-align: center; }
.empty h2 { font-size: 16px; margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 18px; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.pagination a, .pagination span.page { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; }
.pagination a:hover { background: var(--surface-2); }
.pagination [aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.pagination .disabled { color: var(--muted); opacity: .5; }

/* ---------- daftar proyek ---------- */
.todo { margin-bottom: 20px; }
.todo h2 { display: flex; align-items: center; gap: 8px; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.todo-list li:last-child { border-bottom: 0; }
.todo-list .row-link { display: inline-flex; align-items: center; min-height: 44px; }
.row-edit { display: inline-flex; align-items: center; min-height: 44px; margin: -12px 0; }

/* ---------- detail proyek ---------- */
.project-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 20px; padding: 18px 22px; }
.project-customer { font-size: 16px; font-weight: 600; margin-top: 2px; }
.project-head-side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.file-name { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-left: 6px; overflow-wrap: anywhere; }
.file-name .icon { width: 16px; height: 16px; }
.add-form { padding: 20px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)); border-radius: 0 0 12px 12px; }
.add-form h3 { font-size: 14px; font-weight: 650; margin-bottom: 12px; }
.add-form > .btn { margin-top: 16px; }
.add-form input[type="text"], .add-form input[type="file"], .add-form input[type="number"], .add-form input[type="date"] { width: 100%; }
.row-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 120px; gap: 12px; margin-bottom: 18px; }
.row-fields .field + .field { margin-top: 0; }
.row-fields:has(.field-date) { grid-template-columns: minmax(0, 1fr) 170px 170px; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.narrow { max-width: 640px; }
.checklist { list-style: none; margin: 0 0 4px; padding: 0; font-size: 13px; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.check-mark { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.checklist .ok .check-mark { background: var(--st-applied-bg); color: var(--st-applied); }
.checklist .missing .check-mark { background: var(--st-pending-bg); color: var(--st-pending); }
.checklist .muted { margin-left: auto; }

/* Timeline bergaya Gantt: satu baris per tahap, batang = rentang tanggal relatif ke seluruh proyek. */
.gantt { padding: 16px 20px 8px; border-bottom: 1px solid var(--border); }
.gantt-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 34px; }
.gantt-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-track { position: relative; height: 14px; border-radius: 7px; background: var(--surface-2); }
/* --accent-text, bukan --accent: di tema gelap merah tombol hanya ~2.5:1 terhadap jalur, merah teks > 3:1. */
.gantt-bar { position: absolute; top: 0; bottom: 0; border-radius: 7px; background: var(--accent-text); }
.gantt-today { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--text); }
.gantt-legend { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.gantt-today-key { display: inline-block; width: 2px; height: 14px; background: var(--text); }

/* ---------- detail (shared) ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.facts { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.note-box { white-space: pre-line; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 18px; bottom: 2px; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.done::before { background: var(--st-applied); }
.timeline li.bad::before { background: var(--st-failed); }
.timeline strong { display: block; font-size: 13px; }
.decision textarea { margin: 6px 0 12px; }
.decision .btn { width: 100%; }
.decision + .decision { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.error-text { font-family: var(--mono); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--st-failed); }

/* ---------- form ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.field { display: block; }
.field + .field { margin-top: 18px; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.field .field-error { font-size: 13px; color: var(--st-failed); margin-top: 6px; }
.field select, .field input[type="text"], .field input[type="password"] { width: 100%; }
.types { display: flex; flex-wrap: wrap; gap: 8px; }
.types label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; }
.types label:hover { background: var(--surface-2); }
.types label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.types input { accent-color: var(--accent); width: 16px; height: 16px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.side-note h3 { font-size: 14px; font-weight: 650; margin-bottom: 8px; }
.side-note p, .side-note li { font-size: 13px; color: var(--muted); }
.side-note ol { margin: 0; padding-left: 18px; }
.side-note li + li { margin-top: 6px; }

/* ---------- login ---------- */
/* Same login card as myadmin and Watch: faint brand tint behind one centered card. */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(ellipse at top left, #fde3e3, transparent 60%), var(--bg); }
[data-theme="dark"] .login-page { background: radial-gradient(ellipse at top left, #2a1214, transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 430px; padding: 38px; border-radius: 20px; box-shadow: 0 24px 80px rgb(94 22 22 / .06); }
.login-card .login-logo { display: block; height: 48px; width: auto; margin: 0 auto 16px; }
.login-card h1 { font-size: 24px; font-weight: 650; letter-spacing: -.3px; text-align: center; }
.login-card .lead { color: var(--muted); margin: 6px 0 24px; font-size: 14px; text-align: center; }
@media (max-width: 480px) { .login-card { padding: 26px 20px; } }
.login-card input { width: 100%; }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row img { border-radius: 8px; border: 1px solid var(--border); width: 180px; height: 56px; }
.login-card .btn { width: 100%; margin-top: 22px; }

/* ---------- responsif ---------- */
@media (max-width: 1080px) {
    .detail-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
    .shell { display: block; }
    .sidebar { position: sticky; top: 0; z-index: 20; width: auto; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; border-right: 0; border-bottom: 1px solid var(--border); }
    .brand { padding: 12px 16px; }
    .brand img { height: 28px; }
    .brand > span { display: none; }
    .menu-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-right: 12px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
    .sidebar-menu { display: none; width: 100%; border-top: 1px solid var(--border); padding-top: 8px; }
    .sidebar-menu.is-open { display: flex; }
    .topbar { padding: 16px; flex-wrap: wrap; }
    .topbar h1 { font-size: 19px; }
    .content { padding: 20px 16px 32px; }
    .panel-pad { padding: 18px 16px; }
    .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .facts dd { margin-bottom: 10px; }
    .row-fields, .row-fields:has(.field-date) { grid-template-columns: minmax(0, 1fr); }
    .gantt { padding: 14px 16px 8px; }
    .gantt-row { grid-template-columns: 96px minmax(0, 1fr); }
    .file-list li, .todo-list li { padding: 12px 16px; }
    .add-form { padding: 16px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search input[type="search"] { flex: 1; min-width: 0; }
    th, td { padding: 10px 12px; }
}

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