:root {
  --brand-900: #0b3b3a;
  --brand-700: #0f5c58;
  --brand-500: #1b8a82;
  --brand-100: #d7ebe8;
  --brand-50: #eaf4f2;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #17211f;
  --muted: #5b6966;
  --line: #d9e0de;
  --ok: #1e7b45; --ok-bg: #e3f3e8;
  --warn: #8a5a00; --warn-bg: #fff1cc;
  --bad: #b3261e; --bad-bg: #fce8e6;
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --header-h: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 14px/1.55 var(--font); color: var(--text); background: var(--bg); }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
a { color: var(--brand-700); }
code, .mono { font-family: var(--mono); font-size: 13px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- tombol & form ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--brand-700); background: var(--brand-700); color: #fff; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--brand-900); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand-700); }
.btn.ghost:hover { background: var(--brand-50); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 500; font-size: 13px; }
.field .help { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--bad); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-500); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
.checks { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.checks label { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- header & layout ---------- */
.app-header {
  position: fixed; inset: 0 0 auto 0; z-index: 30; height: calc(var(--header-h) + var(--safe-top)); padding-top: var(--safe-top);
  display: flex; align-items: center; gap: 14px; padding-inline: 16px; background: var(--brand-900); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img.logo { width: 34px; height: 34px; border-radius: 8px; flex: none; }
.brand .titles { min-width: 0; }
.brand .t1 { font-weight: 600; font-size: 15px; line-height: 1.2; white-space: nowrap; }
.brand .t2 { font-size: 11px; color: #a9cfca; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-company { margin-left: 8px; padding-left: 14px; border-left: 1px solid rgba(255,255,255,.25); min-width: 0; }
.hdr-company .cn { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.hdr-company .cd { font-size: 11px; color: #a9cfca; }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { background: transparent; border: 1px solid rgba(255,255,255,.28); color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.burger { display: none; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.12); white-space: nowrap; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: #aab; }
.conn.on i { background: #4fd17f; }
.conn.off i, .conn.bad i { background: #ff6b5e; }
.conn.warn i { background: #ffc94d; }

.shell { display: flex; padding-top: calc(var(--header-h) + var(--safe-top)); min-height: 100vh; }
.sidebar { width: 236px; flex: none; background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: calc(var(--header-h) + var(--safe-top)); align-self: flex-start; height: calc(100vh - var(--header-h) - var(--safe-top)); overflow: auto; }
.nav-group { margin-bottom: 14px; }
.nav-title { font-size: 12px; color: var(--muted); padding: 4px 10px; font-weight: 500; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--brand-50); }
.nav a.active { background: var(--brand-100); color: var(--brand-900); font-weight: 600; }
.nav .soon { color: var(--muted); cursor: default; }
.nav .soon:hover { background: transparent; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.main { flex: 1; min-width: 0; padding: 20px 24px 48px; max-width: 1180px; }
.alertbar { padding: 10px 16px; font-size: 13px; background: var(--bad-bg); color: var(--bad); border-bottom: 1px solid #f0c4bf; }
.alertbar.warn { background: var(--warn-bg); color: var(--warn); border-color: #ecd699; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 2px 0 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.panel > h2 { margin-bottom: 10px; }

@media (max-width: 860px) {
  .burger { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: calc(var(--header-h) + var(--safe-top)); z-index: 25; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 4px 0 18px rgba(0,0,0,.12); }
  body.nav-open .sidebar { transform: none; }
  .main { padding: 16px 14px 40px; }
  .hdr-company, .brand .t2, .conn span { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- tabel ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar select { width: auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--brand-50); font-weight: 600; font-size: 13px; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: var(--brand-100); }
th .arr { color: var(--brand-700); margin-left: 4px; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.empty { text-align: center; color: var(--muted); padding: 28px; }
.ic { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px; cursor: pointer; color: var(--brand-700); display: inline-flex; }
.ic:hover { background: var(--brand-50); border-color: var(--line); }
.ic.red { color: var(--bad); }
.ic svg { width: 17px; height: 17px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted); }
.pager .ctrl { display: flex; align-items: center; gap: 8px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cb; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: #ecd699; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: #f0c4bf; }

/* ---------- dialog & toast ---------- */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--text); }
dialog::backdrop { background: rgba(10,25,24,.5); }
.dlg-head { padding: 16px 20px 0; }
.dlg-body { padding: 14px 20px; max-height: 70vh; overflow: auto; }
.dlg-foot { padding: 12px 20px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.form-error { background: var(--bad-bg); color: var(--bad); padding: 8px 10px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.secret { font-family: var(--mono); font-size: 16px; padding: 10px 12px; background: var(--warn-bg); border: 1px dashed #d9b95a; border-radius: 6px; user-select: all; word-break: break-all; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--brand-900); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 340px; }
.toast.err { background: var(--bad); }

/* ---------- login & kunci layar ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 5fr) 6fr; }
.auth-brand { background: var(--brand-900); color: #fff; padding: 48px 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.auth-brand .logo { width: 64px; height: 64px; border-radius: 14px; background: #fff; object-fit: contain; }
.auth-brand h1 { font-size: 26px; margin: 18px 0 6px; }
.auth-brand .company { font-size: 16px; color: #cfe6e2; }
.auth-brand .credit { font-size: 12px; color: #a9cfca; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: min(380px, 100%); }
.auth-card h2 { font-size: 20px; margin-bottom: 4px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 24px 20px; flex-direction: row; align-items: center; justify-content: flex-start; }
  .auth-brand h1 { font-size: 18px; margin: 0; }
  .auth-brand .credit { display: none; }
}
.lock { position: fixed; inset: 0; z-index: 90; background: var(--brand-900); display: flex; align-items: center; justify-content: center; padding: 20px; }
.lock .auth-card { background: var(--surface); padding: 24px; border-radius: 12px; }

/* ---------- dashboard ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-weight: 600; font-size: 16px; margin-top: 2px; }
.logo-preview { max-width: 120px; max-height: 120px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; display: block; margin-bottom: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.tabs button.active { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }

/* ---------- tambahan layout ---------- */
.content { flex: 1; min-width: 0; }
.icon-btn svg { width: 16px; height: 16px; }
.who { padding: 6px 10px 12px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
@media (max-width: 520px) { .icon-btn span { display: none; } }
