@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-blue: #0088cc;
    --accent-light: #00aaff;
    --accent-glow: rgba(0, 136, 204, 0.3);
    --border-color: #30363d;
    --green: #238636;
    --green-bg: rgba(35, 134, 54, 0.15);
    --red: #da3633;
    --red-bg: rgba(218, 54, 51, 0.15);
    --yellow: #d29922;
    --yellow-bg: rgba(210, 153, 34, 0.15);
    --orange: #db6d28;
    --orange-bg: rgba(219, 109, 40, 0.15);
    --gray: #6e7681;
    --gray-bg: rgba(110, 118, 129, 0.15);
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        linear-gradient(rgba(0, 136, 204, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 136, 204, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: -1;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-logo {
    width: 140px;
    height: auto;
    display: block;
    margin-bottom: 0.25rem;
}
.login-logo {
    width: 200px;
    height: auto;
    display: block;
    margin: 0 auto 0.5rem;
}
.customer-name {
    display: block;
    font-size: .85rem;
    color: var(--text-secondary);
    margin-top: .25rem;
}
.nav-links {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
}
.nav-links a {
    display: block;
    padding: .75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .95rem;
    font-weight: 500;
    transition: color 0.2s ease, background 0.2s ease;
}
.nav-links a:hover {
    color: var(--accent-light);
    background: rgba(0, 136, 204, 0.08);
}
.nav-links a.active {
    color: var(--accent-light);
    background: rgba(0, 136, 204, 0.12);
    border-left: 3px solid var(--accent-blue);
}
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .8rem;
}
.version { color: var(--text-muted); }
.logout-link { color: var(--text-muted); text-decoration: none; transition: color 0.2s ease; }
.logout-link:hover { color: var(--accent-light); }

/* Main content */
.content {
    margin-left: 240px;
    padding: 2rem;
    flex: 1;
    max-width: 1200px;
}
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}
.domain-badge {
    background: rgba(0, 136, 204, 0.15);
    color: var(--accent-light);
    padding: .25rem .75rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 500;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--gray);
    transition: border-color 0.3s ease;
}
.stat-running { border-left-color: var(--green); }
.stat-stopped { border-left-color: var(--red); }
.stat-total { border-left-color: var(--accent-blue); }
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.stat-running .stat-value { background: var(--green); -webkit-background-clip: text; background-clip: text; }
.stat-stopped .stat-value { background: var(--red); -webkit-background-clip: text; background-clip: text; }
.stat-label {
    color: var(--text-secondary);
    font-size: .85rem;
    margin-top: .25rem;
}

/* System info bar */
.system-info-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}
.system-info-items {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}
.system-info-item {
    flex: 1;
    min-width: 200px;
}
.system-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .5rem;
}
.system-info-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.system-info-value {
    font-size: .8rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}
.system-bar {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    position: relative;
    background: linear-gradient(to right,
        rgba(35, 134, 54, 0.10) 0%, rgba(35, 134, 54, 0.10) 70%,
        rgba(210, 153, 34, 0.18) 70%, rgba(210, 153, 34, 0.18) 85%,
        rgba(218, 54, 51, 0.18) 85%, rgba(218, 54, 51, 0.18) 100%
    );
}
.system-bar::before {
    content: '';
    position: absolute;
    left: 70%;
    top: -1px;
    bottom: -1px;
    width: 2px;
    background: var(--yellow);
    border-radius: 1px;
    opacity: 0.5;
    z-index: 2;
}
.system-bar::after {
    content: '';
    position: absolute;
    left: 85%;
    top: -1px;
    bottom: -1px;
    width: 2px;
    background: var(--red);
    border-radius: 1px;
    opacity: 0.5;
    z-index: 2;
}
.system-bar-fill {
    height: 100%;
    border-radius: 5px;
    position: relative;
    z-index: 1;
    transition: width 0.3s ease;
    min-width: 3px;
}
.system-bar-green { background: var(--green); box-shadow: 0 0 6px rgba(35, 134, 54, 0.4); }
.system-bar-yellow { background: var(--yellow); box-shadow: 0 0 6px rgba(210, 153, 34, 0.4); }
.system-bar-red { background: var(--red); box-shadow: 0 0 6px rgba(218, 54, 51, 0.4); }

