﻿/* ============================================================
   RAYX Panel de Control v2.0
   ============================================================ */
:root {
    --bg-dark: #080A0F;
    --bg-card: #111827;
    --bg-card-hover: #162032;
    --accent: #66FCF1;
    --accent-dim: #45A29E;
    --accent-glow: rgba(102, 252, 241, 0.15);
    --text-main: #94A3B8;
    --text-light: #E2E8F0;
    --text-dim: #4B5563;
    --danger: #EF4444;
    --danger-glow: rgba(239, 68, 68, 0.3);
    --success: #10B981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --warning: #F59E0B;
    --warning-glow: rgba(245, 158, 11, 0.3);
    --border: rgba(102, 252, 241, 0.12);
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

/* ============================================================
   RAYX Auth shell
   ============================================================ */
body:not(.authenticated) .sidebar,
body:not(.authenticated) .app-wrapper {
    filter: blur(10px);
    pointer-events: none;
    user-select: none;
}

body.authenticated .auth-screen {
    display: none;
}

.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 50% 0%, rgba(74, 222, 128, 0.18), transparent 34%),
        rgba(12, 15, 24, 0.82);
    backdrop-filter: blur(14px);
}

.auth-panel {
    width: min(460px, 100%);
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(22, 27, 41, 0.96), rgba(12, 15, 24, 0.96));
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.auth-brand img {
    width: 150px;
    height: auto;
}

.auth-panel h1 {
    margin: 0;
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    font-size: 2.2rem;
    line-height: 1;
}

.auth-panel p {
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}

.auth-error {
    margin-top: 14px;
    color: var(--red);
    font-weight: 700;
}

.auth-helper {
    margin-bottom: 0;
    font-size: 0.88rem;
}

.auth-link {
    margin-top: 10px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--green);
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}

.device-panel,
.heartbeat-panel {
    position: relative;
}

.device-panel .btn {
    margin-top: 12px;
    width: 100%;
}

.heartbeat-panel small {
    display: block;
    margin-top: 6px;
}

.admin-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 16px;
}

.admin-form-card,
.admin-list-card,
.admin-audit-card {
    align-self: start;
}

.admin-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.admin-license-list {
    display: grid;
    gap: 10px;
}

.admin-license-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.4fr);
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
}

.admin-license-row strong,
.admin-license-row code {
    display: block;
}

.admin-license-row code {
    margin-top: 6px;
    color: var(--green);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    overflow-wrap: anywhere;
}

.admin-license-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    color: var(--muted);
    font-size: 0.86rem;
}

.admin-sim-card {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.admin-audit-card,
.admin-maint-card {
    grid-column: 1 / -1;
}

.admin-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-audit-list {
    display: grid;
    gap: 10px;
    max-height: 480px;
    overflow: auto;
    padding-right: 4px;
}

.admin-audit-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.2fr) minmax(280px, 1.4fr);
    gap: 8px 14px;
    padding: 12px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--muted2);
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
}

.admin-audit-row.audit-ok {
    border-left-color: var(--green);
}

.admin-audit-row.audit-failed {
    border-left-color: var(--red);
}

.admin-audit-row.audit-rate_limited {
    border-left-color: var(--gold);
}

.audit-main strong,
.audit-main span,
.audit-meta span,
.admin-audit-row small {
    display: block;
}

.audit-main strong {
    color: var(--text);
}

.audit-main span,
.audit-meta,
.admin-audit-row small {
    color: var(--muted);
    font-size: 0.86rem;
}

.audit-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
}

.admin-audit-row small {
    grid-column: 1 / -1;
    overflow-wrap: anywhere;
}

.admin-maint-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.stat-panel.mini {
    padding: 12px;
}

.stat-panel.mini strong {
    font-size: 1.15rem;
}

.stat-panel.mini small {
    display: block;
    overflow-wrap: anywhere;
}

.admin-maint-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ANIMATED BACKGROUND */
.background-glow {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 40% at 20% 0%, rgba(102,252,241,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(69,162,158,0.05) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.app-wrapper {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ===== HEADER ===== */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-light);
    letter-spacing: 3px;
}

.logo span {
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent), 0 0 40px rgba(102,252,241,0.3);
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 2px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-tabs {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(17,24,39,0.75);
}

.view-tab {
    flex: 1;
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.view-tab.active {
    background: var(--accent);
    color: var(--bg-dark);
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(17,24,39,0.8);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
}

.dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.dot.active { background: var(--success); box-shadow: 0 0 10px var(--success), 0 0 20px var(--success-glow); animation: pulse-dot 2s infinite; }
.dot.paused { background: var(--warning); box-shadow: 0 0 10px var(--warning); }

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 10px var(--success); }
    50% { box-shadow: 0 0 20px var(--success), 0 0 30px var(--success-glow); }
}

