/* ============================================================
   LicensePanel — cPanel-Style Professional UI
   (Fonts loaded via <link> in header.php)
   ============================================================ */

:root {
    /* Primary */
    --primary:          #2563eb;
    --primary-light:    #3b82f6;
    --primary-dark:     #1d4ed8;
    --primary-soft:     #eff6ff;
    --primary-gradient: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);

    /* Status */
    --success:      #16a34a;
    --success-soft: #dcfce7;
    --warning:      #d97706;
    --warning-soft: #fef3c7;
    --danger:       #dc2626;
    --danger-soft:  #fee2e2;

    /* Sidebar */
    --sidebar-bg:          #1e293b;
    --sidebar-hover:       rgba(255,255,255,0.06);
    --sidebar-active-bg:   rgba(37,99,235,0.15);
    --sidebar-active-line: #3b82f6;
    --sidebar-text:        #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-muted:       rgba(255,255,255,0.32);
    --sidebar-width:       210px;

    /* Layout */
    --topbar-h:   58px;
    --page:       #f1f5f9;
    --surface:    #ffffff;
    --text:       #0f172a;
    --text-2:     #475569;
    --text-muted: #94a3b8;
    --line:       #e2e8f0;
    --line-soft:  #f8fafc;

    /* Shadows (neutral) */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 24px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.06);

    /* Radius */
    --r-sm:  4px;
    --r-md:  6px;
    --r-lg:  8px;
    --r-xl:  10px;
    --r-2xl: 14px;

    /* Auth page compat vars */
    --indigo-200: #c7d2fe;
    --indigo-400: #818cf8;
    --sidebar-surface: rgba(255,255,255,0.05);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color .15s; }
button, input, select { font: inherit; }

.material-symbols-rounded {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    display: inline-flex;
    line-height: 1;
    vertical-align: middle;
}

/* ════════════════════════════════════════
   LAYOUT
════════════════════════════════════════ */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0,1fr);
    min-height: 100vh;
}

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
    border-right: 1px solid rgba(255,255,255,0.04);
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    height: var(--topbar-h);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.2px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.brand:hover { color: #fff; }

.brand small {
    display: block;
    margin-top: 1px;
    color: var(--sidebar-muted);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    background: var(--primary-gradient);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}

/* Sidebar profile (hidden in cPanel style — moved to topbar) */
.sidebar-profile { display: none; }

/* Nav */
.nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 12px 8px;
    flex: 1;
}

.nav-label {
    padding: 14px 10px 5px;
    color: var(--sidebar-muted);
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 10px;
    border-radius: var(--r-lg);
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    transition: background .12s, color .12s;
    position: relative;
}

.nav a .material-symbols-rounded {
    font-size: 18px;
    color: #64748b;
    transition: color .12s;
    flex-shrink: 0;
}

.nav a:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}
.nav a:hover .material-symbols-rounded { color: #94a3b8; }

.nav a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    font-weight: 600;
}
.nav a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--sidebar-active-line);
}
.nav a.active .material-symbols-rounded { color: #93c5fd; }

/* Sidebar bottom area */
.sidebar-logout { display: none; }

/* ════════════════════════════════════════
   CONTENT AREA
════════════════════════════════════════ */
.content-area {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ── Top Bar ── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-xs);
}

.app-header-left { display: flex; align-items: center; gap: 12px; }
.app-header-right { display: flex; align-items: center; gap: 10px; }

.app-header strong {
    display: block;
    color: var(--text);
    font-size: 14.5px;
    font-weight: 700;
}

.app-header span {
    display: block;
    margin-top: 1px;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 400;
    text-transform: capitalize;
}

