/* ========================================================================== 
   RetroStation Admin — Modern UI 2.0
   ========================================================================== */

:root {
    --bg: #070812;
    --bg-2: #0b0d19;
    --surface: rgba(17, 20, 35, .88);
    --surface-2: rgba(25, 29, 48, .78);
    --surface-3: rgba(37, 42, 65, .72);
    --line: rgba(255, 255, 255, .075);
    --line-strong: rgba(255, 255, 255, .14);
    --text: #f5f7ff;
    --muted: #9ba6c2;
    --muted-2: #6f7894;
    --primary: #8b5cf6;
    --primary-strong: #7c3aed;
    --primary-soft: rgba(139, 92, 246, .14);
    --accent: #22d3ee;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #fb7185;
    --radius-xl: 24px;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 22px 65px rgba(0, 0, 0, .34);
    --shadow-soft: 0 14px 36px rgba(0, 0, 0, .22);
    --sidebar: 276px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(900px 520px at 7% -8%, rgba(124, 58, 237, .25), transparent 60%),
        radial-gradient(780px 460px at 94% 0%, rgba(34, 211, 238, .12), transparent 64%),
        linear-gradient(180deg, #080914 0%, #060711 100%);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(139, 92, 246, .35); color: #fff; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; color: #67e8f9; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--text); letter-spacing: -.025em; }
h1 { margin-bottom: 5px; font-size: clamp(24px, 3vw, 32px); line-height: 1.1; }
h2 { margin-bottom: 5px; font-size: clamp(18px, 2vw, 21px); }
p { margin-bottom: 0; color: var(--muted); }
small { color: var(--muted); }
strong { color: var(--text); }
code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
code { padding: 2px 7px; border: 1px solid var(--line); border-radius: 7px; background: rgba(4, 6, 14, .82); overflow-wrap: anywhere; }

/* Login */
body.centered { display: grid; place-items: center; padding: 24px; }
.auth-card {
    width: min(440px, 100%);
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 26px;
    background: linear-gradient(145deg, rgba(26, 30, 51, .92), rgba(12, 14, 26, .92));
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}
.auth-card form { display: grid; gap: 13px; margin-top: 22px; }
.auth-card small { display: block; margin-top: 16px; }

/* Shell */
.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; width: 100%; }
.app-shell > aside { grid-column: 1; grid-row: 1; }
.app-shell > main { grid-column: 2; grid-row: 1; min-width: 0; }
aside {
    position: sticky;
    top: 0;
    z-index: 20;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    border-right: 1px solid var(--line);
    background: rgba(8, 10, 20, .78);
    backdrop-filter: blur(26px) saturate(125%);
}
.brand { padding: 14px 13px 21px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.brand strong { display: block; font-size: 19px; line-height: 1.15; }
.brand small { display: block; margin-top: 5px; color: var(--muted-2); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
aside nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; padding: 4px 0; }
aside nav a {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 43px;
    padding: 10px 13px 10px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 650;
    transition: .18s ease;
}
aside nav a::before {
    content: "";
    width: 5px;
    height: 5px;
    margin-right: 11px;
    border-radius: 50%;
    background: currentColor;
    opacity: .45;
}
aside nav a:hover { color: #fff; background: rgba(255,255,255,.045); }
aside nav a.active {
    color: #fff;
    border-color: rgba(139, 92, 246, .36);
    background: linear-gradient(120deg, rgba(139, 92, 246, .20), rgba(34, 211, 238, .07));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}
aside nav a.active::before { width: 7px; height: 7px; background: var(--primary); box-shadow: 0 0 16px rgba(139,92,246,.8); opacity: 1; }
.logout-form { margin-top: auto; padding-top: 14px; }

main { min-width: 0; width: 100%; max-width: 1750px; margin: 0 auto; padding: 30px clamp(18px, 3vw, 44px) 64px; }
main > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}
main > header p { max-width: 760px; }

/* Base components */
.card {
    position: relative;
    margin-top: 18px;
    padding: 23px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: linear-gradient(145deg, rgba(22, 26, 44, .88), rgba(13, 16, 29, .88));
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}
.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22px;
    right: 22px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.12), transparent);
}
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.card-heading p { max-width: 820px; }
.catalog-heading { align-items: center; }
.eyebrow { display: inline-block; margin-bottom: 6px; color: #a78bfa; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.metric-badge {
    flex: 0 0 auto;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.035);
    color: #d7def5;
    font-size: 12px;
    font-weight: 700;
}
.form-section { margin-top: 20px; }

