/* ==========================================================================
   Nuke AI Hub — Admin Dashboard
   Dark cinematic theme · Catppuccin Mocha palette · Pure CSS
   ========================================================================== */

/* --- Palette & Tokens -------------------------------------------------- */
:root {
    --crust:    #11111b;
    --mantle:   #181825;
    --base:     #1e1e2e;
    --surface0: #313244;
    --surface1: #45475a;
    --surface2: #585b70;
    --overlay0: #6c7086;
    --overlay1: #7f849c;
    --text:     #cdd6f4;
    --subtext0: #a6adc8;
    --subtext1: #bac2de;
    --blue:     #89b4fa;
    --green:    #a6e3a1;
    --red:      #f38ba8;
    --yellow:   #f9e2af;
    --peach:    #fab387;
    --mauve:    #cba6f7;
    --teal:     #94e2d5;

    --sidebar-w: 232px;
    --radius:    8px;
    --radius-sm: 5px;
    --transition: 0.15s ease;
    --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", "SF Mono", monospace;
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --space-xs:  8px;
    --space-sm:  14px;
    --space-md:  24px;
    --space-lg:  28px;
    --space-xl:  36px;
}

/* --- Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    background: var(--base);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: #a8cbfc; text-decoration: none; }

ul, ol { list-style: none; }

/* --- Layout ------------------------------------------------------------ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar ----------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(180deg, #1a1a2e 0%, var(--mantle) 40%, #161624 100%);
    border-right: 1px solid rgba(69, 71, 90, 0.5);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 22px 16px;
    border-bottom: 1px solid rgba(69, 71, 90, 0.4);
    position: relative;
}

/* subtle glow line under header */
.sidebar-header::after {
    content: "";
    position: absolute;
    bottom: -1px; left: 22px; right: 22px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(137, 180, 250, 0.25), transparent);
}

.sidebar-logo {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: 0.03em;
    line-height: 1.2;
}

.sidebar-subtitle {
    display: block;
    font-size: 0.72rem;
    color: var(--overlay0);
    letter-spacing: 0.04em;
    margin-top: 3px;
}

/* Sidebar brand (alternate class from original) */
.sidebar-brand {
    padding: 20px 22px 16px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: 0.03em;
    border-bottom: 1px solid rgba(69, 71, 90, 0.4);
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav li { margin: 1px 0; }

.sidebar-nav a,
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 22px;
    color: var(--subtext0);
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition);
    position: relative;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav .nav-link:hover {
    background: rgba(137, 180, 250, 0.04);
    color: var(--text);
}

.sidebar-nav a.active,
.sidebar-nav .nav-link.active {
    color: var(--blue);
    border-left-color: var(--blue);
    background: rgba(137, 180, 250, 0.07);
}

/* Glow behind active item */
.sidebar-nav a.active::before,
.sidebar-nav .nav-link.active::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 50%;
    background: radial-gradient(ellipse at left center, rgba(137, 180, 250, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.sidebar-nav .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav a.active .nav-icon,
.sidebar-nav .nav-link.active .nav-icon {
    opacity: 1;
}

.sidebar-section {
    padding: 20px 22px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--overlay0);
}

.sidebar-footer {
    padding: 14px 22px;
    border-top: 1px solid rgba(69, 71, 90, 0.4);
}

.sidebar-footer .nav-link,
.sidebar-footer a {
    color: var(--overlay1);
    font-size: 0.82rem;
    padding: 6px 0;
    display: block;
    border-left: none;
}

.sidebar-footer a:hover { color: var(--red); }

.logout-link { color: var(--overlay1) !important; }
.logout-link:hover { color: var(--red) !important; }

/* --- Main content area ------------------------------------------------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--base);
}

.content {
    flex: 1;
    padding: var(--space-lg);
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}

/* --- Page titles ------------------------------------------------------- */
.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--space-md);
    letter-spacing: -0.01em;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: var(--space-md);
}

.page-header h1,
.page-header h2 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.page-header p {
    color: var(--subtext0);
    font-size: 0.88rem;
    margin-top: 4px;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--subtext1);
    margin: var(--space-lg) 0 var(--space-sm);
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(69, 71, 90, 0.35);
}

/* --- Stat cards -------------------------------------------------------- */
.card-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: var(--space-md);
}

.stat-card {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: 20px 22px;
    border-top: 3px solid var(--blue);
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

/* Color variants via nth-child for dashboard rows */
.card-row .stat-card:nth-child(3) { border-top-color: var(--teal); }
.card-row .stat-card:nth-child(4) { border-top-color: var(--peach); }
.card-row + .card-row .stat-card:nth-child(1) { border-top-color: var(--green); }
.card-row + .card-row .stat-card:nth-child(2) { border-top-color: var(--mauve); }
.card-row + .card-row .stat-card:nth-child(3) { border-top-color: var(--yellow); }
.card-row + .card-row .stat-card:nth-child(4) { border-top-color: var(--red); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--overlay1);
    margin-top: 8px;
}