/* User chip in topbar */
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--line-soft);
    cursor: default;
}
.user-chip .avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
}
.user-chip-info { line-height: 1.2; }
.user-chip-name {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
}
.user-chip-role {
    display: block;
    font-size: 10.5px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.logout-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    transition: all .15s;
    white-space: nowrap;
}
.logout-link:hover {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

/* ── Page Shell ── */
.page-shell {
    width: min(1320px, calc(100% - 48px));
    margin: 24px auto;
    flex: 1;
}

/* ════════════════════════════════════════
   AUTH LAYOUT
════════════════════════════════════════ */
.auth-layout {
    min-height: 100vh;
    background: #0f172a;
    position: relative;
    overflow: hidden;
}
.auth-layout::before {
    content: '';
    position: fixed;
    top: -160px; left: -120px;
    width: 520px; height: 520px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37,99,235,.22) 0%, transparent 65%);
    pointer-events: none;
}
.auth-layout::after {
    content: '';
    position: fixed;
    bottom: -160px; right: -80px;
    width: 440px; height: 440px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59,130,246,.16) 0%, transparent 65%);
    pointer-events: none;
}

.login-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    height: 64px;
    padding: 0 32px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    position: relative;
    z-index: 1;
}
.login-header .brand { color: #fff; border-bottom: 0; padding: 0; height: auto; }
.login-header .logout-link {
    border-color: rgba(255,255,255,.14);
    background: rgba(255,255,255,.05);
    color: rgba(255,255,255,.65);
}
.login-header .logout-link:hover {
    border-color: rgba(255,255,255,.3);
    background: rgba(255,255,255,.1);
    color: #fff;
}

.auth-shell {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0 16px;
    position: relative;
    z-index: 1;
}

/* ── Auth Card ── */
.auth-card {
    width: min(440px, 100%);
    margin: 48px auto;
    padding: 40px;
    border-radius: var(--r-2xl);
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: var(--shadow-xl);
}
.auth-card h1         { color: #fff; font-size: 24px; }
.auth-card .eyebrow   { color: #60a5fa; }
.auth-card .hero-copy { color: rgba(255,255,255,.5); font-size: 14px; }
.auth-card label span { color: rgba(255,255,255,.6); }
.auth-card input {
    background: rgba(255,255,255,.07);
    border-color: rgba(255,255,255,.12);
    color: #fff;
}
.auth-card input::placeholder { color: rgba(255,255,255,.25); }
.auth-card input:focus {
    border-color: #3b82f6;
    outline: 3px solid rgba(59,130,246,.2);
    background: rgba(255,255,255,.1);
}

/* ════════════════════════════════════════
   ALERTS
════════════════════════════════════════ */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding: 12px 16px;
    border-radius: var(--r-lg);
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid;
}
.alert-success { background: var(--success-soft); color: #14532d; border-color: #bbf7d0; }
.alert-error   { background: var(--danger-soft);  color: #7f1d1d; border-color: #fecaca; }

/* ════════════════════════════════════════
   SECTION HEAD / TOPBAR
════════════════════════════════════════ */
.topbar, .section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.section-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

/* ════════════════════════════════════════
   TYPOGRAPHY
════════════════════════════════════════ */
h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.4px;
    line-height: 1.25;
    color: var(--text);
}
.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}
.hero-copy {
    max-width: 580px;
    margin: 8px 0 0;
    color: var(--text-2);
    font-size: 14px;
    line-height: 1.6;
}
.muted { color: var(--text-muted); }

/* ════════════════════════════════════════
   CARD SURFACES (shared)
════════════════════════════════════════ */
.metric,
.hero-panel,
.purchase-panel,
.license-table-wrap,
.product-card,
.invoice-card {
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* ════════════════════════════════════════
   METRIC GRID
════════════════════════════════════════ */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.metric-grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }

.metric {
    padding: 20px 22px;
    position: relative;
    transition: box-shadow .15s;
}
.metric:hover { box-shadow: var(--shadow-md); }

.metric::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    background: var(--primary-gradient);
}

.metric span {
    display: block;
    margin-bottom: 8px;
    color: var(--text-2);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
}
.metric strong {
    display: block;
    color: var(--text);
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.6px;
    line-height: 1;
}
.metric small {
    display: block;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 400;
}

/* ════════════════════════════════════════
   FORM ELEMENTS
════════════════════════════════════════ */
label span {
    display: block;
    margin-bottom: 5px;
    color: var(--text-2);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}

input, select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
    -webkit-appearance: none;
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}
input:focus, select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ════════════════════════════════════════
   BUTTONS