.two-col { display: grid; grid-template-columns: minmax(0, 390px) minmax(0, 1fr); gap: 18px; align-items: start; }
.two-col.wide-left { grid-template-columns: minmax(0, 500px) minmax(0, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; }
.stats article {
    min-height: 112px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(25, 29, 48, .74), rgba(13, 16, 28, .78));
    box-shadow: var(--shadow-soft);
}
.stats b { display: block; margin-bottom: 5px; font-size: 29px; line-height: 1; letter-spacing: -.04em; }
.stats span { color: var(--muted); font-size: 12.5px; }
.mini-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 18px; }
.mini-stats article { min-height: auto; padding: 15px 17px; }
.mini-stats b { font-size: 23px; }

.pill, .tag, .number-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.045);
    color: var(--muted);
}
.pill { max-width: min(100%, 520px); padding: 8px 12px; border-radius: 999px; font-size: 11.5px; overflow-wrap: anywhere; }
.tag { padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.tag.ok { border-color: rgba(52,211,153,.28); background: rgba(52,211,153,.1); color: #a7f3d0; }
.tag.warn { border-color: rgba(251,191,36,.28); background: rgba(251,191,36,.1); color: #fde68a; }
.tag.bad { border-color: rgba(251,113,133,.30); background: rgba(251,113,133,.1); color: #fecdd3; }
.number-chip { min-width: 34px; justify-content: center; padding: 5px 8px; border-radius: 9px; color: #fff; font-weight: 750; }

.alert { margin-bottom: 14px; padding: 13px 15px; border-radius: 13px; border: 1px solid; }
.alert.success { border-color: rgba(52,211,153,.3); background: rgba(52,211,153,.10); color: #bbf7d0; }
.alert.error { border-color: rgba(251,113,133,.3); background: rgba(251,113,133,.10); color: #fecdd3; }
.info-strip { margin-top: 18px; padding: 13px 15px; border: 1px solid rgba(34,211,238,.18); border-radius: 13px; background: rgba(34,211,238,.07); color: #c9f7ff; font-size: 13px; }
.preview { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.preview img { max-width: 190px; max-height: 110px; object-fit: contain; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: #070912; }

/* Tabs and toolbar */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 54px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(12, 15, 27, .68);
    box-shadow: inset 0 1px rgba(255,255,255,.02);
    backdrop-filter: blur(14px);
}
.section-tabs { display: flex; align-items: center; gap: 5px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.section-tabs::-webkit-scrollbar { display: none; }
.section-tab {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 750;
    cursor: pointer;
}
.section-tab:hover { color: #fff; background: rgba(255,255,255,.045); }
.section-tab.active { color: #fff; border-color: rgba(139,92,246,.32); background: linear-gradient(120deg, rgba(139,92,246,.22), rgba(139,92,246,.10)); box-shadow: 0 5px 18px rgba(80,40,160,.12); }
.tab-count { min-width: 20px; padding: 2px 6px; border-radius: 999px; background: rgba(255,255,255,.08); color: #dce3f8; font-size: 10px; text-align: center; }
.toolbar-note { padding-right: 9px; color: var(--muted-2); font-size: 11.5px; text-align: right; }
.toolbar-metrics { padding-right: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.toolbar-metrics b { color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panelIn .16s ease-out; }
@keyframes panelIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* Forms */
form { display: grid; gap: 14px; }
.stack-form { display: block; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; align-items: start; }
.grid-form .wide { grid-column: 1 / -1; }
label { display: block; margin: 0; color: #aab4ce; font-size: 12px; font-weight: 700; }
label > input, label > select, label > textarea { margin-top: 6px; }
label small { display: block; margin-top: 5px; color: var(--muted-2); font-weight: 500; }
input, select, textarea, button { font: inherit; color: var(--text); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=datetime-local], input[type=search], input[type=url], input:not([type]), select, textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    outline: none;
    background: rgba(5, 8, 18, .72);
    color: var(--text);
    box-shadow: inset 0 1px rgba(255,255,255,.015);
    transition: border-color .16s, box-shadow .16s, background .16s;
}
input::placeholder, textarea::placeholder { color: #59627c; }
input:focus, select:focus, textarea:focus { border-color: rgba(34,211,238,.65); background: rgba(7,10,21,.92); box-shadow: 0 0 0 3px rgba(34,211,238,.10); }
textarea { min-height: 104px; resize: vertical; }
select { appearance: auto; }
input[type=color] { width: 100%; height: 44px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 11px; background: rgba(5,8,18,.72); cursor: pointer; }
input[type=file] { width: 100%; min-height: 44px; padding: 9px; border: 1px dashed var(--line-strong); border-radius: 11px; background: rgba(6,9,19,.58); color: var(--muted); font-size: 12px; }
label.check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 45px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255,255,255,.025);
    color: #dbe2f5;
    font-size: 12.5px;
    cursor: pointer;
}
label.check.compact { min-height: 38px; margin-top: 10px; padding: 8px 10px; font-size: 11.5px; }
label.check input { flex: 0 0 auto; width: 17px; height: 17px; margin: 0; accent-color: var(--primary); }
.color-field input[type=color] { max-width: 150px; }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid rgba(139,92,246,.42);
    border-radius: 11px;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
    font-size: 12.5px;
    font-weight: 780;
    cursor: pointer;
    transition: transform .14s, filter .14s, border-color .14s, background .14s;
}
button:hover, .btn:hover { filter: brightness(1.09); color: #fff; }
button:active, .btn:active { transform: translateY(1px); }
button.ghost, .btn.ghost { border-color: var(--line-strong); background: rgba(255,255,255,.04); color: #dbe2f5; }
button.logout { width: 100%; border-color: rgba(251,113,133,.24); background: rgba(251,113,133,.08); color: #fecdd3; }
button.link, a.link { min-height: auto; padding: 5px 7px; border: 0; background: transparent; color: var(--accent); font-size: 11.5px; font-weight: 750; }
button.link:hover, a.link:hover { background: rgba(34,211,238,.07); border-radius: 8px; }
button.link.danger, a.link.danger { color: #fda4af; }
.compact-btn { min-height: 36px; padding: 7px 11px; font-size: 11.5px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-link { font-size: 12px; font-weight: 700; }

.sticky-actions {
    position: sticky;
    z-index: 8;
    bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding: 12px 13px 12px 16px;
    border: 1px solid rgba(139,92,246,.22);
    border-radius: 15px;
    background: rgba(11, 13, 24, .90);
    box-shadow: 0 14px 40px rgba(0,0,0,.32);
    backdrop-filter: blur(20px);
}
.sticky-actions strong { display: block; font-size: 12.5px; }
.sticky-actions small { display: block; margin-top: 2px; font-size: 10.5px; }

/* Branding */
.media-upload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 13px; }
.upload-card { padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025); }
.upload-card-title { margin-bottom: 12px; }
.upload-card-title strong, .upload-card-title small { display: block; }
.upload-card-title small { margin-top: 3px; font-size: 10.5px; }
.asset-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 13px; margin-top: 20px; }
.asset-card { padding: 11px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025); }
.asset-card strong, .asset-card small { display: block; }
.asset-card strong { margin-top: 10px; font-size: 12.5px; }
.asset-card small { margin-top: 2px; font-size: 10.5px; }
.asset-thumb { display: grid; place-items: center; width: 100%; aspect-ratio: 16/9; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #050711; color: var(--muted-2); font-size: 11px; }
.asset-thumb img { width: 100%; height: 100%; object-fit: contain; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; margin-top: 19px; border: 1px solid var(--line); border-radius: 15px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
thead th { padding: 11px 13px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.025); color: #7f8aa7; font-size: 9.5px; font-weight: 800; letter-spacing: .12em; text-align: left; text-transform: uppercase; white-space: nowrap; }
tbody td { padding: 13px; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody td strong { font-size: 12.5px; }
tbody td small { display: block; margin-top: 3px; color: var(--muted-2); font-size: 10.5px; overflow-wrap: anywhere; }
td.actions { white-space: nowrap; }
td.actions form, .game-actions form { display: inline; }
.system-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--system-color, var(--primary)); box-shadow: 0 0 12px color-mix(in srgb, var(--system-color, var(--primary)) 55%, transparent); }

/* Filters */
.filter-bar { display: grid; grid-template-columns: minmax(190px, 1.3fr) minmax(170px, .8fr) auto auto; gap: 10px; align-items: end; margin-top: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.022); }
.filter-bar button, .filter-bar .btn { min-height: 44px; }

/* ROM and games */
.dropzone { grid-column: 1/-1; padding: 23px; border: 1.5px dashed rgba(139,92,246,.42); border-radius: 17px; background: linear-gradient(145deg, rgba(139,92,246,.08), rgba(34,211,238,.035)); text-align: center; }
.dropzone.drag { border-color: var(--accent); background: rgba(34,211,238,.09); }
.dropzone-icon { display: inline-grid; place-items: center; width: 46px; height: 46px; margin-bottom: 10px; border: 1px solid rgba(139,92,246,.32); border-radius: 13px; background: rgba(139,92,246,.12); color: #c4b5fd; font-size: 10px; font-weight: 850; letter-spacing: .1em; }
.dropzone strong, .dropzone small { display: block; }
.dropzone small { margin-top: 4px; }
.dropzone input[type=file] { margin-top: 14px; border-style: solid; }
.dropzone .chosen { margin-top: 9px; color: #dbe2f5; font-size: 11.5px; font-weight: 700; overflow-wrap: anywhere; }
.progress { grid-column: 1/-1; display: none; align-items: center; gap: 12px; }
.progress.on { display: flex; }
.progress .bar { flex: 1; height: 9px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.progress .bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .2s; }
.progress .value { min-width: 92px; color: #dbe2f5; font-size: 11.5px; font-weight: 800; text-align: right; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 13px; margin-top: 18px; }
.game-item { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.025); transition: transform .16s, border-color .16s, background .16s; }
.game-item:hover { transform: translateY(-2px); border-color: rgba(139,92,246,.28); background: rgba(255,255,255,.04); }
.game-item .art { position: relative; aspect-ratio: 4/3; border-bottom: 1px solid var(--line); background: #050711 center/cover no-repeat; }
.game-status { position: absolute; top: 9px; right: 9px; backdrop-filter: blur(10px); }
.game-item .info { padding: 12px; }
.game-item .info > strong { display: block; line-height: 1.25; }
.game-item .info > small { display: block; margin-top: 4px; }
.game-item .row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-top: 9px; }
.empty { margin-top: 18px; padding: 28px 18px; border: 1px dashed var(--line-strong); border-radius: 15px; background: rgba(255,255,255,.018); color: var(--muted); text-align: center; }

pre { margin: 16px 0 0; padding: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: rgba(4,6,14,.82); color: #cbd5e1; font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
ol, ul { margin: 14px 0 0; padding-left: 20px; color: #cbd5e1; }
ol li, ul li { margin-bottom: 6px; }

/* Responsive */
@media (max-width: 760px) {
    main { padding: 18px 13px 52px; }
    main > header { align-items: stretch; flex-direction: column; margin-bottom: 15px; }
    main > header .pill { max-width: 100%; }
    .card { padding: 17px; border-radius: 18px; }
    .page-toolbar { align-items: stretch; flex-direction: column; padding: 6px; }
    .toolbar-note, .toolbar-metrics { padding: 0 8px 5px; text-align: left; white-space: normal; }
    .section-tabs { width: 100%; }
    .section-tab { min-height: 36px; padding: 7px 11px; }
    .grid-form { grid-template-columns: 1fr; }
    .filter-bar { grid-template-columns: 1fr; }
    .filter-bar button, .filter-bar .btn { width: 100%; }
    .mini-stats { grid-template-columns: repeat(3, 1fr); }
    .sticky-actions { align-items: stretch; flex-direction: column; bottom: 8px; }
    .sticky-actions button { width: 100%; }
    .catalog-heading { align-items: flex-start; }
    .metric-badge { display: none; }
}

@media (max-width: 620px) {
    body { font-size: 14px; }
    h1 { font-size: 25px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats article { min-height: 94px; }
    .stats b { font-size: 25px; }
    .mini-stats { grid-template-columns: 1fr; }
    .mini-stats article { min-height: auto; }
    .media-upload-grid, .asset-gallery, .game-grid { grid-template-columns: 1fr; }

    .table-wrap { border: 0; overflow: visible; }
    .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap th, .table-wrap td, .table-wrap tr { display: block; }
    .table-wrap thead { display: none; }
    .table-wrap tbody { display: grid; gap: 10px; }
    .table-wrap tbody tr { padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.022); }
    .table-wrap tbody td { padding: 8px 9px; border: 0; }
    .table-wrap tbody td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: #6f7894; font-size: 9px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
    td.actions { white-space: normal; }
    td.actions form { display: inline-block; }
}

@media (min-width: 1700px) {
    main { padding-left: 50px; padding-right: 50px; }
    .game-grid { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); }
}


/* ========================================================================== 
   Dashboard, auth, install and app connection — Modern UI 2.1
   ========================================================================== */
.auth-page { position: relative; overflow-x: hidden; }
.auth-page::before, .auth-page::after { content:""; position:fixed; z-index:-1; border-radius:50%; pointer-events:none; }
.auth-page::before { width:440px; height:440px; left:-170px; top:-190px; background:radial-gradient(circle, rgba(139,92,246,.23), transparent 68%); }
.auth-page::after { width:520px; height:520px; right:-220px; bottom:-250px; background:radial-gradient(circle, rgba(34,211,238,.12), transparent 68%); }
.auth-shell { width:min(460px, 100%); display:grid; gap:18px; }
.auth-card-modern { position:relative; overflow:hidden; padding:38px; }
.auth-card-modern::before { content:""; position:absolute; inset:0 0 auto 0; height:1px; background:linear-gradient(90deg, transparent, rgba(139,92,246,.8), rgba(34,211,238,.6), transparent); }
.auth-brandline { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:34px; }
.auth-mark { display:grid; place-items:center; width:42px; height:42px; border:1px solid rgba(139,92,246,.36); border-radius:13px; background:linear-gradient(145deg, rgba(139,92,246,.26), rgba(34,211,238,.08)); box-shadow:0 10px 28px rgba(80,40,160,.18); font-weight:900; }
.auth-badge, .install-badge { display:inline-flex; align-items:center; min-height:28px; padding:5px 9px; border:1px solid var(--line); border-radius:999px; background:rgba(255,255,255,.035); color:#8994b1; font-size:9px; font-weight:850; letter-spacing:.14em; }
.auth-copy h1, .auth-copy h2 { margin:4px 0 8px; }
.auth-copy p { max-width:390px; }
.auth-form { margin-top:25px !important; }
.auth-form label { color:#c0c8db; }
.auth-submit { width:100%; min-height:48px; margin-top:3px; box-shadow:0 12px 28px rgba(109,40,217,.22); }
.auth-alert { margin-top:20px; }
.auth-security-line { display:flex; align-items:center; gap:9px; margin-top:23px; color:#66708a; font-size:10px; font-weight:700; text-align:center; }
.auth-security-line span { flex:1; height:1px; background:var(--line); }
.auth-footer, .panel-footer { color:#6f7894; font-size:11.5px; text-align:center; }
.auth-footer a, .panel-footer a { color:#c4b5fd; font-weight:800; }
.panel-footer { margin-top:30px; padding:22px 0 4px; border-top:1px solid var(--line); }
.install-shell { width:min(1040px, 100%); display:grid; grid-template-columns:minmax(0, 1.1fr) minmax(380px, .8fr); gap:52px; align-items:center; }
.install-intro { padding:22px 10px; }
.install-intro h1 { max-width:620px; margin:18px 0 14px; font-size:clamp(34px, 5vw, 58px); line-height:.98; }
.install-intro > p { max-width:620px; font-size:16px; }
.install-feature-list { display:grid; gap:12px; margin-top:34px; }
.install-feature-list > div { display:flex; gap:13px; align-items:flex-start; padding:13px 0; border-top:1px solid var(--line); }
.install-feature-list > div > span { display:grid; place-items:center; flex:0 0 34px; height:34px; border-radius:10px; background:rgba(139,92,246,.12); color:#c4b5fd; font-size:10px; font-weight:850; }
.install-feature-list p, .install-feature-list strong, .install-feature-list small { display:block; }
.install-feature-list small { margin-top:2px; }
.install-card { width:100%; }
.install-requirements { display:flex; flex-wrap:wrap; gap:6px; margin-top:22px; }
.install-requirements span { padding:5px 8px; border:1px solid var(--line); border-radius:8px; background:rgba(255,255,255,.025); color:#737e99; font-size:9.5px; font-weight:750; }
.install-footer { grid-column:1/-1; margin-top:-16px; }
.dashboard-grid { display:grid; grid-template-columns:minmax(0, 1.45fr) minmax(300px, .75fr); gap:16px; margin-top:16px; }
.dashboard-recent, .quick-card { min-height:100%; }
.recent-client-list { display:grid; gap:7px; margin-top:19px; }
.recent-client { display:grid; grid-template-columns:42px minmax(0,1fr) auto; gap:12px; align-items:center; padding:10px; border:1px solid transparent; border-radius:13px; color:inherit; transition:.16s ease; }
.recent-client:hover { border-color:var(--line); background:rgba(255,255,255,.028); color:inherit; }
.recent-avatar { display:grid; place-items:center; width:42px; height:42px; border:1px solid rgba(139,92,246,.2); border-radius:12px; background:linear-gradient(145deg, rgba(139,92,246,.16), rgba(34,211,238,.06)); color:#ddd6fe; font-size:13px; font-weight:850; }
.recent-main { min-width:0; }
.recent-main strong, .recent-main small { display:block; }
.recent-main strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12.5px; }
.recent-main small { margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10px; }
.recent-badges { display:flex; flex-wrap:wrap; gap:5px; justify-content:flex-end; }
.tag.warning { border-color:rgba(251,191,36,.22); background:rgba(251,191,36,.08); color:#fde68a; }
.compact-empty { margin-top:18px; padding:22px 15px; }
.quick-actions { display:grid; gap:8px; margin-top:19px; }
.quick-action { display:grid; grid-template-columns:38px 1fr; gap:11px; align-items:center; padding:11px; border:1px solid var(--line); border-radius:13px; background:rgba(255,255,255,.018); color:inherit; transition:.16s ease; }
.quick-action:hover { transform:translateY(-1px); border-color:rgba(139,92,246,.27); background:rgba(139,92,246,.055); color:inherit; }
.quick-icon { display:grid; place-items:center; width:38px; height:38px; border-radius:11px; background:rgba(139,92,246,.11); color:#c4b5fd; font-size:10px; font-weight:900; }
.quick-action strong, .quick-action small { display:block; }
.quick-action strong { font-size:12px; }
.quick-action small { margin-top:1px; font-size:9.8px; }
.connection-status { display:inline-flex; align-items:center; gap:7px; padding:7px 10px; border:1px solid rgba(52,211,153,.18); border-radius:999px; background:rgba(52,211,153,.055); color:#a7f3d0; font-size:10px; font-weight:800; white-space:nowrap; }
.connection-status i { width:7px; height:7px; border-radius:50%; background:var(--success); box-shadow:0 0 12px rgba(52,211,153,.55); }
.connection-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:21px; }
.connection-field { padding:16px; border:1px solid var(--line); border-radius:15px; background:rgba(255,255,255,.02); }
.connection-label { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
.connection-label span { color:#dbe2f5; font-size:12px; font-weight:800; }
.connection-label small { font-family:"SFMono-Regular",Consolas,monospace; font-size:9.5px; }
.copy-field { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; }
.copy-field input { min-width:0; margin:0; font-family:"SFMono-Regular",Consolas,monospace; font-size:11px; }
.copy-field button { min-width:76px; }
.copy-btn.copied, [data-copy-target].copied { border-color:rgba(52,211,153,.28); background:rgba(52,211,153,.10); color:#a7f3d0; }
.connection-field p { margin-top:9px; color:#68738e; font-size:10.5px; }
.app-json-box { margin-top:14px; padding:16px; border:1px solid var(--line); border-radius:15px; background:rgba(4,6,14,.48); }
.app-json-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.app-json-heading strong, .app-json-heading small { display:block; }
.app-json-heading small { margin-top:2px; font-size:9.5px; }
.app-json-box pre { margin-top:12px; }
.connection-tip { margin-top:14px; }
@media (max-width:900px) { .dashboard-grid,.connection-grid{grid-template-columns:1fr}.install-shell{grid-template-columns:1fr;gap:22px}.install-intro{padding:10px 4px}.install-intro h1{font-size:clamp(31px,9vw,48px)}.install-footer{margin-top:0} }
@media (max-width:620px) { body.centered{padding:14px;align-items:start}.auth-shell{margin-top:5vh}.auth-card-modern{padding:24px 20px;border-radius:21px}.auth-brandline{margin-bottom:26px}.install-shell{padding-top:5px}.recent-client{grid-template-columns:38px minmax(0,1fr)}.recent-avatar{width:38px;height:38px}.recent-badges{grid-column:2;justify-content:flex-start}.copy-field{grid-template-columns:1fr}.copy-field button{width:100%}.app-json-heading{align-items:flex-start;flex-direction:column}.app-json-heading button{width:100%}.connection-status{display:none} }

/* Validade de contas e teste grátis */
.trial-validity-preview{grid-column:1/-1;display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;padding:14px 16px;border:1px solid rgba(89,224,184,.22);border-radius:16px;background:linear-gradient(135deg,rgba(22,163,120,.11),rgba(37,99,235,.07));color:var(--muted)}
.trial-validity-preview span{font-size:.78rem;text-transform:uppercase;letter-spacing:.08em;font-weight:800}
.trial-validity-preview strong{color:#d9fff3;font-size:.95rem}
.trial-validity-preview small{width:100%;margin:0;color:var(--muted)}
.grid-form label small{display:block;margin-top:6px;color:var(--muted);font-size:.76rem;line-height:1.4}
@media(max-width:720px){.trial-validity-preview{padding:12px 13px}.trial-validity-preview strong{width:100%}}

/* ========================================================================== 
   Dashboard compacto, Perfil e navegação responsiva — UI 2.3
   ========================================================================== */
.header-main{display:flex;align-items:flex-start;gap:13px;min-width:0}
.header-main>div{min-width:0}
.menu-toggle{display:none;place-items:center;flex:0 0 42px;width:42px;height:42px;padding:0;border:1px solid var(--line);border-radius:13px;background:rgba(255,255,255,.035);color:#e8ecf8;box-shadow:none}
.menu-toggle svg,.quick-icon svg,.profile-note-icon svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.menu-backdrop{position:fixed;inset:0;z-index:39;width:100%;height:100%;background:rgba(2,4,12,.66);backdrop-filter:blur(4px);opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease,visibility .2s ease}

.dashboard-stack{display:grid;gap:16px;margin-top:18px}
.dashboard-stack>.card{margin-top:0}
.quick-card{min-height:auto}
.quick-actions{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;margin-top:19px}
.quick-action{min-width:0;min-height:94px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;padding:12px 8px;border:1px solid var(--line);border-radius:15px;background:rgba(255,255,255,.018);color:inherit;text-align:center;transition:transform .16s ease,border-color .16s ease,background .16s ease}
.quick-action:hover{transform:translateY(-2px);border-color:rgba(139,92,246,.30);background:rgba(139,92,246,.06);color:#fff}
.quick-icon{display:grid;place-items:center;width:40px;height:40px;border-radius:12px;background:linear-gradient(145deg,rgba(139,92,246,.16),rgba(34,211,238,.055));color:#c4b5fd}
.quick-action small{display:block;max-width:100%;margin:0;color:#bcc5da;font-size:10.5px;font-weight:800;line-height:1.2;white-space:normal}
.dashboard-recent{min-height:auto}

.profile-card{max-width:900px}
.profile-form{max-width:820px}
.profile-note{display:flex;align-items:center;gap:12px;padding:14px;border:1px solid rgba(52,211,153,.18);border-radius:15px;background:rgba(52,211,153,.055)}
.profile-note-icon{display:grid;place-items:center;flex:0 0 38px;width:38px;height:38px;border-radius:11px;background:rgba(52,211,153,.10);color:#a7f3d0}
.profile-note strong,.profile-note small{display:block}
.profile-note small{margin-top:2px}

@media (max-width:1100px){
  body.menu-open{overflow:hidden}
  .app-shell{display:block;min-height:100vh}
  aside#panel-sidebar{position:fixed;inset:0 auto 0 0;z-index:40;width:min(86vw,310px);height:100dvh;padding:16px 13px;border-right:1px solid var(--line);border-bottom:0;background:rgba(7,9,18,.97);box-shadow:24px 0 70px rgba(0,0,0,.42);backdrop-filter:blur(26px);transform:translateX(-104%);transition:transform .22s ease;overflow:hidden}
  body.menu-open aside#panel-sidebar{transform:translateX(0)}
  aside#panel-sidebar .brand{padding:12px 12px 18px;margin-bottom:8px;border-bottom:1px solid var(--line)}
  aside#panel-sidebar nav{display:flex;flex:1;min-height:0;flex-direction:column;flex-wrap:nowrap;gap:4px;overflow-x:hidden;overflow-y:auto;padding:4px 0 12px}
  aside#panel-sidebar nav a{flex:0 0 auto;width:100%;min-height:43px;padding:10px 13px 10px 16px;white-space:normal}
  aside#panel-sidebar nav a::before{display:block}
  aside#panel-sidebar .logout-form{margin-top:auto;padding-top:12px}
  aside#panel-sidebar button.logout{width:100%;min-height:42px}
  .menu-toggle{display:grid}
  .menu-backdrop{visibility:hidden;opacity:0;pointer-events:none}
  body.menu-open .menu-backdrop{visibility:visible;opacity:1;pointer-events:auto}
  main{max-width:none;padding-top:22px}
  main>header{align-items:flex-start}
  .two-col,.two-col.wide-left{grid-template-columns:1fr}
}

@media (max-width:760px){
  main{padding:15px 12px 46px}
  main>header{gap:12px}
  .header-main{width:100%;align-items:center}
  .header-main h1{margin-bottom:3px}
  main>header>.pill{width:100%;max-width:none}
  .card{padding:16px}
  .stats{gap:9px}
  .stats article{padding:14px}
  .quick-actions{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  .quick-action{min-height:84px;padding:10px 6px}
  .quick-icon{width:36px;height:36px}
  .quick-icon svg{width:20px;height:20px}
  .recent-client-list{margin-top:14px}
  .page-toolbar{overflow:hidden}
  .section-tabs{display:flex;max-width:100%;overflow-x:auto;flex-wrap:nowrap;scrollbar-width:none}
  .section-tabs::-webkit-scrollbar{display:none}
  .section-tab{flex:0 0 auto;white-space:nowrap}
  .row-actions{display:grid;grid-template-columns:1fr}
  .row-actions>*{width:100%}
  .card-heading{gap:12px}
  .profile-card{max-width:none}
}

@media (max-width:480px){
  .stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .quick-actions{grid-template-columns:repeat(3,minmax(0,1fr))}
  .quick-action small{font-size:9.8px}
  .recent-client{padding:9px}
  .card-heading{flex-direction:column}
  .card-heading .btn{width:100%}
  .profile-note{align-items:flex-start}
}

/* Security: somente o app.json pronto */
.security-json-only { width:100%; max-width:920px; margin:0 auto; }
.security-json-only pre { white-space:pre-wrap; overflow-wrap:anywhere; }
@media (max-width:620px) {
  .security-json-only { max-width:none; }
}


/* ========================================================================== 
   Layout stability patch — UI 2.3.3
   Prevents stale CSS / overlay elements from occupying the application grid.
   ========================================================================== */
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body { min-height: 100vh; }
.app-shell { isolation: isolate; }
.app-shell > main { position: relative; z-index: 1; }
#panel-sidebar { min-width: 0; }
.menu-backdrop[hidden] { display: none !important; }

/* The backdrop is outside .app-shell on purpose. Even if an old stylesheet is
   cached, it can no longer become a giant grid item in the content column. */
.menu-backdrop { cursor: default; }

@media (min-width: 1101px) {
  .app-shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  #panel-sidebar { transform: none !important; }
  .menu-toggle { display: none !important; }
  .menu-backdrop { display: none !important; }
  .app-shell > main { width: 100%; }
}

@media (max-width: 1100px) {
  .app-shell { display: block; width: 100%; min-height: 100vh; }
  .app-shell > main { display: block; width: 100%; }
  #panel-sidebar { overscroll-behavior: contain; }
}

@media (max-width: 760px) {
  main > header { width: 100%; }
  .header-main { min-width: 0; }
  .header-main > div { min-width: 0; }
  .header-main h1, .header-main p { overflow-wrap: anywhere; }
  .page-toolbar, .card, .stats, .dashboard-stack { min-width: 0; max-width: 100%; }
  .grid-form > *, .two-col > *, .two-col.wide-left > * { min-width: 0; }
  pre, code { max-width: 100%; }
}

/* Security connection flow — UI 2.4.1 */
.security-heading-modern{align-items:center;gap:18px;flex-wrap:wrap}
.security-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;flex-wrap:wrap;margin-left:auto}
.security-regenerate-form{margin:0}
.app-connection-state{display:inline-flex;align-items:center;gap:8px;min-height:36px;padding:0 12px;border:1px solid var(--line);border-radius:999px;background:rgba(255,255,255,.035);font-size:12px;font-weight:800;white-space:nowrap}
.app-connection-state .connection-dot{width:8px;height:8px;border-radius:50%;background:#f59e0b;box-shadow:0 0 0 4px rgba(245,158,11,.10)}
.app-connection-state.is-connected{border-color:rgba(34,197,94,.30);background:rgba(34,197,94,.08);color:#bbf7d0}
.app-connection-state.is-connected .connection-dot{background:#22c55e;box-shadow:0 0 0 4px rgba(34,197,94,.12)}
.app-connection-state.is-waiting{color:#fde68a}
.connection-meta{display:flex;align-items:center;gap:8px 18px;flex-wrap:wrap;margin-top:12px;padding:11px 13px;border:1px solid var(--line);border-radius:12px;background:rgba(255,255,255,.025);font-size:11px;color:var(--muted)}
.connection-meta strong{color:var(--text);font-weight:750;overflow-wrap:anywhere}
.security-help{margin:11px 2px 0;color:var(--muted);font-size:12px;line-height:1.5}
@media (max-width:760px){
  .security-heading-modern{align-items:stretch}
  .security-actions{width:100%;margin-left:0;justify-content:flex-start}
  .security-actions .compact-btn,.security-regenerate-form{flex:1 1 150px}
  .security-regenerate-form .compact-btn{width:100%}
  .app-connection-state{flex:1 1 100%;justify-content:center}
}

/* v1.12.23 — editor visual dos controles locais */
.controller-toolbar{align-items:flex-start;gap:18px}.controller-editor-card{overflow:hidden}.controller-editor-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:14px}.controller-editor-head>div:first-child{min-width:220px}.controller-editor-head strong{display:block;font-size:16px}.controller-editor-head small{display:block;color:var(--muted);margin-top:4px;line-height:1.4}.controller-core-picker{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:7px}.controller-core-pill{display:inline-flex;align-items:center;min-height:34px;padding:0 11px;border:1px solid rgba(255,255,255,.1);border-radius:999px;background:rgba(15,23,42,.72);color:var(--muted);font-size:10px;font-weight:800;text-decoration:none;transition:.16s ease}.controller-core-pill:hover{border-color:rgba(124,58,237,.55);color:#fff}.controller-core-pill.active{background:linear-gradient(135deg,rgba(124,58,237,.95),rgba(67,56,202,.92));border-color:rgba(255,255,255,.18);color:#fff;box-shadow:0 10px 28px rgba(76,29,149,.25)}.controller-designer-shell{width:100%;border:1px solid rgba(255,255,255,.09);border-radius:20px;overflow:hidden;background:#050914}.controller-designer-frame{display:block;width:100%;height:700px;border:0;background:#070b15}@media(max-width:1100px){.controller-editor-head{display:block}.controller-core-picker{justify-content:flex-start;margin-top:12px}.controller-designer-frame{height:950px}}@media(max-width:680px){.controller-core-pill{font-size:9px;padding:0 9px}.controller-designer-frame{height:1080px}.controller-editor-card{padding-left:9px;padding-right:9px}}
