/**
 * Apeiron License Server — UI
 *
 * Mengikuti sistem desain Apeiron Portal:
 *  - Font Ubuntu, satu warna brand (biru #2563eb), netral memikul tampilan.
 *  - Radius 10px, border 1px tipis, bayangan nyaris tak terlihat.
 *  - Satu tinggi kontrol (40px) untuk tombol, input, dan select sebaris.
 *  - Sidebar putih di kiri + topbar tipis di atas konten.
 *
 * Semua nama class dan variabel lama tetap tersedia supaya halaman admin
 * yang sudah ada tetap bekerja tanpa diubah.
 */

/* =================================================================
   1. Token
   ================================================================= */
:root,
[data-theme="light"] {
    /* Netral */
    --n-0: #ffffff;
    --n-25: #fcfcfd;
    --n-50: #f9fafb;
    --n-100: #f2f4f7;
    --n-200: #e4e7ec;
    --n-300: #d0d5dd;
    --n-400: #98a2b3;
    --n-500: #667085;
    --n-600: #475467;
    --n-700: #344054;
    --n-800: #1d2939;
    --n-900: #101828;

    /* Brand */
    --brand: #2563eb;
    --brand-hover: #1d4ed8;
    --brand-active: #1e40af;
    --brand-soft: #eff4ff;
    --brand-border: #b9d0fd;
    --brand-ink: #1e40af;

    /* Status */
    --ok: var(--brand);
    --ok-soft: var(--brand-soft);
    --ok-border: var(--brand-border);
    --warn: #b54708;
    --warn-soft: #fffaeb;
    --warn-border: #fedf89;
    --err: #b42318;
    --err-hover: #912018;
    --err-soft: #fef3f2;
    --err-border: #fecdca;
    --info-ink: #2f6ac4;
    --info-soft: #f5f8fd;
    --info-border: #dfe8f6;

    /* Permukaan */
    --bg-page: var(--n-50);
    --bg-surface: var(--n-0);
    --bg-subtle: var(--n-50);
    --bg-hover: var(--n-100);
    --bg-overlay: rgba(16, 24, 40, 0.5);
    --topbar-bg: rgba(255, 255, 255, 0.85);
    --border-soft: #eceff4;
    --border-strong: #dde2ea;

    /* Teks */
    --text-heading: var(--n-900);
    --text-body: var(--n-700);
    --text-faint: var(--n-400);
    --text-inverse: #ffffff;

    /* Bayangan */
    --sh-card: 0 1px 3px rgba(16, 24, 40, 0.022);
    --sh-raise: 0 1px 3px rgba(16, 24, 40, 0.025), 0 2px 6px rgba(16, 24, 40, 0.03);
    --sh-pop: 0 4px 14px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.025);

    /* ---- Nama variabel lama (dipakai inline style di halaman admin) ---- */
    --bg-primary: var(--bg-page);
    --bg-secondary: var(--bg-surface);
    --bg-card: var(--bg-surface);
    --bg-card-hover: var(--bg-hover);
    --bg-input: var(--bg-surface);
    --border-color: var(--border-soft);
    --border-hover: var(--border-strong);
    --text-primary: var(--text-heading);
    --text-secondary: var(--text-body);
    --text-muted: var(--n-500);
    --accent: var(--brand);
    --accent-hover: var(--brand-hover);
    --accent-glow: rgba(37, 99, 235, 0.18);
    --accent-soft: var(--brand-soft);
    --success: var(--ok);
    --success-bg: var(--ok-soft);
    --warning: var(--warn);
    --warning-bg: var(--warn-soft);
    --danger: var(--err);
    --danger-bg: var(--err-soft);
    --info: var(--info-ink);
    --info-bg: var(--info-soft);
    --primary: var(--brand);
    --bg: var(--bg-subtle);
    --text: var(--text-heading);
    --border: var(--border-soft);
    --card-bg: var(--bg-surface);
    --error-bg: var(--err-soft);
    --shadow-sm: var(--sh-card);
    --shadow-md: var(--sh-raise);
    --shadow-lg: var(--sh-pop);

    /* Tipografi */
    --font-sans: 'Ubuntu', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Ubuntu Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --fs-h1: 1.375rem;
    --fs-h2: 1.125rem;
    --fs-h3: 1rem;
    --fs-body: 0.9375rem;
    --fs-label: 0.875rem;
    --fs-caption: 0.8125rem;
    --fs-micro: 0.75rem;
    --fw-medium: 500;
    --fw-bold: 700;
    --tracking-tight: -0.011em;
    --tracking-wide: 0.04em;

    /* Radius & kontrol */
    --r: 10px;
    --r-sm: 8px;
    --r-pill: 999px;
    --radius-sm: var(--r-sm);
    --radius-md: var(--r);
    --radius-lg: var(--r);
    --radius-xl: var(--r);
    --h-control: 40px;
    --h-control-sm: 34px;
    --h-control-lg: 46px;

    /* Layout */
    --sidebar-w: 248px;
    --topbar-h: 60px;
    --content-max: 1440px;

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 100ms;
    --dur: 160ms;

    color-scheme: light;
}

