:root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel-2: #1e222b;
    --border: #272c37;
    --text: #e7eaf0;
    --muted: #9aa3b2;
    --accent: #CC5500;
    --accent-2: #E06600;
    --green: #10b981;
    --red: #ef4444;
    --amber: #f59e0b;
    --radius: 12px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
small { color: var(--muted); }

/* Layout ---------------------------------------------------------------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 232px; flex-shrink: 0; background: var(--panel);
    border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 6px 8px 22px; }
.brand-logo { height: 30px; width: auto; max-width: 165px; display: block; }
.brand-sub { color: var(--muted); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600; }
.feed-switch { padding: 0 8px 16px; }
.feed-switch label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 5px; }
.feed-switch select { width: 100%; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
    color: var(--muted); padding: 10px 12px; border-radius: 9px; font-weight: 500;
}
.sidebar nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.who { color: var(--muted); font-size: 12px; margin-bottom: 6px; word-break: break-all; }
.logout { font-size: 13px; }

.main { flex: 1; padding: 28px 32px; max-width: 1480px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.page-head .sub { color: var(--muted); }

/* Flash ----------------------------------------------------------------- */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; border: 1px solid; }
.flash-success { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.4); color: #6ee7b7; }
.flash-error { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.4); color: #fca5a5; }

/* Cards / stats --------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat .delta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.two-col { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .main { padding: 20px; } .sidebar { width: 200px; } }

/* Tables ---------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.logo-chip {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 4px 6px; height: 40px; min-width: 56px; max-width: 150px;
}
.logo-chip img { max-height: 32px; max-width: 130px; width: auto; height: auto; object-fit: contain; display: block; }

/* Asset gallery --------------------------------------------------------- */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.asset-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 9px; }
.asset-thumb {
    display: flex; align-items: center; justify-content: center; height: 128px; border-radius: 8px; overflow: hidden;
    background: repeating-conic-gradient(rgba(255,255,255,.04) 0% 25%, transparent 0% 50%) 50% / 18px 18px, var(--panel-2);
}
.asset-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* Deploy / embed modal ------------------------------------------------- */
dialog.gf-modal { border: none; border-radius: 14px; background: var(--panel); color: var(--text); max-width: 620px; width: 92%; padding: 22px; box-shadow: 0 24px 70px rgba(0,0,0,.55); }
dialog.gf-modal::backdrop { background: rgba(0,0,0,.62); }
.gf-modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.gf-modal-head strong { font-size: 16px; }
.gf-snip { margin-bottom: 14px; }
.gf-snip-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.gf-snip textarea { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; line-height: 1.45; resize: vertical; }
.gf-note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.asset-link { text-decoration: none; color: inherit; transition: border-color .15s; }
.asset-link:hover { border-color: var(--accent); text-decoration: none; }
.asset-meta { min-width: 0; }
.asset-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* Badges + pills -------------------------------------------------------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-gray { background: var(--panel-2); color: var(--muted); }
.badge-info { background: rgba(204,85,0,.2); color: #f2b083; }
.badge-warn { background: rgba(245,158,11,.16); color: #fcd34d; }
.badge-ok { background: rgba(16,185,129,.16); color: #6ee7b7; }

/* Checkbox grid (feed assignment) ------------------------------------- */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; }
.check-item { display: flex; align-items: center; gap: 9px; padding: 6px 4px; font-size: 13px; }
.check-item input { width: 16px; height: 16px; flex-shrink: 0; }
.check-item.is-disabled { opacity: .5; }

/* Buttons --------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
    font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #3a414f; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { background: transparent; border-color: rgba(239,68,68,.5); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,.12); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Row action buttons: one line on desktop, 2-per-row grid on mobile. */
.row-actions { display: flex; gap: 8px; flex-wrap: nowrap; align-items: center; }
@media (max-width: 640px) {
    .row-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .row-actions > a, .row-actions > form { display: block; width: 100%; }
    .row-actions .btn { width: 100%; justify-content: center; }
}

/* Game row actions (Copy / Deploy / Assets): right-aligned inline on desktop,
   tidy full-width stack on narrow screens. */
.game-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
@media (max-width: 640px) {
    .game-actions { display: grid; grid-template-columns: 1fr; }
    .game-actions .btn { width: 100%; justify-content: center; }
}

/* Toggle switch (submits a form) --------------------------------------- */
.switch { border: none; background: none; padding: 0; cursor: pointer; }
.switch .track {
    width: 42px; height: 24px; border-radius: 999px; background: #39404d; position: relative;
    transition: background .15s; display: inline-block;
}
.switch .track::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
    border-radius: 50%; background: #fff; transition: transform .15s;
}
.switch.on .track { background: var(--green); }
.switch.on .track::after { transform: translateX(18px); }

/* Forms ----------------------------------------------------------------- */
.form { max-width: 620px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--panel-2); color: var(--text); font-size: 14px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: 18px; height: 18px; }
.logo-preview { height: 60px; margin-top: 10px; border-radius: 8px; background: #fff; padding: 4px; }

/* URL list -------------------------------------------------------------- */
.url-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.url-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.url-row:last-child { border-bottom: none; }
.url-row .u { color: var(--muted); font-size: 12px; word-break: break-all; }

/* Login ----------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; padding-bottom: 26px; }

/* Simple bar chart ------------------------------------------------------ */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; }
.bars .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .bar:hover { background: var(--accent-2); }
.hbar-row { display: grid; grid-template-columns: 130px 1fr 48px; align-items: center; gap: 10px; margin-bottom: 9px; }
.hbar-track { background: var(--panel-2); border-radius: 6px; height: 20px; overflow: hidden; }
.hbar-fill { background: var(--accent); height: 100%; border-radius: 6px; }
.chart-note { color: var(--muted); font-size: 12px; margin-top: 10px; }