/* Stack list (dashboard) */
.stack-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.stack-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.3s ease, transform 0.2s ease;
}
.stack-card:hover {
    border-color: var(--accent-blue);
}
.stack-state-green { border-left-color: var(--green); }
.stack-state-red { border-left-color: var(--red); }
.stack-state-yellow { border-left-color: var(--yellow); }
.stack-state-orange { border-left-color: var(--orange); }
.stack-state-gray { border-left-color: var(--gray); }
.stack-info {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.stack-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
    background: var(--bg-secondary);
    padding: 4px;
}
.stack-logo-lg {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: contain;
    background: var(--bg-secondary);
    padding: 6px;
}
.stack-name { font-size: 1rem; font-weight: 500; }
.stack-desc { display: block; font-size: .8rem; color: var(--text-secondary); }
.stack-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.stack-state-label {
    font-size: .8rem;
    color: var(--text-secondary);
    margin-right: .5rem;
}

/* Stack detail grid (applications page) */
.stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}
.stack-detail-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-top: 4px solid var(--gray);
    transition: border-color 0.3s ease, transform 0.3s ease;
}
.stack-detail-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}
.stack-detail-card.stack-state-green { border-top-color: var(--green); }
.stack-detail-card.stack-state-red { border-top-color: var(--red); }
.stack-detail-card.stack-state-orange { border-top-color: var(--orange); }
.stack-detail-card.stack-state-yellow { border-top-color: var(--yellow); }
.stack-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: .75rem;
}
.stack-title-row {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.subdomain-link {
    font-size: .8rem;
    color: var(--accent-light);
    text-decoration: none;
    transition: color 0.2s ease;
}
.subdomain-link:hover { text-decoration: underline; }
.stack-state-badge {
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.state-green { background: var(--green-bg); color: var(--green); }
.state-red { background: var(--red-bg); color: var(--red); }
.state-yellow { background: var(--yellow-bg); color: var(--yellow); }
.state-orange { background: var(--orange-bg); color: var(--orange); }
.state-gray { background: var(--gray-bg); color: var(--gray); }
.state-text-green { color: var(--green); }
.state-text-red { color: var(--red); }
.state-text-orange { color: var(--orange); }
.state-text-yellow { color: var(--yellow); }
.stack-detail-desc {
    color: var(--text-secondary);
    font-size: .85rem;
    margin-bottom: .75rem;
}
.stack-meta-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin: .5rem 0;
}
.meta-badge {
    background: rgba(0, 136, 204, 0.1);
    color: var(--text-secondary);
    padding: .15rem .5rem;
    border-radius: 6px;
    font-size: .75rem;
}
.meta-badge-ok {
    background: var(--green-bg);
    color: var(--green);
}
.container-list { margin: .75rem 0; }
.container-list h4 { font-size: .8rem; color: var(--text-muted); margin-bottom: .4rem; }
.container-row {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    padding: .3rem 0;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}
.container-row:last-child { border-bottom: none; }
.container-name { font-family: 'JetBrains Mono', monospace; color: var(--text-secondary); }
.container-status { font-size: .75rem; }
.stack-detail-actions {
    display: flex;
    gap: .5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #fff;
    font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.loading { opacity: .6; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-lg { padding: .65rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-light));
    box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 20px var(--accent-glow); }
.btn-success { background: var(--green); }
.btn-success:hover { box-shadow: 0 4px 12px rgba(35, 134, 54, 0.3); }
.btn-warning { background: var(--yellow); color: #0d1117; }
.btn-danger { background: var(--red); }
.btn-danger:hover { box-shadow: 0 4px 12px rgba(218, 54, 51, 0.3); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--accent-blue);
    color: var(--accent-light);
    background: rgba(0, 136, 204, 0.08);
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
}
.badge-protected {
    background: var(--gray-bg);
    color: var(--text-muted);
}

/* Deploy page */
.deploy-container { max-width: 700px; }
.deploy-info {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.deploy-logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: contain;
    background: var(--bg-secondary);
    padding: 8px;
    flex-shrink: 0;
}
.deploy-info h3 { font-size: 1.2rem; margin-bottom: .25rem; }
.deploy-info p { color: var(--text-secondary); font-size: .9rem; }
.deploy-form {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}
.form-section { margin-bottom: 1.5rem; }
.form-section h4 { font-size: 1rem; margin-bottom: .5rem; color: var(--text-primary); }
.form-section-desc { color: var(--text-secondary); font-size: .85rem; margin-bottom: .75rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .4rem; color: var(--text-primary); }
.form-group-auto {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem .75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.form-group-auto label { margin: 0; }
.auto-generated-badge { color: var(--green); font-size: .8rem; font-weight: 500; }
.form-control {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: .9rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control:disabled {
    background: var(--bg-primary);
    color: var(--text-muted);
    cursor: not-allowed;
}
select.form-control { appearance: auto; }
select.form-control option { background: var(--bg-secondary); color: var(--text-primary); }
.input-with-button { display: flex; gap: .5rem; }
.input-with-button .form-control { flex: 1; }
.form-hint { display: block; font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.required { color: var(--red); }
.locked-hint { font-size: .75rem; color: var(--text-muted); font-weight: 400; margin-left: .5rem; }
.deploy-actions {
    display: flex;
    gap: .75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Deploy progress */
.deploy-progress {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.deploy-progress h3 {
    margin-bottom: 0.5rem;
}
.deploy-steps {
    margin: 1rem 0;
}
.deploy-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: .95rem;
    color: var(--text-muted);
}
.deploy-step.active {
    color: var(--text-primary);
}
.deploy-step.done {
    color: var(--text-primary);
}
.deploy-step.done .step-icon {
    color: var(--green);
}
.deploy-step.error .step-icon {
    color: var(--red);
}
.deploy-step.warn .step-icon {
    color: var(--yellow);
}
.step-icon {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}
.deploy-elapsed {
    color: var(--text-muted);
    font-size: .85rem;
    margin-top: 0.5rem;
}

/* Toggle switch */
.toggle { cursor: pointer; display: flex; align-items: center; gap: .5rem; }
.toggle input[type="checkbox"] { accent-color: var(--accent-blue); }
.toggle-label { font-size: .9rem; color: var(--text-secondary); }

/* Alerts */
.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .85rem;
    border: 1px solid;
}
.alert-error {
    background: var(--red-bg);
    color: var(--red);
    border-color: rgba(218, 54, 51, 0.3);
}
.alert-info {
    background: rgba(0, 136, 204, 0.1);
    color: var(--accent-light);
    border-color: rgba(0, 136, 204, 0.3);
}
.alert-warning {
    background: var(--yellow-bg);
    color: var(--yellow);
    border-color: rgba(210, 153, 34, 0.3);
}

/* Memory summary on deploy page */
.memory-summary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.memory-blocked {
    border-color: rgba(218, 54, 51, 0.5);
}
.memory-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.memory-summary-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
}
.memory-summary-value {
    font-size: .8rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}
.memory-bar-stacked {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    display: flex;
    overflow: hidden;
    position: relative;
    background: linear-gradient(to right,
        rgba(35, 134, 54, 0.10) 0%, rgba(35, 134, 54, 0.10) 70%,
        rgba(210, 153, 34, 0.18) 70%, rgba(210, 153, 34, 0.18) 85%,
        rgba(218, 54, 51, 0.18) 85%, rgba(218, 54, 51, 0.18) 100%
    );
}
.memory-bar-stacked::before {
    content: '';
    position: absolute;
    left: 70%;
    top: -1px;
    bottom: -1px;
    width: 2px;
    background: var(--yellow);
    border-radius: 1px;
    opacity: 0.5;
    z-index: 2;
}
.memory-bar-stacked::after {
    content: '';
    position: absolute;
    left: 85%;
    top: -1px;
    bottom: -1px;
    width: 2px;
    background: var(--red);
    border-radius: 1px;
    opacity: 0.5;
    z-index: 2;
}
.memory-bar-segment {
    height: 100%;
    position: relative;
    z-index: 1;
    transition: width 0.3s ease;
}
.memory-bar-segment:not([style*="width:0%"]) {
    min-width: 3px;
}
.memory-bar-committed {
    background: var(--green);
    box-shadow: 0 0 6px rgba(35, 134, 54, 0.4);
    border-radius: 5px 0 0 5px;
}
.memory-bar-new {
    background: rgba(35, 134, 54, 0.45);
    border-right: 2px solid #4edf72;
    border-radius: 0 5px 5px 0;
}
.memory-bar-legend {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.5rem;
}
.memory-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: .75rem;
    color: var(--text-secondary);
}
.memory-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}
.memory-legend-committed {
    background: var(--green);
}
.memory-legend-new {
    background: rgba(35, 134, 54, 0.45);
    border: 1px solid #4edf72;
}

/* Logs */
.logs-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    margin-bottom: 1rem;
}
.logs-output {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: .8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}
.logs-actions {
    display: flex;
    gap: .5rem;
    align-items: center;
}
.logs-live-indicator {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--green);
    margin-right: .5rem;
}
.logs-live-indicator.logs-live-paused {
    color: var(--text-muted);
}
.logs-live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: logs-pulse 1.5s ease-in-out infinite;
}
@keyframes logs-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Sync toast */
.sync-toast {
    padding: .6rem 1rem;
    border-radius: 8px;
    font-size: .85rem;
    margin-bottom: 1rem;
    border: 1px solid;
    transition: opacity 0.3s ease;
}
.sync-toast-ok {
    background: var(--green-bg);
    color: var(--green);
    border-color: rgba(35, 134, 54, 0.3);
}
.sync-toast-err {
    background: var(--red-bg);
    color: var(--red);
    border-color: rgba(218, 54, 51, 0.3);
}