/* Mode gelap — palet netral yang sama, dibalik */
[data-theme="dark"] {
    --n-0: #0f1520;
    --n-25: #121926;
    --n-50: #0b111b;
    --n-100: #1a2231;
    --n-200: #253043;
    --n-300: #334059;
    --n-400: #6b778c;
    --n-500: #8b96a9;
    --n-600: #a7b0c0;
    --n-700: #c4cbd6;
    --n-800: #dfe3ea;
    --n-900: #f2f4f7;

    --brand: #3b7bff;
    --brand-hover: #5b8dff;
    --brand-active: #2563eb;
    --brand-soft: rgba(59, 123, 255, 0.14);
    --brand-border: rgba(59, 123, 255, 0.35);
    --brand-ink: #8fb4ff;

    --warn: #f5b454;
    --warn-soft: rgba(245, 180, 84, 0.12);
    --warn-border: rgba(245, 180, 84, 0.3);
    --err: #f97066;
    --err-hover: #f04438;
    --err-soft: rgba(249, 112, 102, 0.12);
    --err-border: rgba(249, 112, 102, 0.3);
    --info-ink: #8fb4ff;
    --info-soft: rgba(143, 180, 255, 0.1);
    --info-border: rgba(143, 180, 255, 0.25);

    --bg-overlay: rgba(0, 0, 0, 0.6);
    --topbar-bg: rgba(15, 21, 32, 0.85);
    --border-soft: #1f2838;
    --border-strong: #2b364a;
    --text-inverse: #ffffff;
    --accent-glow: rgba(59, 123, 255, 0.25);

    --sh-card: 0 1px 3px rgba(0, 0, 0, 0.25);
    --sh-raise: 0 2px 6px rgba(0, 0, 0, 0.3);
    --sh-pop: 0 8px 24px rgba(0, 0, 0, 0.45);

    color-scheme: dark;
}

/* =================================================================
   2. Reset & dasar
   ================================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: 1.6;
    color: var(--text-body);
    background: var(--bg-page);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4, h5 {
    color: var(--text-heading);
    font-weight: var(--fw-medium);
    line-height: 1.25;
    letter-spacing: var(--tracking-tight);
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: var(--brand-hover);
}

img,
svg {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
}

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

hr {
    border: none;
    border-top: 1px solid var(--border-soft);
}

.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center; }

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =================================================================
   3. Shell: sidebar + topbar + konten
   ================================================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---- Sidebar ---- */
.sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    flex-shrink: 0;
    height: 100vh;
    height: 100dvh;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--n-200);
    z-index: 200;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 20px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--n-200);
    color: var(--text-heading);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: var(--text-heading);
    text-decoration: none;
}

.brand-link:hover {
    color: var(--text-heading);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: var(--r);
    background: var(--brand);
    color: #fff;
    font-size: 14px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.brand-text strong {
    font-size: 1rem;
    font-weight: var(--fw-bold);
    color: var(--text-heading);
    letter-spacing: var(--tracking-tight);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-text small {
    font-size: var(--fs-micro);
    font-weight: var(--fw-medium);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--n-400);
}

.sidebar-close {
    display: none;
    margin-left: auto;
    width: 32px;
    height: 32px;
    place-items: center;
    border: none;
    background: none;
    border-radius: var(--r-sm);
    color: var(--n-600);
    cursor: pointer;
    font-size: 16px;
}

.sidebar-close:hover {
    background: var(--bg-hover);
    color: var(--text-heading);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 16px 16px;
}

.nav-label {
    padding: 0 12px;
    margin-bottom: 12px;
    font-size: var(--fs-micro);
    font-weight: var(--fw-medium);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--n-400);
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    list-style: none;
}

.nav-group + .nav-label {
    margin-top: 24px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: var(--h-control);
    padding: 0 12px;
    border-radius: var(--r);
    font-size: var(--fs-body);
    font-weight: var(--fw-medium);
    color: var(--n-600);
    text-decoration: none;
    white-space: nowrap;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-link i {
    width: 18px;
    font-size: 15px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-heading);
}

.nav-link.active {
    background: var(--brand-soft);
    color: var(--brand-ink);
}

.sidebar-footer {
    padding: 16px;
    flex-shrink: 0;
    border-top: 1px solid var(--n-200);
}

.nav-link-danger:hover {
    background: var(--err-soft);
    color: var(--err);
}

.sidebar-overlay {
    display: none;
}