════════════════════════════════════════ */
button { cursor: pointer; }

.primary-btn,
.table-btn,
.primary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: var(--r-lg);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s, box-shadow .15s, transform .12s;
    letter-spacing: .1px;
}
.primary-btn,
.primary-link { min-height: 40px; padding: 0 20px; font-size: 13.5px; }
.table-btn    { min-height: 30px; padding: 0 12px; font-size: 12px; border-radius: var(--r-md); }

.primary-btn:hover,
.table-btn:hover,
.primary-link:hover {
    background: var(--primary-dark);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.primary-btn:active,
.table-btn:active { transform: translateY(1px); }

.primary-btn.full { width: 100%; }

.danger-btn { background: var(--danger); }
.danger-btn:hover { background: #b91c1c; box-shadow: 0 2px 8px rgba(220,38,38,.3); }

/* ════════════════════════════════════════
   STACK FORM (auth)
════════════════════════════════════════ */
.stack-form {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

/* ════════════════════════════════════════
   AUTH STRIP
════════════════════════════════════════ */
.auth-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 8px;
    margin-top: 20px;
}
.auth-strip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 999px;
    background: rgba(255,255,255,.05);
    color: rgba(255,255,255,.45);
    font-size: 10.5px;
    font-weight: 600;
}

/* ════════════════════════════════════════
   PURCHASE PANEL & FORMS
════════════════════════════════════════ */
.purchase-panel { margin-bottom: 18px; }

.buy-form, .product-form, .member-form {
    display: grid;
    grid-template-columns: minmax(200px,1fr) minmax(200px,1fr) auto;
    gap: 14px;
    align-items: end;
    padding: 20px;
}
.product-form {
    grid-template-columns: 120px minmax(160px,1fr) 130px 110px 130px auto;
}
.member-form {
    grid-template-columns: minmax(140px,1fr) minmax(140px,1fr) minmax(140px,1fr) auto;
}

/* ════════════════════════════════════════
   PRODUCT GRID (admin)
════════════════════════════════════════ */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.product-card {
    padding: 22px;
    transition: box-shadow .15s;
}
.product-card:hover { box-shadow: var(--shadow-md); }
.product-code {
    display: inline-flex;
    margin-bottom: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.product-card h2 { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.product-card strong {
    display: block;
    color: var(--primary);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.5px;
}
.product-card p { margin: 8px 0 0; color: var(--text-2); line-height: 1.6; font-size: 13px; }

/* ════════════════════════════════════════
   TABLE
════════════════════════════════════════ */
.license-table-wrap {
    overflow-x: auto;
    border-radius: var(--r-xl);
}
.license-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}
.license-table.compact  { min-width: 780px; }
.admin-license-table    { min-width: 980px; }
.member-license-table   { min-width: 480px; }

.license-table th {
    padding: 11px 14px;
    text-align: left;
    background: var(--line-soft);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.license-table th:first-child { border-radius: var(--r-xl) 0 0 0; }
.license-table th:last-child  { border-radius: 0 var(--r-xl) 0 0; }

.license-table tfoot th {
    background: var(--line-soft);
    border-top: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 0;
}

.license-table td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--line-soft);
    color: var(--text);
    font-size: 13.5px;
}
.license-table tbody tr:last-child td { border-bottom: 0; }
.license-table tbody tr:hover td { background: #f8fafc; }

.license-name { display: block; color: var(--primary); font-weight: 600; }
.status-text {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.actions-cell {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 120px;
}
.actions-cell form { margin: 0; }

.change-ip-form { display: flex; gap: 6px; align-items: center; }
.change-ip-form input { width: 136px; height: 30px; }

.admin-license-form {
    display: grid;
    grid-template-columns: 156px 144px 130px auto;
    gap: 6px;
    align-items: center;
}
.admin-license-form input,
.admin-license-form select { height: 30px; }

.invoice-action-form {
    display: grid;
    grid-template-columns: 120px auto;
    gap: 6px;
    align-items: center;
    min-width: 190px;
}
.invoice-action-form select { height: 30px; }
.invoice-sync-form { grid-template-columns: 1fr; margin-top: 6px; }

/* ════════════════════════════════════════
   PILLS
════════════════════════════════════════ */
.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    border: 1px solid transparent;
}
.pill + .pill { margin-left: 4px; }

.pill-single  { background: var(--success-soft); color: #14532d; border-color: #bbf7d0; }
.pill-pending { background: var(--warning-soft); color: #78350f; border-color: #fde68a; }
.pill-no      { background: var(--danger-soft);  color: #7f1d1d; border-color: #fecaca; }

/* ════════════════════════════════════════
   EXPIRED / EMPTY
════════════════════════════════════════ */
.is-expired td,
.is-expired .license-name { color: var(--danger); }

.empty-cell {
    padding: 28px 16px !important;
    color: var(--text-muted) !important;
    text-align: center !important;
    font-size: 13px;
}

/* ════════════════════════════════════════
   INVOICE (old layout — kept for compat)
════════════════════════════════════════ */
.invoice-layout {
    display: grid;
    grid-template-columns: minmax(0,1fr) 340px;
    gap: 18px;
    align-items: start;
}
.invoice-card { padding: 22px; }
.invoice-status { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.invoice-details { display: grid; gap: 0; margin: 0; }
.invoice-details div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
}
.invoice-details div:last-child { border-bottom: 0; }
.invoice-details dt { color: var(--text-2); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.invoice-details dd { margin: 0; color: var(--text); font-weight: 600; text-align: right; }

.qr-card { display: grid; gap: 14px; justify-items: center; text-align: center; }
.qris-image { width: min(240px,100%); aspect-ratio: 1; border: 8px solid #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-md); }

.paid-state { display: grid; gap: 8px; justify-items: center; padding: 28px 10px; }
.paid-state strong { color: var(--success); font-size: 18px; font-weight: 700; }
.failed-state strong { color: var(--danger); }
.paid-state span { color: var(--text-2); font-size: 13.5px; }

/* Hero panel */
.hero-panel { width: min(420px,100%); margin: 52px auto; padding: 34px; border: 0; box-shadow: var(--shadow-lg); }

/* ════════════════════════════════════════
   ANIMATIONS & MICRO-INTERACTIONS
════════════════════════════════════════ */

/* ── Keyframes ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0);    }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0);     }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0);     }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1);    }
}
@keyframes pulseRing {
    0%   { box-shadow: 0 0 0 0 rgba(37,99,235,.35); }
    70%  { box-shadow: 0 0 0 8px rgba(37,99,235,0); }
    100% { box-shadow: 0 0 0 0 rgba(37,99,235,0);   }
}

/* ── Page entrance ── */
.page-shell {
    animation: fadeInUp .38s cubic-bezier(.22,1,.36,1) both;
}
.app-header {
    animation: fadeIn .25s ease-out both;
}

/* ── Sidebar nav stagger (desktop) ── */
@media (min-width: 1101px) {
    .nav a {
        animation: slideInLeft .28s cubic-bezier(.22,1,.36,1) both;
    }
    .nav a:nth-child(2)  { animation-delay: .04s; }
    .nav a:nth-child(3)  { animation-delay: .08s; }
    .nav a:nth-child(4)  { animation-delay: .12s; }
    .nav a:nth-child(5)  { animation-delay: .16s; }
    .nav a:nth-child(6)  { animation-delay: .20s; }
}

/* ── Metric cards stagger ── */
.metric-grid .metric {
    animation: fadeInUp .38s cubic-bezier(.22,1,.36,1) both;
}
.metric-grid .metric:nth-child(1) { animation-delay: .06s; }
.metric-grid .metric:nth-child(2) { animation-delay: .12s; }
.metric-grid .metric:nth-child(3) { animation-delay: .18s; }
.metric-grid .metric:nth-child(4) { animation-delay: .24s; }

/* ── Cards entrance ── */
.license-table-wrap {
    animation: fadeInUp .38s cubic-bezier(.22,1,.36,1) .12s both;
}
.purchase-panel,
.product-grid,
.invoice-layout,
.inv-wrap,
.buy-layout {
    animation: fadeInUp .38s cubic-bezier(.22,1,.36,1) .08s both;
}
.section-head {
    animation: fadeIn .3s ease-out .04s both;
}

/* ── Alerts slide down ── */
.alert {
    animation: slideDown .3s cubic-bezier(.22,1,.36,1) both;
}

/* ── Table rows ── */
.license-table tbody tr {
    animation: fadeIn .25s ease-out both;
}
.license-table tbody tr:nth-child(1)  { animation-delay: .04s; }
.license-table tbody tr:nth-child(2)  { animation-delay: .08s; }
.license-table tbody tr:nth-child(3)  { animation-delay: .12s; }
.license-table tbody tr:nth-child(4)  { animation-delay: .16s; }
.license-table tbody tr:nth-child(5)  { animation-delay: .20s; }
.license-table tbody tr:nth-child(6)  { animation-delay: .22s; }
.license-table tbody tr:nth-child(n+7){ animation-delay: .24s; }

/* ── Product cards stagger (buy page) ── */
.buy-products .buy-product-card {
    animation: fadeInUp .32s cubic-bezier(.22,1,.36,1) both;
}
.buy-products .buy-product-card:nth-child(1) { animation-delay: .05s; }
.buy-products .buy-product-card:nth-child(2) { animation-delay: .12s; }
.buy-products .buy-product-card:nth-child(3) { animation-delay: .19s; }

/* ── Button interactions ── */
.primary-btn,
.table-btn,
.primary-link {
    position: relative;
    overflow: hidden;
}
.primary-btn::after,
.table-btn::after,
.primary-link::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.15);
    opacity: 0;
    transition: opacity .15s;
    border-radius: inherit;
}
.primary-btn:hover::after,
.table-btn:hover::after,
.primary-link:hover::after { opacity: 1; }

.primary-btn:active,
.table-btn:active,
.primary-link:active { transform: scale(.97); }

/* ── Metric card hover ── */
.metric {
    transition: transform .2s cubic-bezier(.22,1,.36,1),
                box-shadow .2s ease;
}
.metric:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

/* ── Product card hover (admin) ── */
.product-card {
    transition: transform .2s cubic-bezier(.22,1,.36,1),
                box-shadow .2s ease;
}
.product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

/* ── Input focus ── */
input, select {
    transition: border-color .18s ease,
                box-shadow .18s ease,
                background .18s ease;
}

/* ── Nav link hover ── */
.nav a {
    transition: background .15s ease,
                color .15s ease,
                transform .12s ease;
}
.nav a:hover { transform: translateX(3px); }
@media (max-width: 1100px) {
    .nav a:hover { transform: none; }
}

/* ── Logout link ── */
.logout-link {
    transition: border-color .15s, background .15s, color .15s, transform .12s;
}
.logout-link:hover { transform: translateY(-1px); }

/* ── User chip pulse on fresh login ── */
.user-chip .avatar { animation: scaleIn .4s cubic-bezier(.22,1,.36,1) .1s both; }

/* ── Sidebar brand ── */
.brand { animation: fadeIn .3s ease-out both; }

/* ── Auth card entrance ── */
.auth-card {
    animation: scaleIn .4s cubic-bezier(.22,1,.36,1) both;
}

/* ── Invoice detail rows stagger ── */
.inv-row {
    animation: fadeIn .25s ease-out both;
}
.inv-row:nth-child(1) { animation-delay: .08s; }
.inv-row:nth-child(2) { animation-delay: .14s; }
.inv-row:nth-child(3) { animation-delay: .20s; }
.inv-row:nth-child(4) { animation-delay: .26s; }

/* ── QR panel ── */
.inv-qr-panel { animation: scaleIn .35s cubic-bezier(.22,1,.36,1) .1s both; }
.inv-doc      { animation: fadeInUp .35s cubic-bezier(.22,1,.36,1) .04s both; }

/* ── Accessibility: respect reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-delay: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* ════════════════════════════════════════
   RESPONSIVE — Tablet (≤1100px)
════════════════════════════════════════ */
@media (max-width: 1100px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    /* Sidebar hanya setinggi kontennya — tidak stretch ke full viewport */
    .sidebar {
        position: relative;
        height: auto;
        align-self: start;
        overflow-x: hidden;
        overflow-y: visible;
        border-right: 0;
        border-bottom: 1px solid rgba(255,255,255,.08);
    }

    /* Brand lebih compact di mobile */
    .brand {
        height: 46px;
        padding: 0 14px;
        font-size: 14px;
    }
    .brand-mark { width: 28px; height: 28px; font-size: 10px; }
    .brand small { display: none; }

    /* Nav horizontal, hanya setinggi item */
    .nav {
        flex: 0 0 auto;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 6px 8px;
        gap: 2px;
        scrollbar-width: none;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav-label { display: none; }

    .nav a {
        height: 34px;
        min-height: unset;
        padding: 0 12px;
        white-space: nowrap;
        flex-shrink: 0;
        align-self: center;
        border-radius: var(--r-md);
        font-size: 13px;
    }
    .nav a::before { display: none; }
    .nav a.active  { background: rgba(37,99,235,.2); }

    .app-header { padding: 0 18px; }

    .metric-grid,
    .metric-grid.four,
    .product-grid,
    .invoice-layout {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }

    .product-form { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .member-form  { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ── Medium (≤860px) ── */
@media (max-width: 860px) {
    .app-header { padding: 0 16px; }
    .page-shell { width: calc(100% - 36px); margin: 18px auto; }

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

/* ── Mobile (≤640px) ── */
@media (max-width: 640px) {
    .app-header { height: 52px; padding: 0 14px; }
    .app-header strong { font-size: 13.5px; }
    .app-header span   { font-size: 11px; }

    .user-chip-info { display: none; }
    .user-chip { padding: 4px; }

    .logout-link { padding: 0 10px; font-size: 12px; height: 30px; }
    .logout-text { display: none; }

    .login-header { padding: 0 16px; }
    .page-shell { width: calc(100% - 28px); margin: 14px auto; }

    .metric-grid,
    .metric-grid.four { grid-template-columns: repeat(2, minmax(0,1fr)); }

    .product-grid { grid-template-columns: 1fr; }
    .invoice-layout { grid-template-columns: 1fr; }

    .buy-form,
    .product-form,
    .member-form { grid-template-columns: 1fr; }

    .section-head { margin-bottom: 14px; }
    .section-head h2 { font-size: 14px; }

    .auth-card { margin: 22px auto; padding: 26px 20px; }
    .hero-panel { margin: 22px auto; padding: 24px 18px; }
}

/* ── Small mobile (≤480px): icon-only nav ── */
@media (max-width: 480px) {
    .nav a {
        padding: 0 10px;
        gap: 0;
        font-size: 0;
        min-width: 40px;
        justify-content: center;
    }
    .nav a .material-symbols-rounded { font-size: 20px; }

    .brand { font-size: 14px; }
    .brand-mark { width: 28px; height: 28px; font-size: 10px; }
    .brand small { display: none; }

    .metric { padding: 16px; }
    .metric strong { font-size: 22px; }

    .table-btn { padding: 0 8px; font-size: 11px; }

    .license-table th,
    .license-table td { padding: 10px 10px; font-size: 12.5px; }
}
