/* WMS — tema Debian: datar, bersih, aksen merah Debian */
:root {
  --red: #D70A53; --red-dark: #A80030; --red-soft: #FBE7EE;
  --ink: #232329; --ink-2: #2E2E36; --side-text: #C9CBD1;
  --bg: #F3F3F5; --surface: #FFFFFF; --border: #DADCE0; --border-2: #ECEDEF;
  --text: #212529; --text-2: #6B6F76;
  --ok: #2E7D32; --ok-bg: #E7F4E8; --warn: #A15C00; --warn-bg: #FFF1D6; --bad: #C62828; --bad-bg: #FDE8E8;
  --r: 6px; --r-lg: 8px;
  --sh: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.05);
  --sh-pop: 0 8px 24px rgba(0,0,0,.14);
  --font: system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'DejaVu Sans', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --sidebar-w: 260px; --rail-w: 72px;
  --bs-body-font-family: var(--font); --bs-body-color: var(--text); --bs-body-bg: var(--bg);
}
* { -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); margin: 0; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0; }
small, .small { font-size: 12.5px; }
.muted { color: var(--text-2); }
a { color: var(--red); text-decoration: none; } a:hover { color: var(--red-dark); text-decoration: underline; }
.link-soft { color: var(--red); font-weight: 600; font-size: 13px; cursor: pointer; }
:focus-visible { outline: 3px solid rgba(215,10,83,.35); outline-offset: 2px; }
[data-lucide] { width: 18px; height: 18px; stroke-width: 2; flex: none; }

/* Permukaan */
.clay-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh); padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }

/* Tombol */
.btn-clay { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none;
  font: 600 14px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border);
  padding: 8px 16px; min-height: 38px; border-radius: var(--r); transition: background .15s, border-color .15s; }
.btn-clay:hover { background: #F7F7F9; border-color: #C3C6CC; color: var(--text); text-decoration: none; }
.btn-clay.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-clay.primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn-clay.btn-sm { padding: 4px 12px; min-height: 32px; font-size: 13px; }
.btn-clay:disabled { opacity: .6; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid transparent; border-radius: var(--r);
  cursor: pointer; background: transparent; color: var(--text-2); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--border-2); color: var(--text); }

/* Formulir */
.clay-input, .form-select.clay-input { background: #fff; border: 1px solid var(--border); border-radius: var(--r); padding: 8px 12px;
  min-height: 38px; font-size: 14px; color: var(--text); box-shadow: none; }
.clay-input:focus { background: #fff; border-color: var(--red); box-shadow: 0 0 0 3px rgba(215,10,83,.15); color: var(--text); }
.clay-input.is-invalid { border-color: var(--bad); background-image: none; }
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.invalid-feedback { color: var(--bad); font-size: 12.5px; }
.form-narrow { max-width: 620px; }
.input-reveal { position: relative; } .input-reveal .clay-input { padding-right: 44px; }
.reveal-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--text-2); padding: 8px; cursor: pointer; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; } .filter-bar .clay-input { flex: 1 1 170px; min-width: 0; }
.perm-item { display: flex; gap: 12px; align-items: flex-start; padding: 9px 2px; cursor: pointer; border-bottom: 1px solid var(--border-2); }
.perm-item:last-child { border-bottom: 0; } .perm-item small { display: block; color: var(--text-2); }
.perm-item input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--red); flex: none; }

/* Kerangka */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); position: fixed; inset: 0 auto 0 0; z-index: 1040; display: flex; flex-direction: column;
  background: var(--ink); color: var(--side-text); padding: 0 12px 12px; overflow-y: auto; transition: transform .22s, width .22s; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; color: #fff; padding: 16px 8px 18px; margin-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,.08); text-decoration: none; }