/* ---- Topbar ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 190;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 24px;
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
}

.topbar-title {
    font-size: var(--fs-h3);
    font-weight: var(--fw-medium);
    color: var(--text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.nav-burger {
    display: none;
    place-items: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--r);
    background: var(--bg-subtle);
    color: var(--text-heading);
    cursor: pointer;
    font-size: 17px;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-burger:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-shrink: 0;
}

.btn-theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--bg-surface);
    color: var(--n-500);
    cursor: pointer;
    box-shadow: var(--sh-card);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.btn-theme-toggle:hover {
    background: var(--bg-subtle);
    border-color: var(--n-300);
    color: var(--text-heading);
}

.btn-theme-toggle i {
    font-size: 15px;
    pointer-events: none;
}

.nav-username {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 4px 4px;
    border-radius: var(--r-pill);
    min-width: 0;
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: var(--r-pill);
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-size: var(--fs-caption);
    font-weight: var(--fw-bold);
    text-transform: uppercase;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.user-name {
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
    color: var(--text-heading);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role {
    font-size: var(--fs-micro);
    color: var(--text-muted);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: var(--h-control);
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--bg-surface);
    color: var(--text-body);
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
    text-decoration: none;
    box-shadow: var(--sh-card);
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.btn-logout:hover {
    background: var(--err-soft);
    border-color: var(--err-border);
    color: var(--err);
}

/* ---- Area konten ---- */
/* Konten selalu mengisi penuh lebar layar (tanpa ruang kosong di monitor besar) */
.container {
    flex: 1;
    width: 100%;
    margin: 0;
    padding: 24px;
}

@media (min-width: 1600px) {
    .container {
        padding: 28px 32px;
    }
}

/* =================================================================
   4. Kartu
   ================================================================= */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
    box-shadow: var(--sh-card);
    padding: 20px;
    margin-bottom: 20px;
}

.card .card {
    box-shadow: none;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-soft);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--fs-h2);
    font-weight: var(--fw-medium);
    color: var(--text-heading);
}

.card-title i {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: var(--r);
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-size: 14px;
}

/* =================================================================
   5. Kartu statistik
   ================================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    --tone-fg: var(--brand-ink);
    --tone-bg: var(--brand-soft);
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 12px;
    align-items: center;
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
    box-shadow: var(--sh-card);
    transition: border-color var(--dur) var(--ease);
}

.stat-card:hover {
    border-color: var(--border-strong);
}

.stat-card.success { --tone-fg: var(--ok); --tone-bg: var(--ok-soft); }
.stat-card.danger  { --tone-fg: var(--err); --tone-bg: var(--err-soft); }
.stat-card.warning { --tone-fg: var(--warn); --tone-bg: var(--warn-soft); }
.stat-card.info    { --tone-fg: var(--info-ink); --tone-bg: var(--info-soft); }

.stat-icon {
    grid-column: 1;
    grid-row: 1 / span 3;
    align-self: center;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r);
    background: var(--tone-bg, var(--brand-soft));
    color: var(--tone-fg, var(--brand-ink));
    font-size: 16px;
}

.stat-value {
    grid-column: 2;
    grid-row: 1;
    font-size: var(--fs-h1);
    font-weight: var(--fw-bold);
    color: var(--text-heading);
    letter-spacing: var(--tracking-tight);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.stat-label {
    grid-column: 2;
    grid-row: 2;
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
    color: var(--text-body);
    line-height: 1.45;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.stat-label i {
    display: none;
}

.stat-change {
    grid-column: 2;
    grid-row: 3;
    font-size: var(--fs-caption);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.stat-change i {
    font-size: 11px;
    opacity: 0.8;
}

/* Kartu tanpa ikon tetap rapi */
.stat-card:not(:has(.stat-icon)) {
    grid-template-columns: minmax(0, 1fr);
}
.stat-card:not(:has(.stat-icon)) > * {
    grid-column: 1;
}

/* =================================================================
   6. Tombol
   ================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: var(--h-control);
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--r);
    font-family: inherit;
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
    color: var(--text-inverse);
}

.btn-primary:active:not(:disabled) {
    background: var(--brand-active);
    border-color: var(--brand-active);
}

.btn-secondary {
    background: var(--bg-surface);
    border-color: var(--border-strong);
    color: var(--text-body);
    box-shadow: var(--sh-card);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-subtle);
    border-color: var(--n-300);
    color: var(--text-heading);
}

.btn-success {
    background: var(--ok);
    border-color: var(--ok);
    color: var(--text-inverse);
}

.btn-success:hover:not(:disabled) {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
    color: var(--text-inverse);
}

.btn-warning {
    background: var(--warn-soft);
    border-color: var(--warn-border);
    color: var(--warn);
}

.btn-warning:hover:not(:disabled) {
    background: var(--warn);
    border-color: var(--warn);
    color: #fff;
}

.btn-danger {
    background: var(--err-soft);
    border-color: var(--err-border);
    color: var(--err);
}

.btn-danger:hover:not(:disabled) {
    background: var(--err);
    border-color: var(--err);
    color: #fff;
}

.btn-sm {
    height: var(--h-control-sm);
    padding: 0 12px;
    font-size: var(--fs-caption);
}

.btn-lg {
    height: var(--h-control-lg);
    padding: 0 20px;
    font-size: var(--fs-body);
}

.btn-icon {
    width: var(--h-control);
    padding: 0;
}

/* =================================================================
   7. Form
   ================================================================= */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
    color: var(--text-heading);
}

.form-label i {
    color: var(--text-faint);
    font-size: 13px;
    width: 16px;
    text-align: center;
}

