:root {
  --navy: #0f2547;
  --navy-2: #1a3566;
  --navy-3: #243f73;
  --blue: #2f5fb3;
  --ink: #1b2740;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --green: #15803d;
  --red: #b91c1c;
  --radius: 12px;
  --side: 248px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0; line-height: 1.25; }
a { color: var(--blue); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.icon { flex: none; display: block; }
:focus-visible { outline: 3px solid #93b4ea; outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--navy); color: #cfd9ee;
  display: flex; flex-direction: column; padding: 20px 14px; z-index: 30; transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: #fff; font-weight: 650; font-size: 17px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--navy-3); color: #fff;
  display: grid; place-items: center; flex: none;
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px;
  color: #cfd9ee; text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--navy-2); color: #fff; }
.nav-link.is-active { background: var(--navy-3); color: #fff; }
.nav-button { width: 100%; background: none; border: 0; font: inherit; font-weight: 500; cursor: pointer; text-align: left; }
.sidebar-foot { border-top: 1px solid var(--navy-3); padding-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.who { display: flex; align-items: center; gap: 10px; padding: 4px 8px 8px; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #dbe6fa; color: var(--navy); display: grid; place-items: center; font-weight: 700; flex: none; }
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-text strong { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { color: #9fb0d1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; margin-left: var(--side); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 32px; background: #fff; border-bottom: 1px solid var(--line); }
.page-title { font-size: 20px; font-weight: 650; }
.menu-btn, .backdrop { display: none; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 9px; width: 40px; height: 40px; place-items: center; color: var(--ink); cursor: pointer; }
.content { padding: 28px 32px 56px; max-width: none; }

/* ---------- komponen ---------- */
.alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 18px; font-size: 14.5px; border: 1px solid; }
.alert-success { background: #dcfce7; border-color: #bbf7d0; color: #14532d; }
.alert-error { background: #fee2e2; border-color: #fecaca; color: #7f1d1d; }
.alert-warning { background: #fef3c7; border-color: #fde68a; color: #78350f; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat-value { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.tone-navy { background: #dbe3f3; color: var(--navy); }
.tone-green { background: #dcfce7; color: var(--green); }
.tone-grey { background: #e8edf3; color: #475569; }
.tone-red { background: #fee2e2; color: var(--red); }
.tone-blue { background: #dbeafe; color: #1d4ed8; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.grid-2 .card { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; font-weight: 650; }
.link { font-size: 14px; }
.empty { color: var(--muted); margin: 8px 0 0; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafc; }
.cell-detail { max-width: 280px; overflow-wrap: anywhere; color: var(--muted); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed li > div { display: flex; flex-direction: column; min-width: 0; }
.feed time { white-space: nowrap; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 650; }
.badge-green { background: #dcfce7; color: var(--green); }
.badge-red { background: #fee2e2; color: var(--red); }
.badge-grey { background: #e8edf3; color: #475569; }

.code { background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; padding: 12px; margin: 10px 0; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; text-align: right; overflow-wrap: anywhere; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 9px; font: inherit; color: var(--ink); background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--navy-2); outline-offset: 1px; border-color: var(--navy-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px;
  border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: #fff; border-color: #cbd5e1; color: var(--ink); padding: 7px 12px; font-size: 14px; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-danger { background: #b91c1c; color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.page { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 14px; }
a.page:hover { background: #f1f5f9; }
.page.is-current { background: var(--navy); border-color: var(--navy); color: #fff; }
.page.is-disabled { color: #aab4c3; }
.page.is-gap { border-color: transparent; }

.checklist { list-style: none; margin: 0 0 14px; padding: 0; }
.checklist li { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }

/* ---------- halaman tanpa sidebar ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 410px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.auth-head { display: flex; align-items: center; gap: 14px; background: var(--navy); color: #fff; padding: 22px 26px; }
.auth-head h1 { font-size: 19px; font-weight: 650; }
.auth-head p { margin: 2px 0 0; color: #b8c7e3; font-size: 13.5px; }
.auth-main { padding: 26px; }
.auth-title { font-size: 18px; font-weight: 650; margin-bottom: 16px; }
.error-box { text-align: center; }
.error-code { margin: 0 0 4px; font-size: 44px; font-weight: 700; color: var(--navy-3); }
.error-box .btn { margin-top: 12px; }

/* ---------- responsif ---------- */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 37, 71, .45); z-index: 20; }
  body.nav-open .backdrop { display: block; }
  .topbar { padding: 14px 16px; }
  .content { padding: 20px 16px 48px; }
  .stat-value { font-size: 24px; }
}
@media (max-width: 640px) {
  /* tabel menjadi daftar kartu di layar kecil */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-weight: 600; text-align: left; flex: none; }
  .cell-detail { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

.sr-copy { position: fixed; top: -100px; left: -100px; }

/* ---------- Tahap 4: lisensi & pelanggan ---------- */
.stat:hover { border-color: #b9c7e2; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.page-actions .btn-ghost { padding: 10px 16px; font-size: inherit; }
.field textarea { resize: vertical; min-height: 84px; }
.field input:disabled { background: #f1f5f9; color: var(--muted); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.narrow { max-width: 720px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .grow { flex: 1 1 260px; }
.filters .field:not(.grow) { min-width: 170px; }
.filter-buttons { display: flex; gap: 8px; }
.sub { display: block; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.cell-actions { white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: 6px; }

.keybox { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.key-display { font-size: 17px; font-weight: 600; letter-spacing: .02em; overflow-wrap: anywhere; }
.keybox-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.action { border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.action h3 { margin: 0; font-size: 15px; }
.action p { margin: 0; }
.action .form { width: 100%; }
.action-danger { border-color: #fecaca; background: #fffafa; }

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .cell-actions { justify-content: flex-end; }
  .filters .field:not(.grow), .filter-buttons { width: 100%; }
  .filter-buttons .btn { flex: 1; }
  .keybox-actions { width: 100%; }
  .keybox-actions .btn { flex: 1; }
}

/* ---------- penjualan (Tahap 6B-1) ---------- */
.badge-amber { background: #fef3c7; color: #92400e; }
.subnav { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.subnav-link { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav-link:hover { color: var(--ink); }
.subnav-link.is-active { color: var(--navy); border-bottom-color: var(--navy); }
.inline-form { margin-top: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; }
.advanced { border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; }
.advanced summary { cursor: pointer; font-weight: 600; }
.advanced .field { margin-top: 12px; }

/* ---------- portal pelanggan (Tahap 6B-2) ---------- */
.lic-grid { display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 14px; }
.lic-label { margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.lic-value { margin: 0; font-size: 18px; font-weight: 650; }
.lic-key { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lic-key code { font-size: 15px; font-weight: 600; letter-spacing: .4px; word-break: break-all; }
.lic-host { border-top: 1px solid var(--line); padding-top: 14px; }
.chip { display: inline-block; padding: 4px 12px; border: 1px solid var(--line); background: #f8fafc; border-radius: 8px; font-size: 14px; margin-right: 8px; }
.steps { margin: 0; padding-left: 20px; }
.steps li + li { margin-top: 8px; }
@media (max-width: 640px) { .lic-grid { grid-template-columns: 1fr 1fr; } .lic-grid > :first-child { grid-column: 1 / -1; } }

/* ---------- lebar penuh (Tahap 9A) ---------- */
/* Konten memenuhi lebar layar; formulir tetap dibatasi agar nyaman dibaca. */
.card > .form, .card > form.form { max-width: 760px; }
.card > .code { max-width: 100%; }

.group-title { margin: 22px 0 10px; font-size: 18px; font-weight: 650; }

/* Tiket support */
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--card); }
.msg-admin { border-left: 3px solid var(--blue); }
.msg-internal { background: #fffbeb; border-style: dashed; }
.msg-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.msg-body { margin-top: 6px; overflow-wrap: anywhere; line-height: 1.55; }
.nav-badge { margin-left: auto; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.att-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.att { margin: 0; max-width: 260px; }
.att-img { display: block; max-width: 100%; height: auto; max-height: 220px; width: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