.builders-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(17,24,39,0.8);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-light);
}

/* ===== CONTROLS ===== */
.section-controls { margin-bottom: 2rem; }

.master-control {
    background: linear-gradient(135deg, #111827 0%, #0f1f2e 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.05);
}

.phase-badge {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.phase-label {
    font-size: 0.65rem;
    letter-spacing: 2px;
    color: var(--accent-dim);
    text-transform: uppercase;
    font-weight: 600;
}

.phase-badge strong {
    font-size: 1.3rem;
    color: var(--text-light);
    font-family: 'Orbitron', sans-serif;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== RESOURCES ===== */
.section-resources {
    margin-bottom: 2.5rem;
    padding: 0.15rem 0 0.25rem;
}

.section-title {
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-dim);
    margin-bottom: 1rem;
    font-weight: 600;
}

.resources-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.05rem;
}

.builder-resources-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 700px) {
    .resources-grid,
    .builder-resources-grid { grid-template-columns: 1fr; }
}

.resource-item {
    min-height: 106px;
    background: linear-gradient(180deg, rgba(17,24,39,0.98), rgba(14,22,35,0.96));
    border: 1px solid rgba(102,252,241,0.18);
    border-radius: 14px;
    padding: 1.05rem 1.15rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 14px 28px rgba(0,0,0,0.32), inset 0 1px 0 rgba(255,255,255,0.04);
}

.coc-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-box {
    width: 46px; height: 46px;
    background:
        radial-gradient(circle at 38% 30%, rgba(255,255,255,0.18), transparent 35%),
        radial-gradient(circle at 50% 56%, #293241, #080A0F 68%);
    border: 2px solid rgba(255,255,255,0.12);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 6px 14px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.08);
}

.icon-box img { width: 75%; height: 75%; object-fit: contain; }