/* Status dot inside stat cards */
.status-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-online  { background: var(--green); box-shadow: 0 0 8px rgba(166, 227, 161, 0.5); }
.status-offline { background: var(--red); box-shadow: 0 0 8px rgba(243, 139, 168, 0.4); }

/* --- Generic cards (legacy compat) ------------------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: var(--space-lg);
}

.card {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid transparent;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    border-color: var(--surface1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
}

.card-label {
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--overlay1);
    margin-bottom: 8px;
}

.card-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.card-value.blue   { color: var(--blue); }
.card-value.green  { color: var(--green); }
.card-value.red    { color: var(--red); }
.card-value.yellow { color: var(--yellow); }
.card-value.peach  { color: var(--peach); }
.card-value.mauve  { color: var(--mauve); }

.card-footer {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--subtext0);
}

/* --- Panels ------------------------------------------------------------ */
.panel {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

/* --- Config sections --------------------------------------------------- */
.config-section {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.config-section .section-title {
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: var(--space-sm);
}

/* --- Tables ------------------------------------------------------------ */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table,
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table thead th,
thead th {
    text-align: left;
    padding: 11px 16px;
    font-weight: 600;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--overlay1);
    border-bottom: 2px solid var(--surface1);
    white-space: nowrap;
    background: transparent;
}

.data-table tbody td,
tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid rgba(49, 50, 68, 0.6);
    color: var(--subtext1);
    transition: background var(--transition);
}

.data-table tbody tr:hover,
tbody tr:hover {
    background: rgba(137, 180, 250, 0.04);
}

/* No zebra striping -- clean horizontal lines only */
.data-table tbody tr:nth-child(even),
tbody tr:nth-child(even) {
    background: transparent;
}
.data-table tbody tr:nth-child(even):hover,
tbody tr:nth-child(even):hover {
    background: rgba(137, 180, 250, 0.04);
}

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

/* Monospace cells */
td.mono, .mono {
    font-family: var(--font-mono);
    font-size: 0.82em;
    letter-spacing: -0.01em;
}

/* --- Badges ------------------------------------------------------------ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    padding: 3px 11px;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.badge::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge.green,
.badge-ok          { color: var(--green); background: rgba(166, 227, 161, 0.1); }
.badge.green::before,
.badge-ok::before  { background: var(--green); }

.badge.yellow          { color: var(--yellow); background: rgba(249, 226, 175, 0.1); }
.badge.yellow::before  { background: var(--yellow); }

.badge.red,
.badge-off          { color: var(--red); background: rgba(243, 139, 168, 0.1); }
.badge.red::before,
.badge-off::before  { background: var(--red); }

.badge.blue          { color: var(--blue); background: rgba(137, 180, 250, 0.1); }
.badge.blue::before  { background: var(--blue); }

.badge-tier {
    color: var(--mauve);
    background: rgba(203, 166, 247, 0.1);
}
.badge-tier::before { background: var(--mauve); }

/* Dot indicators */
.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    vertical-align: middle;
}
.dot.green  { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.red    { background: var(--red); }

/* --- Token bar --------------------------------------------------------- */
.token-bar-container {
    width: 100%;
    height: 6px;
    background: var(--surface1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.token-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--teal));
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.token-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--teal));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.token-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--subtext0);
}

/* --- Forms ------------------------------------------------------------- */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--subtext1);
    margin-bottom: 6px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-row .form-group {
    flex: 1;
    min-width: 160px;
}

.form-group-btn {
    display: flex;
    gap: 8px;
    padding-bottom: 18px;
}

.form-input,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--crust);
    border: 1px solid var(--surface1);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(137, 180, 250, 0.12), 0 0 12px rgba(137, 180, 250, 0.06);
}

input::placeholder,
textarea::placeholder {
    color: var(--overlay0);
}

textarea {
    resize: vertical;
    min-height: 80px;
    font-family: var(--font-sans);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%237f849c'%3E%3Cpath d='M6 8.5L1 3.5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* Inline form */
.inline-form {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border: 1px solid var(--surface1);
}

/* Key display */
.key-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--crust);
    border: 1px solid var(--surface1);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin: 12px 0 8px;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--green);
    word-break: break-all;
}

.key-display span { flex: 1; }

.key-warning {
    color: var(--yellow);
    font-size: 0.82rem;
    font-weight: 500;
}

/* --- Buttons ----------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    font-size: 0.86rem;
    font-weight: 600;
    font-family: var(--font-sans);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--blue);
    color: var(--crust);
}
.btn-primary:hover {
    background: #9fc5fc;
    box-shadow: 0 2px 12px rgba(137, 180, 250, 0.25);
}

.btn-danger {
    background: var(--red);
    color: var(--crust);
}
.btn-danger:hover {
    background: #f5a0b6;
    box-shadow: 0 2px 12px rgba(243, 139, 168, 0.2);
}

.btn-success {
    background: var(--green);
    color: var(--crust);
}

.btn-secondary,
.btn-ghost {
    background: transparent;
    color: var(--subtext0);
    border: 1px solid var(--surface1);
}

.btn-secondary:hover,
.btn-ghost:hover {
    background: var(--surface0);
    color: var(--text);
    border-color: var(--surface2);
}

.btn-secondary.active {
    background: rgba(137, 180, 250, 0.12);
    color: var(--blue);
    border-color: rgba(137, 180, 250, 0.3);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* --- Filter bar -------------------------------------------------------- */