.form-control {
    display: block;
    width: 100%;
    min-height: var(--h-control);
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    font-family: inherit;
    font-size: var(--fs-body);
    line-height: 1.45;
    color: var(--text-heading);
    box-shadow: none;
    transition: border-color var(--dur) var(--ease);
}

.form-control::placeholder {
    color: var(--text-faint);
}

.form-control:hover:not(:disabled) {
    border-color: var(--n-300);
}

.form-control:focus:not(:disabled) {
    outline: none;
    border-color: var(--brand);
    box-shadow: none;
}

.form-control:disabled,
.form-control[readonly] {
    background: var(--bg-subtle);
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 88px;
    resize: vertical;
}

select.form-control {
    height: var(--h-control);
    padding-top: 0;
    padding-bottom: 0;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

select.form-control[multiple] {
    height: auto;
    background-image: none;
    padding: 8px 12px;
}

select.form-control option {
    background: var(--bg-surface);
    color: var(--text-heading);
}

/* Field di baris filter (header kartu) memakai lebar alami, bukan 100% */
.card-header form .form-control {
    width: auto;
    min-width: 0;
    max-width: 100%;
}

.form-control-sm {
    min-height: var(--h-control-sm);
    padding: 4px 10px;
    font-size: var(--fs-label);
}

select.form-control-sm {
    height: var(--h-control-sm);
}

.form-text {
    font-size: var(--fs-caption);
    color: var(--text-muted);
    margin-top: 6px;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--brand);
}

/* =================================================================
   8. Tabel
   ================================================================= */
.table-wrapper,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-label);
}

.table thead {
    background: var(--bg-subtle);
}

.table th {
    height: 40px;
    padding: 0 16px;
    text-align: left;
    font-size: var(--fs-caption);
    font-weight: var(--fw-medium);
    color: var(--text-muted);
    white-space: nowrap;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-soft);
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-body);
    vertical-align: middle;
    white-space: nowrap;
}

/* Isi sel tidak dipatah per kata; tabel lebar digulir ke samping */
.table th i {
    margin-right: 4px;
}

.table th:first-child,
.table td:first-child {
    padding-left: 20px;
}

.table th:last-child,
.table td:last-child {
    padding-right: 20px;
}

.table tbody tr {
    transition: background var(--dur-fast) var(--ease);
}

.table tbody tr:hover {
    background: var(--bg-subtle);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* =================================================================
   9. Badge
   ================================================================= */
.badge {
    --tone-fg: var(--n-600);
    --tone-bg: var(--n-100);
    --tone-border: var(--n-200);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--r-sm);
    border: 1px solid var(--tone-border);
    background: var(--tone-bg);
    color: var(--tone-fg);
    font-size: var(--fs-micro);
    font-weight: var(--fw-medium);
    white-space: nowrap;
    line-height: 1;
}

.badge i {
    font-size: 10px;
}

.badge-active,
.badge-success {
    --tone-fg: var(--ok);
    --tone-bg: var(--ok-soft);
    --tone-border: var(--ok-border);
}

.badge-inactive,
.badge-danger {
    --tone-fg: var(--err);
    --tone-bg: var(--err-soft);
    --tone-border: var(--err-border);
}

.badge-expired,
.badge-warning {
    --tone-fg: var(--warn);
    --tone-bg: var(--warn-soft);
    --tone-border: var(--warn-border);
}

.badge-info {
    --tone-fg: var(--info-ink);
    --tone-bg: var(--info-soft);
    --tone-border: var(--info-border);
}

.badge-suspended,
.badge-secondary {
    --tone-fg: var(--n-600);
    --tone-bg: var(--n-100);
    --tone-border: var(--n-200);
}

/* =================================================================
   10. Alert
   ================================================================= */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: var(--r);
    border: 1px solid var(--n-200);
    background: var(--bg-surface);
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
    transition: opacity 0.3s ease;
    animation: slideIn var(--dur) var(--ease);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: var(--ok-soft);
    border-color: var(--ok-border);
    color: var(--brand-ink);
}

.alert-error,
.alert-danger {
    background: var(--err-soft);
    border-color: var(--err-border);
    color: var(--err);
}

.alert-warning {
    background: var(--warn-soft);
    border-color: var(--warn-border);
    color: var(--warn);
}

.alert-info {
    background: var(--info-soft);
    border-color: var(--info-border);
    color: var(--info-ink);
}

.alert-close {
    margin-left: auto;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    background: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    opacity: 0.6;
    cursor: pointer;
    transition: opacity var(--dur) var(--ease);
}

.alert-close:hover {
    opacity: 1;
}

/* =================================================================
   11. Kode
   ================================================================= */
code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--n-100);
    border: 1px solid var(--n-200);
    font-family: var(--font-mono);
    font-size: 0.875em;
    color: var(--text-heading);
    overflow-wrap: anywhere;
}

/* Di dalam tabel, kunci lisensi tetap satu baris; tabel bisa digulir */
.table code {
    white-space: nowrap;
    overflow-wrap: normal;
}

pre {
    font-family: var(--font-mono);
}

/* =================================================================
   12. Footer
   ================================================================= */
.footer {
    padding: 20px 24px;
    margin-top: auto;
    border-top: 1px solid var(--border-soft);
}