/* --- Filter bar --- */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

.filter-count {
    opacity: 0.7;
    font-size: 0.8rem;
}

/* Clickable stat cards */
a.stat-card {
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}

a.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Clickable cards */
[data-href] { cursor: pointer; }

.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }

/* Login page */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-primary);
}
.login-body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image:
        linear-gradient(rgba(0, 136, 204, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 136, 204, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}
.login-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 380px;
    text-align: center;
    position: relative;
    z-index: 1;
}
.login-card .login-logo {
    width: 220px;
    margin-bottom: 0.5rem;
}
.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.login-footer {
    margin-top: 1.5rem;
    font-size: .75rem;
    color: var(--text-muted);
}
.login-footer a {
    color: var(--accent-light);
    text-decoration: none;
    transition: color 0.2s ease;
}
.login-footer a:hover { color: var(--accent-blue); }

/* --- App Info Page --- */
.app-info-hero {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.app-info-logo {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
    max-width: 80px;
    max-height: 80px;
    border-radius: 12px;
    object-fit: contain;
    background: var(--bg-secondary);
    padding: 10px;
    flex-shrink: 0;
    overflow: hidden;
}
.app-info-tagline {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0 0 .75rem 0;
}
.app-screenshots {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: .5rem;
}
.app-screenshot {
    max-height: 220px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    object-fit: cover;
}
.app-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.app-info-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}
.app-info-card h3 {
    margin: 0 0 .75rem 0;
    font-size: .95rem;
    color: var(--text-primary);
}
.app-info-list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
    font-size: .9rem;
    line-height: 1.6;
}
.app-info-creds {
    font-family: monospace;
    font-size: 1rem;
    color: var(--accent-light);
    background: var(--bg-secondary);
    padding: .5rem .75rem;
    border-radius: 4px;
    display: inline-block;
    margin: 0 0 .5rem 0;
}
.app-info-creds-warn {
    color: var(--orange);
    font-size: .85rem;
    margin: 0;
}
.app-info-link {
    color: var(--accent-light);
    text-decoration: none;
}
.app-info-link:hover { text-decoration: underline; }