.sidebar-brand:hover { color: #fff; text-decoration: none; }
.sidebar-brand strong { display: block; font-size: 16px; line-height: 1.1; }
.sidebar-brand small { color: #9A9DA6; display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--red); }
.brand-mark.sm { width: 38px; height: 38px; border-radius: 9px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding-top: 8px; }
.nav-group { margin: 16px 10px 6px; font-size: 12px; font-weight: 600; color: #8C8F98; }
.nav-link-clay { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r); color: var(--side-text);
  font-weight: 500; border-left: 3px solid transparent; text-decoration: none; transition: background .15s, color .15s; }
.nav-link-clay:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link-clay.active { background: rgba(215,10,83,.2); color: #fff; border-left-color: var(--red); font-weight: 600; }
.sidebar-foot { display: flex; justify-content: space-between; align-items: center; padding: 14px 10px 0; font-size: 12px; color: #8C8F98; border-top: 1px solid rgba(255,255,255,.08); margin-top: 10px; }
.conn { display: inline-flex; align-items: center; gap: 7px; } .conn .dot { width: 9px; height: 9px; border-radius: 50%; background: #4CAF50; }
.conn.offline .dot { background: #EF5350; }
.sidebar-backdrop { display: none; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; transition: margin .22s; }
.topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: 12px; padding: 10px 28px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px)); background: var(--surface); border-top: 3px solid var(--red); border-bottom: 1px solid var(--border); min-height: 56px; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; min-width: 0; } .crumbs [data-lucide] { width: 14px; height: 14px; }
.crumbs span { color: var(--text); font-weight: 600; } .crumbs a { color: var(--text-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer; }
.user-chip:hover { background: #F7F7F9; }
.user-chip strong { display: block; font-size: 13px; line-height: 1.2; } .user-chip small { color: var(--text-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; background: var(--red); }
.clay-menu { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-pop); padding: 6px; min-width: 200px; }
.clay-menu .dropdown-item { display: flex; align-items: center; gap: 10px; border-radius: var(--r); padding: 8px 12px; color: var(--text); width: 100%; }
.clay-menu .dropdown-item:hover { background: var(--red-soft); color: var(--red-dark); }
.content { padding: 20px 28px 40px; padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); max-width: 1600px; width: 100%; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin: 0 0 20px; flex-wrap: wrap; }

/* Tampilan data */
.kpi { display: flex; align-items: center; gap: 14px; padding: 16px; border-left: 4px solid var(--red); }
.kpi-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); }
.tone-blue { color: #1565C0; } .tone-green { color: var(--ok); } .tone-amber { color: var(--warn); } .tone-red { color: var(--bad); }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.table-wrap { overflow-x: auto; }
.table-clay { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-clay th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12.5px; padding: 10px 12px; background: #FAFAFB; border-bottom: 2px solid var(--border); white-space: nowrap; }
.table-clay td { padding: 11px 12px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
.table-clay tbody tr:hover td { background: #FCF5F8; }
.actions { white-space: nowrap; } .actions .icon-btn { width: 34px; height: 34px; }
.badge-clay { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #ECEDEF; color: #43474E; }
.badge-clay.ok { background: var(--ok-bg); color: var(--ok); } .badge-clay.bad { background: var(--bad-bg); color: var(--bad); }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-2); flex-wrap: wrap; }
.activity li:last-child { border-bottom: 0; } .activity time { margin-left: auto; white-space: nowrap; font-size: 12.5px; }
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); } .empty [data-lucide] { width: 34px; height: 34px; margin-bottom: 8px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; flex-wrap: wrap; gap: 10px; }
.matrix .group-row td { background: var(--red-soft); color: var(--red-dark); font-weight: 600; padding: 7px 12px; }
.matrix .yes { color: var(--ok); width: 17px; } .matrix .no { color: #B3B6BC; }
.diff { font-size: 12px; background: #FAFAFB; border: 1px solid var(--border); border-radius: var(--r); padding: 10px; max-width: 420px; max-height: 240px; overflow: auto; margin: 8px 0 0; }

/* Toast & pembaruan */
.toast-stack { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 28px)); }
.toast-clay { background: var(--surface); border: 1px solid var(--border); border-left: 5px solid #1565C0; border-radius: var(--r); padding: 12px 14px; box-shadow: var(--sh-pop); animation: toast-in .2s ease-out; }
.toast-clay.success { border-left-color: var(--ok); } .toast-clay.danger { border-left-color: var(--bad); } .toast-clay.warning { border-left-color: #E69500; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.update-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 2000; display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: #fff; padding: 10px 12px 10px 18px; border-radius: var(--r-lg); box-shadow: var(--sh-pop); width: max-content; max-width: calc(100vw - 24px); }

/* Halaman masuk */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.auth-wrap { display: grid; grid-template-columns: 1fr 440px; max-width: 940px; width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--sh-pop); overflow: hidden; }
.auth-aside { background: linear-gradient(160deg, var(--red) 0%, var(--red-dark) 100%); color: #fff; padding: 48px 40px; display: flex; flex-direction: column; justify-content: center; }
.auth-aside h1 { font-size: 32px; line-height: 1.2; margin: 24px 0 12px; font-weight: 700; }
.auth-aside p { color: rgba(255,255,255,.85); font-size: 15px; max-width: 340px; margin: 0; }
.auth-aside .brand-mark { background: rgba(255,255,255,.18); width: 64px; height: 64px; } .auth-aside .brand-mark [data-lucide] { width: 30px; height: 30px; }
.auth-panel { padding: 40px; display: flex; align-items: center; }
.auth-card { padding: 0; border: 0; box-shadow: none; width: 100%; } .auth-card h2 { font-size: 22px; margin-bottom: 4px; } .auth-card .muted { margin-bottom: 22px; }
.error-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); font-family: var(--font); color: var(--text); }
.error-card { text-align: center; max-width: 420px; padding: 36px; border-top: 4px solid var(--red); } .error-code { font-size: 60px; font-weight: 700; color: var(--red); line-height: 1; margin-bottom: 8px; }
.error-card p { color: var(--text-2); margin-bottom: 22px; }

/* ===== Responsif ===== */
/* Tablet: sidebar menjadi rel ikon */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .sidebar { width: var(--rail-w); padding: 0 8px 12px; }
  .main { margin-left: var(--rail-w); }
  .sidebar-brand { justify-content: center; padding: 14px 0; }
  .sidebar-brand > span:last-child, .nav-link-clay span, .nav-group, .sidebar-foot .ver { display: none; }
  .nav-link-clay { justify-content: center; padding: 12px 0; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-link-clay.active { border-bottom-color: var(--red); }
  .sidebar-foot { justify-content: center; } .conn span { display: none; }
  .topbar, .content { padding-left: 20px; padding-right: 20px; }
}
/* Mobile: menu geser */
@media (max-width: 767.98px) {
  .sidebar { transform: translateX(-105%); width: min(280px, 86vw); box-shadow: var(--sh-pop); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035; }
  .main { margin-left: 0; }
  .topbar { padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .content { padding: 16px 12px 32px; }
  h1 { font-size: 21px; }
  .clay-card { padding: 16px; }
  .btn-clay, .clay-input, .icon-btn { min-height: 44px; }
  .btn-clay.btn-sm { min-height: 40px; }
  .page-header { flex-direction: column; align-items: stretch; margin-bottom: 14px; } .page-header .btn-clay { width: 100%; }
  .filter-bar > * { flex: 1 1 100% !important; }
  .kpi { padding: 14px; } .kpi-value { font-size: 22px; }
  .auth-wrap { grid-template-columns: 1fr; max-width: 440px; }
  .auth-aside { padding: 24px; } .auth-aside h1 { font-size: 22px; margin: 14px 0 6px; } .auth-aside p { font-size: 14px; }
  .auth-aside .brand-mark { width: 44px; height: 44px; } .auth-aside .brand-mark [data-lucide] { width: 22px; height: 22px; }
  .auth-panel { padding: 24px; }
  .form-narrow { max-width: none; }
  .update-bar { left: 12px; right: 12px; transform: none; width: auto; justify-content: space-between; }
  /* Tabel menjadi kartu (label kolom diisi otomatis oleh app.js) */
  .table-clay:not(.matrix) thead { display: none; }
  .table-clay:not(.matrix) tr { display: block; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 6px 12px; margin-bottom: 10px; background: #fff; }
  .table-clay:not(.matrix) td { display: flex; justify-content: space-between; gap: 16px; align-items: center; text-align: right; padding: 8px 0; border-bottom: 1px solid var(--border-2); }
  .table-clay:not(.matrix) td:last-child { border-bottom: 0; }
  .table-clay:not(.matrix) td::before { content: attr(data-label); font-weight: 600; color: var(--text-2); text-align: left; flex: none; }
  .table-clay:not(.matrix) td[data-label=""]::before { display: none; }
  .table-clay:not(.matrix) td.text-end { justify-content: flex-end; }
  .table-clay:not(.matrix) tbody tr:hover td { background: transparent; }
  .diff { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