.footer-content {
    margin: 0 auto;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--fs-caption);
}

/* =================================================================
   13. Grid halaman
   ================================================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.dashboard-grid > .card {
    margin-bottom: 0;
    min-width: 0;
}

.generate-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
}

/* =================================================================
   14. Modal
   ================================================================= */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    padding: 16px;
    background: var(--bg-overlay);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: fadeIn var(--dur) var(--ease);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    --modal-pad: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    max-height: calc(100dvh - 32px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: var(--modal-pad);
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
    box-shadow: var(--sh-pop);
    overscroll-behavior: contain;
}

/* Judul popup tetap terlihat (dan tombol tutup bisa diklik) saat isi digulir */
.modal-header {
    position: sticky;
    top: calc(-1 * var(--modal-pad, 24px));
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: calc(-1 * var(--modal-pad, 24px)) calc(-1 * var(--modal-pad, 24px)) 20px;
    padding: var(--modal-pad, 24px) var(--modal-pad, 24px) 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-soft);
}

.modal-header h2,
.modal-header h3 {
    font-size: var(--fs-h2);
}

.modal-close {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.modal-close:hover {
    background: var(--err-soft);
    border-color: var(--err-border);
    color: var(--err);
}

/* =================================================================
   15. Loading
   ================================================================= */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--n-200);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =================================================================
   16. Komponen halaman
   ================================================================= */

/* Grafik di dalam kartu */
.chart-box {
    position: relative;
    min-width: 0;
}

.chart-box canvas {
    max-height: 300px;
}

/* Kotak abu-abu bertingkat (endpoint, info) */
.panel-subtle {
    padding: 16px;
    margin-bottom: 16px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
}

.panel-subtle:last-child {
    margin-bottom: 0;
}

.panel-subtle h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: var(--fs-label);
    color: var(--text-heading);
}

.panel-subtle h4 i {
    color: var(--brand);
}