/* Optional config section */
.app-optional-config {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.app-optional-config h3 {
    margin: 0 0 1rem 0;
    font-size: 1.05rem;
}
.config-group {
    margin-bottom: 1.5rem;
}
.config-group h4 {
    margin: 0 0 .5rem 0;
    font-size: .95rem;
    color: var(--text-primary);
}
.config-group-desc {
    color: var(--text-secondary);
    font-size: .85rem;
    margin: 0 0 1rem 0;
}
.config-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}
.config-field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.config-field label {
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-primary);
}
.config-field-help {
    font-size: .8rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}
.config-field-help a {
    color: var(--accent-light);
    text-decoration: none;
}
.config-field-help a:hover { text-decoration: underline; }
.config-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: .5rem .75rem;
    color: var(--text-primary);
    font-size: .9rem;
    font-family: monospace;
    width: 100%;
    box-sizing: border-box;
}
.config-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}
.config-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}
.config-save-status {
    font-size: .9rem;
    transition: opacity .3s;
}
.config-save-ok { color: var(--green); }
.config-save-err { color: var(--red); }
.meta-badge-warn {
    background: rgba(255, 152, 0, 0.1) !important;
    color: var(--orange) !important;
}
.meta-badge-ok {
    background: rgba(76, 175, 80, 0.1) !important;
    color: var(--green) !important;
}

