:root {
    --bg:          #09090b; /* Zinc-950 */
    --surface:     #18181b; /* Zinc-900 */
    --surface-2:   #27272a; /* Zinc-800 */
    --surface-3:   #3f3f46; /* Zinc-700 */
    --border:      #27272a; /* Zinc-800 border */
    --border-2:    #3f3f46; /* Zinc-700 border */
    --text:        #fafafa; /* Zinc-50 */
    --text-muted:  #a1a1aa; /* Zinc-400 */
    --accent:      #4f46e5; /* Sleek Indigo-600 */
    --accent-hover: #4338ca;
    --success:     #10b981; /* Emerald-500 */
    --danger:      #ef4444; /* Red-500 */
    --warning:     #f59e0b; /* Amber-500 */
    --font-mono:   ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover {
    color: var(--text);
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
}
::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* ---------- Loading Screen ---------- */
.loading-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg);
}
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--surface-2);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading-text {
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}
.loading-sub {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    max-width: 400px;
    line-height: 1.6;
}
.loading-sub .btn {
    margin-top: 12px;
}
@keyframes spin { 
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ---------- Dashboard Grid Layout ---------- */
.dashboard {
    display: grid;
    grid-template-columns: 240px 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}
.nav-item:hover {
    color: var(--text);
    background: var(--surface-2);
}
.nav-item.active {
    background: var(--surface-2);
    color: var(--text);
}
.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: var(--text-muted);
    transition: stroke 0.15s ease;
}
.nav-item:hover svg,
.nav-item.active svg {
    stroke: var(--text);
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
}
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Main Workspace ---------- */
.main-content {
    padding: 32px 40px;
    overflow-y: auto;
}

.section {
    animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}
.section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}
.section-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.subsection-header {
    margin: 28px 0 14px;
}
.subsection-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 16px;
    padding: 0 6px;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.subsection-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 24px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.subsection-title code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--accent);
}

/* ---------- Stats Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
}
.stat-icon svg {
    width: 20px;
    height: 20px;
}
.stat-info {
    display: flex;
    flex-direction: column;
}
.stat-value {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text);
}
.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---------- Data Tables ---------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}
.data-table thead th {
    font-weight: 500;
    color: var(--text-muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.01);
}
.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}
.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.015);
}

.license-key-text {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    user-select: all;
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.actions-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ---------- State Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}
.badge-active   { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-banned   { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-admin    { background: rgba(79, 70, 229, 0.1); color: var(--accent); }
.badge-user     { background: var(--surface-2); color: var(--text-muted); }
.badge-unused   { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.badge-used     { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-revoked  { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-expired  { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

.live-tail-status {
    color: var(--success);
    font-size: 11px;
    font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.1s ease;
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    outline: none;
}
.btn:hover {
    background: var(--surface-3);
    border-color: var(--border-2);
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--surface-2);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
}

/* ---------- Form Inputs ---------- */
.search-input, .duration-select, .text-input, .textarea-input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.15s ease;
}
.search-input:focus,
.duration-select:focus,
.text-input:focus,
.textarea-input:focus {
    border-color: var(--border-2);
}
.textarea-input {
    resize: vertical;
    min-height: 80px;
}
.duration-select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23a1a1aa' d='M0 0l5 6 5-6z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.field-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.field-group {
    margin-bottom: 16px;
}