/* Blok kode satu baris / beberapa baris */
.code-block {
    display: block;
    padding: 12px 14px;
    background: var(--n-100);
    border: 1px solid var(--n-200);
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    color: var(--text-heading);
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Kartu di dalam kartu: elemen terakhir tidak menambah jarak bawah */
.card > .card:last-child,
.card > .dashboard-grid:last-child {
    margin-bottom: 0;
}

.meta-text {
    margin-top: 8px;
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

/* Kotak sorotan (mis. API key baru) */
.callout {
    padding: 20px;
    margin-bottom: 20px;
    border-radius: var(--r);
    border: 1px solid var(--warn-border);
    background: var(--warn-soft);
    color: var(--text-body);
}

.callout h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: var(--fs-h3);
    color: var(--warn);
}

.callout p {
    margin-bottom: 12px;
}

.callout .code-block {
    margin-bottom: 16px;
    background: var(--bg-surface);
}

/* Daftar error log */
.error-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.error-item {
    padding: 12px 14px;
    background: var(--err-soft);
    border: 1px solid var(--err-border);
    border-left: 3px solid var(--err);
    border-radius: var(--r-sm);
}

.error-item-title {
    font-weight: var(--fw-medium);
    color: var(--err);
}

.error-item-meta {
    margin-top: 4px;
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

.error-item-context {
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    color: var(--text-body);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Daftar key/value (mis. System Metrics) */
.kv-list {
    display: flex;
    flex-direction: column;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
    font-size: var(--fs-label);
}

.kv-row:last-child {
    border-bottom: none;
}

.kv-row span:first-child {
    color: var(--text-muted);
}

.kv-row span:last-child {
    font-weight: var(--fw-medium);
    color: var(--text-heading);
    text-align: right;
    overflow-wrap: anywhere;
}

/* Hasil generate license */
.generated-keys-list {
    display: grid;
    gap: 12px;
}

.generated-key-item {
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
    transition: border-color var(--dur) var(--ease);
}

.generated-key-item:hover {
    border-color: var(--brand-border);
}

.generated-key-index {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-size: var(--fs-micro);
    font-weight: var(--fw-bold);
}

.generated-key-code {
    font-size: var(--fs-body);
    font-weight: var(--fw-bold);
    letter-spacing: 0.02em;
}

/* Halaman health check */
.health-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.health-hero-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: var(--r);
    background: var(--n-100);
    color: var(--n-500);
    font-size: 22px;
}

.health-hero.is-ok .health-hero-icon { background: var(--ok-soft); color: var(--ok); }
.health-hero.is-warn .health-hero-icon { background: var(--warn-soft); color: var(--warn); }
.health-hero.is-err .health-hero-icon { background: var(--err-soft); color: var(--err); }

.health-hero-text {
    flex: 1;
    min-width: 200px;
}

.health-hero-text h2 {
    font-size: var(--fs-h1);
    margin-bottom: 2px;
}

.health-hero-text p {
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.health-check {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
    box-shadow: var(--sh-card);
}

.health-check-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--r);
    background: var(--n-100);
    color: var(--n-500);
    font-size: 16px;
}

.health-check.is-ok .health-check-icon { background: var(--ok-soft); color: var(--ok); }
.health-check.is-warn .health-check-icon { background: var(--warn-soft); color: var(--warn); }
.health-check.is-err .health-check-icon { background: var(--err-soft); color: var(--err); }

.health-check-body {
    flex: 1;
    min-width: 0;
}

.health-check-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.health-check-name {
    font-weight: var(--fw-medium);
    color: var(--text-heading);
}

.health-check-detail {
    font-size: var(--fs-caption);
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

/* =================================================================
   Dashboard
   ================================================================= */
.dash-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.dash-hero-text h1 {
    font-size: var(--fs-h1);
    margin-bottom: 4px;
}

.dash-hero-text p {
    font-size: var(--fs-label);
    color: var(--text-muted);
}

.dash-updated {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-pill);
    background: var(--bg-surface);
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

/* Baris grafik: request API (lebar) + status lisensi */
.dash-charts {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.dash-charts > .card {
    margin-bottom: 0;
}

.dash-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

.dash-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dash-legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.dash-legend i.is-line {
    height: 3px;
    border-radius: 2px;
}

.dash-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.dash-kpis > div {
    padding: 12px 14px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
}

.dash-kpis strong {
    display: block;
    font-size: var(--fs-h2);
    font-weight: var(--fw-bold);
    color: var(--text-heading);
    line-height: 1.3;
}

.dash-kpis strong.is-bad {
    color: var(--err);
}

.dash-kpis span {
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

.dash-chart-box {
    position: relative;
    height: 260px;
}

/* Donut status lisensi */
.dash-donut {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.dash-donut-chart {
    position: relative;
    width: 200px;
    height: 200px;
}

.dash-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.dash-donut-center strong {
    font-size: var(--fs-h1);
    font-weight: var(--fw-bold);
    color: var(--text-heading);
    line-height: 1.1;
}

.dash-donut-center span {
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

.dash-status-list {
    width: 100%;
    list-style: none;
    display: flex;
    flex-direction: column;
}

.dash-status-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 4px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-body);
    font-size: var(--fs-label);
    text-decoration: none;
}

.dash-status-list li:last-child a {
    border-bottom: none;
}

.dash-status-list a:hover {
    color: var(--text-heading);
}

.dash-status-list i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.dash-status-list span {
    flex: 1;
}

.dash-status-list strong {
    font-weight: var(--fw-medium);
    color: var(--text-heading);
}

.dash-status-list em {
    width: 44px;
    text-align: right;
    font-style: normal;
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

/* Daftar ringkas (Expiring Soon) — gaya sama dengan Top Websites */
.dash-list {
    list-style: none;
    display: flex;
    flex-direction: column;
}

.dash-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-soft);
}

.dash-list li:first-child {
    padding-top: 0;
}

.dash-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.dash-list-main {
    min-width: 0;
}

.dash-list-main .key-chip {
    max-width: 100%;
}

.dash-list-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    text-align: right;
}

.dash-list-side .cell-sub {
    margin-top: 4px;
}

.dash-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 0;
    font-size: var(--fs-label);
    color: var(--text-muted);
}

.dash-empty i {
    color: var(--ok);
}

/* Bar horizontal sederhana (Top Websites) */
.dash-bars {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dash-bars-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    font-size: var(--fs-label);
}

.dash-bars-row .key-chip {
    max-width: 65%;
    color: var(--text-heading);
    font-weight: var(--fw-medium);
}

.dash-bars-num {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-body);
    font-weight: var(--fw-medium);
}

.dash-bars-track {
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--n-100);
    overflow: hidden;
}

.dash-bars-track span {
    display: block;
    height: 100%;
    border-radius: var(--r-pill);
    background: var(--brand);
}

@media (max-width: 1200px) {
    .dash-charts {
        grid-template-columns: minmax(0, 1fr);
    }

    .dash-donut {
        flex-direction: row;
        align-items: center;
    }

    .dash-donut-chart {
        flex-shrink: 0;
    }
}

@media (max-width: 640px) {
    .dash-donut {
        flex-direction: column;
    }

    .dash-kpis {
        gap: 8px;
    }

    .dash-kpis > div {
        padding: 10px;
    }

    .dash-chart-box {
        height: 220px;
    }
}