/* Orphan badge */
.badge-orphaned {
    background: var(--orange-bg);
    color: var(--orange);
}

/* Delete modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.modal-card h3 {
    margin-bottom: .75rem;
}
.modal-hdd-info {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: .75rem 1rem;
    margin: .75rem 0;
    font-size: .85rem;
    color: var(--text-secondary);
}
.modal-hdd-path {
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
    color: var(--text-muted);
    padding: .2rem 0;
}
.modal-checkbox {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: .75rem 0;
    padding: .75rem 1rem;
    background: var(--red-bg);
    border: 1px solid rgba(218, 54, 51, 0.3);
    border-radius: 8px;
    font-size: .85rem;
    color: var(--red);
    cursor: pointer;
}
.modal-checkbox input[type="checkbox"] {
    accent-color: var(--red);
}
.modal-actions {
    display: flex;
    gap: .75rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

/* Load average text */
.system-load-avg {
    font-size: .7rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    margin-top: .25rem;
}

/* Temperature dot */
.temp-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: .25rem;
    vertical-align: middle;
}
.temp-dot-green { background: var(--green); box-shadow: 0 0 4px rgba(35, 134, 54, 0.5); }
.temp-dot-yellow { background: var(--yellow); box-shadow: 0 0 4px rgba(210, 153, 34, 0.5); }
.temp-dot-red { background: var(--red); box-shadow: 0 0 4px rgba(218, 54, 51, 0.5); }

.system-info-item-compact {
    flex: 0 1 auto;
    min-width: 120px;
}

/* Backup status card */
.backup-status-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}
.backup-status-card h3 {
    margin-bottom: .75rem;
}
.backup-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .25rem 0;
    font-size: .85rem;
}
.backup-label {
    color: var(--text-secondary);
}
.backup-value {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
}
.backup-status-ok { color: var(--green); }
.backup-status-fail { color: var(--red); }
.backup-status-none { color: var(--text-muted); }

/* Dashboard backup card link */
.backup-card-link {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}
.backup-card-link:hover {
    color: var(--accent-light);
}

/* --- Backup page --- */
.backup-page-cards {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.backup-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}
.backup-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}
.backup-empty-state h3 {
    margin-bottom: .5rem;
}
.backup-empty-state p {
    color: var(--text-secondary);
    font-size: .9rem;
    line-height: 1.6;
}

.schedule-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.schedule-card h3 {
    margin-bottom: .75rem;
}
.schedule-rows {
    margin-bottom: 1rem;
}
.schedule-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .4rem 0;
    font-size: .85rem;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}
.schedule-row:last-child { border-bottom: none; }
.schedule-task {
    color: var(--text-primary);
    font-weight: 500;
    min-width: 160px;
}
.schedule-time {
    color: var(--accent-light);
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
    min-width: 80px;
}
.schedule-next {
    color: var(--text-secondary);
    font-size: .8rem;
}
.schedule-summary {
    border-top: 1px solid var(--border-color);
    padding-top: .75rem;
    margin-bottom: .75rem;
}
.schedule-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .25rem 0;
    font-size: .85rem;
    color: var(--text-secondary);
}
.schedule-summary-value {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
}
.schedule-actions {
    padding-top: .5rem;
}

.backup-section-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.backup-section-card h3 {
    margin-bottom: .75rem;
}

.backup-table-wrap {
    overflow-x: auto;
}