.progress-container {
    flex: 1;
    height: 31px;
    background: linear-gradient(180deg, #050608, #0B0D12);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    border: 2px solid rgba(0,0,0,0.58);
    box-shadow: inset 0 3px 8px rgba(0,0,0,0.9), 0 1px 0 rgba(255,255,255,0.07);
}

.progress-bar {
    height: 100%;
    width: 0%;
    transition: width 1s cubic-bezier(0.1, 0.7, 0.1, 1);
    border-radius: 12px;
}

.gold .progress-bar { background: linear-gradient(90deg, #c9a227, #FFD700); }
.elixir .progress-bar { background: linear-gradient(90deg, #a020a0, #FF69B4); }
.dark .progress-bar { background: linear-gradient(90deg, #2c1654, #7B2FBE); }

.bar-gloss {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 45%;
    background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 100%);
    pointer-events: none;
}

.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 0 4px #000, 0 1px 2px #000;
    letter-spacing: 1px;
}

.res-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
    font-size: 0.78rem;
    padding: 0 2px;
}

.res-label {
    min-width: 72px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.gold-label { color: #F59E0B; }
.elixir-label { color: #EC4899; }
.dark-label { color: #8B5CF6; }
.res-total {
    color: #A9B5C8;
    text-align: center;
    flex: 1;
    white-space: nowrap;
}
.res-missing {
    color: #FF5D6C;
    font-weight: 900;
    text-align: right;
    white-space: nowrap;
}

/* ===== OPERATIONS ===== */
.section-operations { margin-bottom: 2.5rem; }

.ops-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.readiness-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(17,24,39,0.8);
}

.readiness-strip > div:first-child {
    display: grid;
    gap: 4px;
}

.readiness-label {
    color: var(--text-dim);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

#readiness-title {
    color: var(--text-light);
    font-size: 1rem;
}

#readiness-title.ok { color: var(--success); }
#readiness-title.warn { color: var(--warning); }

.readiness-checks {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.45rem;
}

.readiness-chip {
    padding: 0.42rem 0.58rem;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    background: rgba(0,0,0,0.28);
    color: var(--text-light);
    font-size: 0.72rem;
    font-weight: 700;
}

.readiness-chip.ok { border-color: rgba(16,185,129,0.45); }
.readiness-chip.bad { border-color: rgba(239,68,68,0.52); color: #FCA5A5; }

[hidden] { display: none !important; }

.ops-metric {
    min-height: 74px;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(17,24,39,0.8);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ops-metric span {
    font-size: 0.68rem;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 700;
}

.ops-metric strong {
    font-size: 1.15rem;
    color: var(--text-light);
}

.ops-metric strong.ok { color: var(--success); }
.ops-metric strong.warn { color: var(--warning); }
.ops-metric strong.bad { color: var(--danger); }

.ops-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.ops-card { min-height: 286px; }
.log-card { grid-column: 1 / -1; min-height: 260px; }
.event-list, .asset-list { display: flex; flex-direction: column; gap: 0.65rem; }

.manual-card {
    grid-column: 1 / -1;
    min-height: 0;
}

.manual-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.55rem;
    margin-bottom: 0.8rem;
}

.manual-action-btn {
    min-height: 40px;
    padding: 0.55rem 0.65rem;
    font-size: 0.72rem;
}

.manual-result {
    min-height: 86px;
    max-height: 180px;
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.35);
    color: var(--text-light);
    padding: 0.8rem;
    font: 0.75rem/1.45 Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.profile-card {
    min-height: 0;
}

.profile-save-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.profile-save-row input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-light);
}

.profile-list {
    display: grid;
    gap: 0.65rem;
}

.profile-row {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.22);
    padding: 0.7rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem;
    align-items: center;
}

.profile-row strong {
    color: var(--text-light);
    display: block;
    font-size: 0.86rem;
}

.profile-row span {
    color: var(--text-main);
    font-size: 0.72rem;
}

.profile-actions {
    display: flex;
    gap: 0.45rem;
}

.instance-manager {
    margin-top: 16px;
}

.instance-manager-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.instance-head-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.instance-form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(130px, 0.8fr) 110px minmax(130px, 0.9fr) auto auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

.instance-guardrails {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 14px;
}

.instance-scheduler {
    border: 1px solid rgba(74,222,128,0.18);
    border-radius: var(--radius-sm);
    background: rgba(2,6,23,0.45);
    color: var(--text-main);
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.45;
    margin-bottom: 14px;
    padding: 0.62rem 0.75rem;
}

.guardrail-chip {
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.25);
    color: var(--text-main);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.48rem 0.65rem;
}

.guardrail-chip.ok {
    border-color: rgba(16,185,129,0.42);
    color: #86EFAC;
}

.guardrail-chip.warn {
    border-color: rgba(245,158,11,0.45);
    color: #FCD34D;
}

.guardrail-chip.bad {
    border-color: rgba(239,68,68,0.55);
    color: #FCA5A5;
}

.instance-form .form-group {
    margin-bottom: 0;
}

.instance-list {
    display: grid;
    gap: 0.65rem;
}

.instance-row {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.22);
    padding: 0.75rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
}

.instance-title {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.instance-row strong {
    color: var(--text-light);
    font-size: 0.9rem;
}

.instance-row span,
.instance-row small {
    display: block;
    color: var(--text-main);
    font-size: 0.74rem;
    overflow-wrap: anywhere;
}

.instance-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-small {
    padding: 0.45rem 0.6rem;
    font-size: 0.68rem;
}

.loot-card {
    min-height: 0;
}

.loot-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.loot-summary div {
    display: grid;
    gap: 4px;
    padding: 0.65rem;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.22);
}

.loot-summary span {
    color: var(--text-dim);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.loot-summary strong {
    color: var(--text-light);
    font-size: 1.05rem;
}

.loot-target-mini {
    margin-top: 0.75rem;
    color: var(--text-main);
    font-size: 0.76rem;
    line-height: 1.5;
}

.daily-card {
    min-height: 0;
}

.daily-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.6rem;
}

.daily-grid div {
    display: grid;
    gap: 4px;
    padding: 0.65rem;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.22);
}

.daily-grid span {
    color: var(--text-dim);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.daily-grid strong {
    color: var(--text-light);
    font-size: 1rem;
}

.failure-row {
    border-color: rgba(239,68,68,0.18);
}

.ocr-alert-row {
    border-color: rgba(245,158,11,0.24);
}

.event-row, .asset-row {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.22);
    padding: 0.65rem 0.75rem;
    display: grid;
    gap: 3px;
}

.event-row strong, .asset-row strong {
    color: var(--text-light);
    font-size: 0.82rem;
}

.event-row span, .asset-row span, .ops-empty {
    color: var(--text-main);
    font-size: 0.75rem;
    line-height: 1.4;
}

.event-meta { color: var(--accent-dim); text-transform: uppercase; font-weight: 700; }

.live-log {
    height: 190px;
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.42);
    color: var(--text-light);
    padding: 0.9rem;
    font: 0.75rem/1.5 Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.calibration-card {
    grid-column: 1 / -1;
}

.calibration-list {
    display: grid;
    gap: 0.7rem;
    margin-bottom: 1rem;
}

.calibration-row {
    display: grid;
    gap: 0.45rem;
    padding: 0.8rem;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.22);
}

.calibration-row p {
    color: var(--text-main);
    font-size: 0.76rem;
    line-height: 1.4;
}

.calibration-head,
.calibration-command {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    min-width: 0;
}

.calibration-head strong {
    color: var(--text-light);
    font-size: 0.85rem;
}

.calibration-state {
    padding: 0.26rem 0.45rem;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.66rem;
    font-weight: 800;
    text-transform: uppercase;
}

.calibration-state.ready { border-color: rgba(16,185,129,0.45); color: var(--success); }
.calibration-state.blocked { border-color: rgba(239,68,68,0.52); color: #FCA5A5; }
.calibration-state.degraded { border-color: rgba(245,158,11,0.48); color: var(--warning); }

.calibration-command code {
    min-width: 0;
    flex: 1;
    overflow: auto;
    padding: 0.48rem 0.55rem;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    background: rgba(8,10,15,0.76);
    color: var(--text-light);
    font: 0.74rem Consolas, monospace;
    white-space: nowrap;
}

.command-copy {
    min-height: 34px;
    padding: 0 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(102,252,241,0.12);
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
}

/* ===== SETTINGS GRID ===== */
.section-settings { }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    border-color: rgba(102,252,241,0.25);
    box-shadow: var(--shadow), 0 0 20px var(--accent-glow);
}

.card-title {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* TOGGLE SWITCH */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.toggle-row:last-of-type { border-bottom: none; }

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px; height: 24px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    inset: 0;
    background: #374151;
    border-radius: 24px;
    cursor: pointer;
    transition: 0.3s ease;
}

.slider:before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; top: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.toggle-switch input:checked + .slider {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.toggle-switch input:checked + .slider:before {
    transform: translateX(22px);
    background: var(--bg-dark);
}

.toggle-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mode-group {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.mode-segments {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 4px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    background: rgba(0,0,0,0.28);
}

.mode-segments label {
    position: relative;
    min-width: 0;
}

.mode-segments input {
    position: absolute;
    opacity: 0;
}

.mode-segments span {
    display: grid;
    min-height: 38px;
    place-items: center;
    border-radius: 6px;
    color: var(--text-main);
    cursor: pointer;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.mode-segments input:checked + span {
    background: var(--accent);
    color: var(--bg-dark);
}

.toggle-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-light);
}

.toggle-desc {
    font-size: 0.72rem;
    color: var(--text-dim);
    line-height: 1.4;
}

/* FORM ELEMENTS */
.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input[type="number"],
.form-group input[type="text"],
.form-group select,
.army-group-row input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.army-group-row input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.army-group-list {
    display: grid;
    gap: 8px;
    margin-bottom: 1rem;
}

.army-group-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 8px;
}

.slot-qty-row {
    align-items: center;
}

.slot-qty-row span {
    color: var(--text-light);
    font-size: 0.84rem;
    font-weight: 600;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.input-with-unit input { flex: 1; }

.unit {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.field-hint {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 4px;
    line-height: 1.4;
}

.separator {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}

.card-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-dim);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* BUILDERS STATUS BOX */
.builders-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin: 1rem 0;
}

.builders-status-label { font-size: 0.8rem; color: var(--text-main); }
.builders-value { font-size: 1.2rem; font-weight: 800; color: var(--accent); }

/* ===== BUTTONS ===== */
.btn {
    padding: 0.65rem 1.4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.btn-lg { padding: 0.8rem 1.8rem; font-size: 0.9rem; }

.btn-primary {
    background: var(--accent);
    color: var(--bg-dark);
    width: 100%;
    margin-top: 1.2rem;
    box-shadow: 0 0 15px var(--accent-glow);
}
.btn-primary:hover { background: #55E6DC; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(102,252,241,0.4); }

.btn-success { background: var(--success); color: white; box-shadow: 0 0 15px var(--success-glow); }
.btn-success:hover { filter: brightness(1.1); box-shadow: 0 4px 20px var(--success-glow); }

.btn-danger { background: var(--danger); color: white; box-shadow: 0 0 15px var(--danger-glow); }
.btn-danger:hover { filter: brightness(1.1); box-shadow: 0 4px 20px var(--danger-glow); }

.btn-warning { background: var(--warning); color: var(--bg-dark); box-shadow: 0 0 15px var(--warning-glow); }
.btn-warning:hover { filter: brightness(1.1); }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    color: var(--text-light);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
    pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: var(--danger); }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
    .main-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .master-control { flex-direction: column; align-items: flex-start; }
    .logo { font-size: 1.4rem; }
    .app-wrapper { padding: 1rem; }
    .ops-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ops-grid { grid-template-columns: 1fr; }
    .log-card { grid-column: auto; }
    .manual-card { grid-column: auto; }
    .manual-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-save-row, .profile-row, .instance-form, .instance-row { grid-template-columns: 1fr; }
    .instance-manager-head { flex-direction: column; }
    .instance-actions { justify-content: flex-start; }
    .view-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .readiness-strip { align-items: flex-start; flex-direction: column; }
    .readiness-checks { justify-content: flex-start; }
    .calibration-command { align-items: stretch; flex-direction: column; }
    .calibration-command code { overflow-wrap: anywhere; overflow: visible; white-space: normal; width: 100%; }
    .command-copy { align-self: flex-end; }
    .loot-summary { grid-template-columns: 1fr; }
    .daily-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ============================================================
   RAYX SaaS shell overrides
   ============================================================ */
:root {
    --bg: #0C0F18;
    --bg2: #11151F;
    --bg3: #161B29;
    --green: #4ADE80;
    --green-dim: rgba(74,222,128,0.10);
    --green-border: rgba(74,222,128,0.22);
    --gold: #FBBF24;
    --gold-dim: rgba(251,191,36,0.10);
    --purple: #C084FC;
    --purple-dim: rgba(192,132,252,0.10);
    --purple-border: rgba(192,132,252,0.22);
    --text: #F0F4FF;
    --muted: rgba(240,244,255,0.45);
    --muted2: rgba(240,244,255,0.22);
    --red: #F87171;
    --bg-dark: var(--bg);
    --bg-card: var(--bg2);
    --bg-card-hover: var(--bg3);
    --accent: var(--green);
    --accent-dim: var(--muted);
    --accent-glow: rgba(74,222,128,0.18);
    --text-main: var(--muted);
    --text-light: var(--text);
    --text-dim: var(--muted2);
    --danger: var(--red);
    --success: var(--green);
    --warning: var(--gold);
    --border: rgba(255,255,255,0.07);
    --radius: 16px;
    --radius-sm: 8px;
}

body {
    background: var(--bg);
    color: var(--muted);
    font-family: 'DM Sans', sans-serif;
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 52px 52px;
    mask-image: radial-gradient(ellipse 80% 80% at 50% 20%, black 20%, transparent 100%);
}

.background-glow {
    background:
        radial-gradient(circle at 15% 5%, rgba(74,222,128,0.06), transparent 32%),
        radial-gradient(circle at 85% 15%, rgba(251,191,36,0.05), transparent 30%),
        radial-gradient(circle at 65% 90%, rgba(192,132,252,0.04), transparent 34%);
}

.sidebar {
    width: 240px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 24px 20px 18px;
}

.sidebar-logo img {
    height: 34px;
    width: auto;
    display: block;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 16px 18px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
}

.sidebar-user img {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.sidebar-user strong {
    display: block;
    color: var(--text);
    font-size: 0.9rem;
}

.sidebar .view-tabs {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0 8px;
    border: 0;
    background: transparent;
    border-radius: 0;
}

.sidebar .view-tab {
    flex: none;
    min-height: 40px;
    text-align: left;
    padding: 10px 16px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.sidebar .view-tab:hover {
    color: var(--text);
    background: rgba(255,255,255,0.04);
}

.sidebar .view-tab.active {
    background: var(--green-dim);
    color: var(--green);
    border-left: 3px solid var(--green);
    padding-left: 13px;
}

.sidebar-logout {
    margin: auto 16px 20px;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    color: var(--muted);
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
}

.app-wrapper {
    max-width: none;
    margin: 0 0 0 240px;
    min-height: 100vh;
    padding: 0 32px 48px;
}

.main-header {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 60px;
    margin: 0 -32px 28px;
    padding: 0 32px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}

.logo, .section-title, .phase-badge strong, .stat-panel strong, .plan-card strong, .client-hero h2 {
    font-family: 'Rajdhani', sans-serif;
}

.logo {
    font-size: 1.45rem;
    letter-spacing: 0;
    color: var(--text);
}

.logo-subtitle {
    color: var(--muted2);
    letter-spacing: 0.06em;
}

.card, .control-card, .resource-item, .readiness-strip, .ops-metric {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: none;
}

.card:hover, .resource-item:hover {
    border-color: rgba(255,255,255,0.12);
}

.btn {
    font-family: 'DM Sans', sans-serif;
    border-radius: 10px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
}

.btn-primary {
    width: auto;
    margin-top: 0;
    background: var(--green);
    color: var(--bg);
    box-shadow: none;
}

.btn-primary:hover {
    background: #6EE7A0;
    box-shadow: 0 8px 24px rgba(74,222,128,0.25);
}

.card form > .btn-primary {
    width: 100%;
    margin-top: 1.2rem;
}

.btn-danger {
    background: rgba(248,113,113,0.10);
    color: var(--red);
    border: 1px solid rgba(248,113,113,0.25);
    box-shadow: none;
}

.badge {
    display: inline-block;
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 20px;
}

.badge-free, .badge-active {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid var(--green-border);
}

.badge-pro {
    background: var(--purple-dim);
    color: var(--purple);
    border: 1px solid var(--purple-border);
}

.badge-legend {
    background: rgba(192,132,252,0.15);
    color: #E879F9;
    border: 1px solid rgba(232,121,249,0.3);
}

.rayx-client-page {
    animation: fadeInUp 0.4s ease both;
}

.client-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
}

.client-hero h2 {
    color: var(--text);
    font-size: 2rem;
    margin: 8px 0 4px;
}

.client-hero p {
    max-width: 620px;
    color: var(--muted);
}

.license-key {
    font-family: 'JetBrains Mono', monospace;
    color: var(--green);
    background: var(--bg3);
    border: 1px solid var(--green-border);
    border-radius: 10px;
    padding: 12px 14px;
}

.license-actions,
.subscription-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.client-grid, .pricing-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.stat-panel span {
    display: block;
    color: var(--muted2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-panel strong, .plan-card strong {
    display: block;
    color: var(--text);
    font-size: 2.3rem;
    line-height: 1;
    margin: 8px 0;
}

.runtime-panel small {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.gold-stat { color: var(--gold) !important; }
.purple-stat { color: var(--purple) !important; }
.green-stat { color: var(--green) !important; }

.plan-card.featured {
    border-color: var(--green-border);
    background: linear-gradient(160deg, rgba(74,222,128,0.08), var(--bg2) 60%);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: auto;
        height: auto;
    }
    .sidebar .view-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding-bottom: 12px;
    }
    .sidebar-logout {
        margin-top: 8px;
    }
    .app-wrapper {
        margin-left: 0;
        padding: 0 16px 36px;
    }
    .main-header {
        margin: 0 -16px 20px;
        padding: 0 16px;
    }
    .client-hero {
        align-items: flex-start;
        flex-direction: column;
    }
    .license-actions,
    .subscription-actions {
        justify-content: flex-start;
        width: 100%;
    }
    .client-grid, .pricing-grid {
        grid-template-columns: 1fr;
    }
    .admin-layout,
    .admin-license-row,
    .admin-license-meta,
    .admin-audit-row,
    .audit-meta,
    .admin-maint-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 24px;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: min(460px, 100%);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow);
    animation: modal-in 0.15s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.96) translateY(-8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
    margin: 0;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.2rem;
    color: var(--text-light);
}

.modal-desc {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-main);
}

.modal-input {
    width: 100%;
    box-sizing: border-box;
}

.modal-error {
    margin: 0;
    font-size: 0.85rem;
    color: var(--danger);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

/* ── Mejoras panel v2.1 ────────────────────────────────────── */

/* Indicador cambios sin guardar */
button.dirty {
    outline: 2px solid var(--warning, #f5a623);
    outline-offset: 2px;
}

/* Tiempo de sesión activa junto a la fase */
.session-uptime {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted, #8899aa);
    font-weight: 400;
    margin-top: 2px;
}

/* Card title con selector de instancia a la derecha */
.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.card-title-row .card-title {
    margin-bottom: 0;
}

/* Selector de instancia en logs */
.log-instance-select {
    font-size: 0.78rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border, #2a3040);
    background: var(--bg-card, #141820);
    color: var(--text, #cdd6f4);
    max-width: 160px;
}