/* Kartu statistik yang bisa diklik */
a.stat-link {
    color: inherit;
    text-decoration: none;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

a.stat-link:hover {
    color: inherit;
    border-color: var(--brand-border);
    box-shadow: var(--sh-raise);
}

a.stat-link:focus-visible {
    outline-offset: 2px;
}

/* Dua kartu tabel sejajar dengan tinggi sama */
.dash-grid {
    align-items: stretch;
}

.dash-card {
    display: flex;
    flex-direction: column;
}

/* Grup tombol aksi di baris tabel: ikon seragam, satu baris */
.row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.row-actions form {
    display: inline-flex;
    margin: 0;
}

.row-actions .btn {
    flex-shrink: 0;
}

.btn-icon.btn-sm {
    width: var(--h-control-sm);
    min-width: var(--h-control-sm);
    padding: 0;
}

/* Chip key/URL panjang: dipotong dengan elipsis */
.key-chip {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.key-chip-wide {
    max-width: 280px;
}

.cell-sub {
    display: block;
    margin-top: 2px;
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

.cell-muted {
    color: var(--text-muted);
}

.empty-row td {
    text-align: center;
    padding: 40px 16px !important;
    color: var(--text-muted);
    white-space: normal;
}

/* Tab di header kartu (segmented) */
.page-tabs {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
    max-width: 100%;
    overflow-x: auto;
}

.page-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 14px;
    border-radius: var(--r-sm);
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.page-tab:hover {
    color: var(--text-heading);
}

.page-tab.active {
    background: var(--bg-surface);
    color: var(--brand-ink);
    box-shadow: var(--sh-card);
}

/* Baris filter di atas tabel */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.toolbar-search {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 260px;
}

.toolbar-search .form-control {
    flex: 1;
}

.toolbar > select.form-control {
    width: auto;
    min-width: 150px;
}

/* Bar aksi massal */
.bulk-bar {
    display: none;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 16px;
    background: var(--brand-soft);
    border: 1px solid var(--brand-border);
    border-radius: var(--r);
}

.bulk-bar.show {
    display: flex;
}

.bulk-bar-count {
    font-weight: var(--fw-medium);
    color: var(--brand-ink);
    margin-right: 4px;
}

.bulk-bar select.form-control {
    width: auto;
    min-width: 150px;
}

/* Popup detail berada satu lapis di bawah popup lain (konfirmasi, edit) */
#ajaxModal {
    z-index: 1990;
}

/* Popup besar + isi yang dapat digulir */
.modal-content.modal-lg {
    max-width: 920px;
}

.modal-content.modal-md {
    max-width: 640px;
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.modal-header h2 i {
    color: var(--brand);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

.modal-loading {
    display: grid;
    place-items: center;
    gap: 12px;
    padding: 48px 16px;
    color: var(--text-muted);
}

/* Isi detail lisensi di popup */
.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: var(--fs-micro);
    font-weight: var(--fw-medium);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-muted);
}

.detail-key {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 20px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
}

.detail-key code {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    padding: 0;
    font-size: var(--fs-label);
}

/* Form generate di popup: dua kolom */
.form-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
    font-size: var(--fs-micro);
    font-weight: var(--fw-medium);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-muted);
}

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: var(--fs-label);
}

.check-row input {
    margin-top: 4px;
}

/* =================================================================
   Notifikasi request gagal (lonceng topbar + toast)
   ================================================================= */
[hidden] {
    display: none !important;
}

.notif {
    position: relative;
}

.notif-bell {
    position: relative;
}

.notif.has-unseen .notif-bell {
    color: var(--err);
    border-color: var(--err-border);
}

.notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: var(--r-pill);
    background: var(--err);
    color: #fff;
    font-size: 10px;
    font-weight: var(--fw-bold);
    line-height: 1;
    box-shadow: 0 0 0 2px var(--bg-surface);
}

.notif-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 380px;
    max-width: calc(100vw - 24px);
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r);
    box-shadow: var(--sh-pop);
    z-index: 300;
    overflow: hidden;
    animation: fadeIn var(--dur) var(--ease);
}

.notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
}

.notif-head strong {
    display: block;
    font-weight: var(--fw-medium);
    color: var(--text-heading);
}

.notif-sub {
    display: block;
    font-size: var(--fs-caption);
    color: var(--text-muted);
}

.notif-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-bottom: 1px solid var(--border-soft);
    background: none;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: background var(--dur) var(--ease);
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item:hover {
    background: var(--bg-subtle);
}

.notif-item.is-new {
    background: var(--err-soft);
}

.notif-item.is-new:hover {
    background: var(--bg-hover);
}

.notif-icon,
.toast-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: var(--r);
    font-size: 13px;
}

.notif-icon.tone-warning,
.toast.tone-warning .toast-icon {
    background: var(--warn-soft);
    color: var(--warn);
}

.notif-icon.tone-danger,
.toast.tone-danger .toast-icon {
    background: var(--err-soft);
    color: var(--err);
}

.notif-body,
.toast-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.notif-title {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
    color: var(--text-heading);
}

.notif-text {
    font-size: var(--fs-caption);
    color: var(--text-body);
    line-height: 1.45;
}

.notif-meta {
    font-size: var(--fs-micro);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notif-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 16px;
    font-size: var(--fs-label);
    color: var(--text-muted);
}

.notif-empty i {
    color: var(--ok);
}

.notif-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-subtle);
    font-size: var(--fs-label);
    font-weight: var(--fw-medium);
}

/* Popup konfirmasi (pengganti confirm() browser) */
#confirmModal {
    z-index: 2050;
}

.modal-content.modal-confirm {
    max-width: 440px;
}

.confirm-body {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.confirm-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: var(--r);
    font-size: 17px;
    background: var(--err-soft);
    color: var(--err);
}

.confirm-icon.tone-warning {
    background: var(--warn-soft);
    color: var(--warn);
}