.db-table, .snapshot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.db-table th, .snapshot-table th {
    text-align: left;
    padding: .5rem .75rem;
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border-color);
}
.db-table td, .snapshot-table td {
    padding: .5rem .75rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(48, 54, 61, 0.3);
}
.db-table tr:nth-child(even), .snapshot-table tr:nth-child(even) {
    background: var(--bg-secondary);
}
.db-table tr:nth-child(odd), .snapshot-table tr:nth-child(odd) {
    background: var(--bg-card);
}
.db-table td.mono, .snapshot-table td.mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
}

.db-type-badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
}
.db-type-postgres {
    background: rgba(0, 136, 204, 0.15);
    color: var(--accent-light);
}
.db-type-mariadb {
    background: rgba(210, 153, 34, 0.15);
    color: var(--yellow);
}

.validation-badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
}
.validation-ok {
    background: var(--green-bg);
    color: var(--green);
}
.validation-fail {
    background: var(--red-bg);
    color: var(--red);
    cursor: help;
}
.validation-na {
    color: var(--text-muted);
}

.snapshot-footer {
    padding: .75rem .75rem 0;
    font-size: .8rem;
    color: var(--text-secondary);
}

.backup-table-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
}

.repo-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.repo-card h3 {
    margin-bottom: .75rem;
}
.repo-info-rows {
    margin-bottom: 1rem;
}
.repo-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .3rem 0;
    font-size: .85rem;
}
.repo-label {
    color: var(--text-secondary);
}
.repo-value {
    color: var(--text-primary);
}
.repo-value.mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
}
.repo-paths {
    border-top: 1px solid var(--border-color);
    padding-top: .75rem;
    margin-bottom: .75rem;
}
.repo-path-list {
    list-style: disc;
    padding-left: 1.5rem;
    margin-top: .5rem;
}
.repo-path-list li {
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
    color: var(--text-secondary);
    padding: .15rem 0;
}
.repo-remote {
    border-top: 1px solid var(--border-color);
    padding-top: .75rem;
}
.repo-remote-status {
    margin-top: .25rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.relative-time {
    color: var(--text-muted);
    font-size: .8rem;
}

/* --- Monitoring page --- */
.monitor-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.monitor-card h3 {
    margin-bottom: .75rem;
}
.monitor-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.monitor-card-header h3 {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}
.time-range-bar {
    display: flex;
    gap: .35rem;
}
.sysinfo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: .5rem;
}
.sysinfo-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .35rem .5rem;
    border-bottom: 1px solid rgba(48, 54, 61, 0.3);
    font-size: .9rem;
}
.sysinfo-row:last-child { border-bottom: none; }
.sysinfo-label {
    color: var(--text-secondary);
    font-weight: 500;
}
.sysinfo-value {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: .85rem;
}
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.charts-grid-2 {
    grid-template-columns: 1fr 1fr;
}
.chart-box {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: .75rem;
    border: 1px solid rgba(48, 54, 61, 0.5);
}
.chart-box-half {
    flex: 1;
    min-width: 0;
}
.chart-title {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .5rem;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.chart-wrap {
    position: relative;
    height: 180px;
}
.chart-wrap-bar {
    position: relative;
    height: 250px;
}
.container-charts-row {
    display: flex;
    gap: 1rem;
}
.chart-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: .9rem;
}
.storage-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.storage-item {
    padding: .25rem 0;
}
.storage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .4rem;
}
.storage-label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.storage-value {
    font-size: .8rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* Responsive */
@media(max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--border-color); }
    .nav-links { display: flex; padding: 0; overflow-x: auto; }
    .nav-links a { padding: .5rem 1rem; white-space: nowrap; }
    .nav-links a.active { border-left: none; border-bottom: 2px solid var(--accent-blue); }
    .content { margin-left: 0; padding: 1rem; }
    body { flex-direction: column; }
    .stack-card { flex-direction: column; align-items: flex-start; gap: .75rem; }
    .stack-actions { width: 100%; justify-content: flex-end; }
    .stack-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .deploy-info { flex-direction: column; }
    .system-info-items { flex-direction: column; gap: 1rem; }
    .charts-grid { grid-template-columns: 1fr; }
    .container-charts-row { flex-direction: column; }
    .sysinfo-grid { grid-template-columns: 1fr; }
}