/* ---------- Modals ---------- */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(9, 9, 11, 0.7);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    width: min(440px, 94vw);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.modal-content h3 {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.modal-content p {
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Modal details styling */
.key-display {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text);
    word-break: break-all;
    user-select: all;
    margin-bottom: 16px;
}
.key-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    font-size: 12px;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.key-meta > span:nth-child(odd) { color: var(--text-muted); }
.key-meta > span:nth-child(even) { color: var(--text); font-weight: 500; }

.bulk-keys-box {
    width: 100%;
    min-height: 160px;
    max-height: 260px;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}
.bulk-keys-box:focus {
    border-color: var(--border-2);
}

.ban-details-email {
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 16px;
    font-size: 13px;
}
.ban-details-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    font-size: 13px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.ban-details-label { color: var(--text-muted); }
.ban-details-value { color: var(--text); font-weight: 500; }
.ban-details-description {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin-top: 4px;
    white-space: pre-wrap;
    max-height: 160px;
    overflow-y: auto;
}
.ban-details-notes {
    font-size: 13px;
    line-height: 1.5;
    color: var(--warning);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin-top: 4px;
    white-space: pre-wrap;
    max-height: 150px;
    overflow-y: auto;
}

/* ---------- Toasts ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1100;
    pointer-events: none;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 1;
    transition: opacity 0.2s;
    pointer-events: auto;
    max-width: 360px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--accent); }

/* ---------- Form Containers ---------- */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin: 12px 0 4px;
}
.form-input, .form-textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}
.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}
.form-input:focus, .form-textarea:focus {
    border-color: var(--border-2);
}
.form-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.form-row .form-input {
    flex: 1;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}
.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.checkbox-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.modal-wide {
    max-width: 560px !important;
    width: 94%;
}

/* ---------- Update Stepper ---------- */
.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 24px;
    padding: 0;
    list-style: none;
}

.stepper .step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    position: relative;
}

.stepper .step .step-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.stepper .step .step-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.stepper .step.active .step-circle {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}
.stepper .step.active .step-label {
    color: var(--text);
}

.stepper .step.done .step-circle {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
    color: var(--success);
}
.stepper .step.done .step-label {
    color: var(--success);
}

.stepper .step-connector {
    height: 2px;
    background: var(--border);
    flex: 1;
}
.stepper .step-connector.done { background: var(--success); }
.stepper .step-connector.active { background: var(--accent); }

.stepper-step-panel {
    display: none;
}
.stepper-step-panel.active {
    display: block;
}

.stepper-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.stepper-review-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    margin-bottom: 6px;
}
.stepper-review-row .review-label {
    color: var(--text-muted);
    font-size: 12px;
}
.stepper-review-row .review-value {
    color: var(--text);
    font-weight: 500;
    font-family: var(--font-mono);
}

.stepper-status-info {
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
    margin-bottom: 16px;
    line-height: 1.5;
}
.stepper-status-info strong {
    color: #ffffff;
}

/* ---------- Notification Toast ---------- */
#update-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 14px 18px;
    width: 320px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}
#update-notification .update-notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
#update-notification .update-notif-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
#update-notification .update-notif-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
}
#update-notification .update-notif-close:hover { color: var(--text); }
#update-notification .update-notif-body {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 12px;
}
#update-notification .update-notif-actions {
    display: flex;
    gap: 8px;
}
#update-notification .update-notif-actions .btn {
    flex: 1;
    font-size: 12px;
    padding: 6px 10px;
}

/* ---------- Status Page Bars Redesign ---------- */
.status-components-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 28px;
}

.status-component {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.status-component-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-component-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-component-status {
    font-size: 12px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
}
.status-operational {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}
.status-degraded {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}
.status-outage {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}
.status-unknown {
    background: var(--surface-2);
    color: var(--text-muted);
}

.status-bars-container {
    display: flex;
    gap: 3px;
    height: 28px;
    align-items: stretch;
}

.status-bar {
    flex: 1;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    transition: opacity 0.15s ease, transform 0.1s ease;
}
.status-bar:hover {
    opacity: 0.85;
    transform: scaleY(1.08);
}

.status-bar-green  { background: #10b981; }
.status-bar-yellow { background: #f59e0b; }
.status-bar-red    { background: #ef4444; }
.status-bar-gray   { background: var(--surface-3); }

/* Custom tooltips */
.status-bar::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: #18181b;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.4;
    white-space: pre;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 100;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}
.status-bar::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 6px solid transparent;
    border-top-color: #18181b;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 100;
    pointer-events: none;
}
.status-bar:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-6px);
}
.status-bar:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(2px);
}

.status-component-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    position: relative;
    margin-top: 4px;
}
.status-component-footer::before {
    content: '';
    position: absolute;
    left: 80px;
    right: 50px;
    top: 50%;
    height: 1px;
    background: var(--border);
    z-index: 1;
}
.status-component-footer span {
    background: var(--surface);
    padding: 0 8px;
    z-index: 2;
}