.confirm-icon.tone-primary {
    background: var(--brand-soft);
    color: var(--brand-ink);
}

.confirm-text {
    min-width: 0;
}

.confirm-text h2 {
    margin-bottom: 6px;
    font-size: var(--fs-h2);
}

.confirm-text p {
    color: var(--text-body);
    line-height: 1.55;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Tombol aksi berbahaya yang solid (dipakai di popup konfirmasi) */
.btn-danger-solid {
    background: var(--err);
    border-color: var(--err);
    color: #fff;
}

.btn-danger-solid:hover:not(:disabled) {
    background: var(--err-hover);
    border-color: var(--err-hover);
    color: #fff;
}

.btn-warning-solid {
    background: var(--warn);
    border-color: var(--warn);
    color: #fff;
}

.btn-warning-solid:hover:not(:disabled) {
    filter: brightness(0.92);
    color: #fff;
}

/* Toast */
.toast-host {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 360px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--warn);
    border-radius: var(--r);
    box-shadow: var(--sh-pop);
    pointer-events: auto;
    animation: slideIn var(--dur) var(--ease);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.tone-danger {
    border-left-color: var(--err);
}

.toast.is-leaving {
    opacity: 0;
    transform: translateY(6px);
}

.toast-body strong {
    font-weight: var(--fw-medium);
    color: var(--text-heading);
}

.toast-body span {
    font-size: var(--fs-caption);
    color: var(--text-body);
}

.toast-body .toast-sub {
    color: var(--text-muted);
}

.toast-close {
    margin-left: auto;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

/* =================================================================
   17. Responsif
   ================================================================= */

@media (max-width: 480px) {
    .notif-panel {
        position: fixed;
        top: calc(var(--topbar-h) + 4px);
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }
}

@media (max-width: 720px) {
    .detail-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Tepat 4 kartu statistik: satu baris berisi 4 */
.stats-grid:has(> :nth-child(4):last-child) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1100px) {
    .stats-grid:has(> :nth-child(4):last-child) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 1600px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1100px) {
    /* Halaman dashboard memasang grid 2 kolom lewat inline style */
    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

/* Sidebar jadi drawer di bawah 1024px */
@media (max-width: 1023px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
        transition: transform var(--dur) var(--ease);
        box-shadow: var(--sh-pop);
    }

    body.nav-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-close {
        display: grid;
    }

    body.nav-open .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: var(--bg-overlay);
        z-index: 199;
        animation: fadeIn var(--dur) var(--ease);
    }

    body.nav-open {
        overflow: hidden;
    }

    .nav-burger {
        display: grid;
    }

    .generate-form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
        gap: 12px;
    }

    .user-meta,
    .logout-text {
        display: none;
    }

    .btn-logout {
        width: var(--h-control);
        padding: 0;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .card {
        padding: 16px;
    }

    .card-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
    }

    .table th,
    .table td {
        padding-left: 12px;
        padding-right: 12px;
    }

    .nav-link,
    .btn {
        min-height: 40px;
    }

    .btn-sm {
        min-height: var(--h-control-sm);
    }
}

@media (max-width: 480px) {
    .stats-grid,
    .stats-grid:has(> :nth-child(4):last-child) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card {
        grid-template-columns: minmax(0, 1fr);
        padding: 14px;
    }

    .stat-card > * {
        grid-column: 1;
    }

    .stat-icon {
        grid-row: auto;
        width: 34px;
        height: 34px;
        margin-bottom: 8px;
        font-size: 14px;
    }

    .stat-value {
        grid-row: auto;
        font-size: var(--fs-h2);
    }

    .stat-label,
    .stat-change {
        grid-row: auto;
    }

    /* Urutan di kartu sempit: ikon, angka, label, keterangan */
    .stat-icon { order: 0; }
    .stat-value { order: 1; }
    .stat-label { order: 2; }
    .stat-change { order: 3; }
}

@media (max-width: 340px) {
    .stats-grid,
    .stats-grid:has(> :nth-child(4):last-child) {
        grid-template-columns: minmax(0, 1fr);
    }

    .topbar-title {
        font-size: var(--fs-label);
    }
}

/* Popup di layar kecil: tepi lebih rapat */
@media (max-width: 640px) {
    .modal {
        padding: 8px;
    }

    .modal-content {
        --modal-pad: 16px;
        max-height: calc(100dvh - 16px);
    }

    .modal-footer {
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1;
    }
}

/* =================================================================
   Scrollbar: 1px di seluruh halaman, tabel, dan popup
   (Chrome/Edge/Safari). Firefox tidak mendukung lebar piksel, jadi
   memakai ukuran tertipis yang tersedia.
   ================================================================= */
*::-webkit-scrollbar {
    width: 1px;
    height: 1px;
}

*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--n-300);
    border-radius: 1px;
}

*::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

/* Hanya Firefox: scrollbar-width di Chrome justru mematikan aturan di atas */
@supports (-moz-appearance: none) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--n-300) transparent;
    }
}

/* clip (bukan hidden) supaya sidebar & topbar sticky tetap menempel */
html,
body {
    overflow-x: clip;
    max-width: 100%;
}