.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* --- Toggle switch ----------------------------------------------------- */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 40px; height: 22px;
    background: var(--surface1);
    border-radius: 11px;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle-slider::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: var(--text);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle input:checked + .toggle-slider {
    background: var(--blue);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(18px);
    background: var(--crust);
}

.toggle-label {
    font-size: 0.88rem;
    color: var(--subtext1);
}

/* --- Login page -------------------------------------------------------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--crust);
    background-image:
        radial-gradient(ellipse 600px 400px at 30% 20%, rgba(137, 180, 250, 0.04), transparent),
        radial-gradient(ellipse 500px 350px at 70% 80%, rgba(203, 166, 247, 0.03), transparent);
}

/* Also support .login-page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--crust);
}

.login-card {
    background: var(--surface0);
    border-radius: 12px;
    padding: 44px 38px 38px;
    width: 100%;
    max-width: 390px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(69, 71, 90, 0.4);
    position: relative;
    overflow: hidden;
}

/* Animated gradient border glow */
.login-card::before {
    content: "";
    position: absolute;
    top: -1px; left: -1px; right: -1px;
    height: 3px;
    background: linear-gradient(90deg, var(--blue), var(--mauve), var(--teal), var(--blue));
    background-size: 300% 100%;
    animation: loginGlow 6s linear infinite;
    border-radius: 12px 12px 0 0;
}

@keyframes loginGlow {
    0%   { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

.login-title,
.login-card h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--blue);
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.login-card .login-subtitle {
    text-align: center;
    color: var(--overlay1);
    font-size: 0.85rem;
    margin-bottom: var(--space-lg);
}

.login-card .btn {
    width: 100%;
    margin-top: 8px;
    padding: 11px 20px;
}

.login-error {
    background: rgba(243, 139, 168, 0.08);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border-left: 3px solid var(--red);
}

/* --- Log viewer -------------------------------------------------------- */
.log-viewer {
    background: var(--crust);
    border: 1px solid rgba(49, 50, 68, 0.5);
    border-radius: var(--radius);
    padding: 18px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    line-height: 1.75;
    color: var(--subtext0);
    overflow-x: auto;
    max-height: 560px;
    overflow-y: auto;
    white-space: pre;
}

.log-line {
    padding: 1px 0 1px 10px;
    border-left: 2px solid transparent;
    transition: background var(--transition);
}

.log-line:hover {
    background: rgba(137, 180, 250, 0.03);
}

.log-line.log-error,
.log-viewer .log-error {
    color: var(--red);
    border-left-color: var(--red);
}

.log-line.log-warn,
.log-line.log-warning,
.log-viewer .log-warning {
    color: var(--yellow);
    border-left-color: var(--yellow);
}

.log-line.log-info,
.log-viewer .log-info {
    color: var(--blue);
    border-left-color: var(--blue);
}

/* --- Modal ------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 17, 27, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFadeIn 0.2s ease;
}

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

.modal {
    background: var(--surface0);
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(69, 71, 90, 0.4);
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    color: var(--overlay1);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all var(--transition);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
    background: var(--surface1);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: var(--space-md);
    padding-top: 16px;
    border-top: 1px solid rgba(69, 71, 90, 0.35);
}

/* --- Cost calculator --------------------------------------------------- */
.calc-result {
    background: var(--crust);
    border: 1px solid var(--surface1);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.92rem;
    color: var(--subtext1);
}

.calc-result strong {
    color: var(--green);
    font-family: var(--font-mono);
}

.calc-sep {
    color: var(--surface2);
}

/* --- Utility classes --------------------------------------------------- */
.text-muted  { color: var(--overlay1); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue   { color: var(--blue); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.mono {
    font-family: var(--font-mono);
    font-size: 0.85em;
}

/* --- Scrollbar (Webkit) ------------------------------------------------ */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface2); }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--surface1) transparent; }

/* --- Animations -------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease forwards; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.pulse { animation: pulse 2s ease-in-out infinite; }

/* --- Menu toggle (mobile) ---------------------------------------------- */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
}

/* --- Responsive -------------------------------------------------------- */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 232px;
    }

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

    .main { margin-left: 0; }

    .card-row,
    .card-grid { grid-template-columns: 1fr 1fr; }

    .content { padding: 18px; }

    .menu-toggle { display: block !important; }

    .form-row { flex-direction: column; }

    .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .card-row,
    .card-grid { grid-template-columns: 1fr; }

    .login-card {
        margin: 0 16px;
        padding: 28px 22px;
    }
}

/* --- Topbar (legacy compat) -------------------------------------------- */
.topbar {
    height: 56px;
    background: var(--mantle);
    border-bottom: 1px solid rgba(69, 71, 90, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-actions a {
    color: var(--subtext0);
    font-size: 0.85rem;
    transition: color var(--transition);
}

.topbar-actions a:hover { color: var(--text); }
