/* Admin, superadmin and sign-in pages. Mobile first. */
:root {
  --bg: #f3f5f9; --panel: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #2563eb; --brand-ink: #ffffff; --danger: #dc2626; --ok: #15803d; --radius: 12px;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
code { background: #eef2f7; padding: .1em .35em; border-radius: 4px; font-size: .92em; }
h1 { font-size: 1.4rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.text-error { color: var(--danger); }
.mt { margin-top: 1rem; }

/* Controls */
input, select, textarea { width: 100%; font: inherit; color: inherit; padding: .6rem .7rem; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; }
input[type=color] { padding: 2px; height: 42px; width: 56px; }
input[type=checkbox], input[type=radio] { width: auto; margin-right: .4rem; }
textarea { min-height: 3.2rem; resize: vertical; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .8rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
label.inline { display: inline-flex; align-items: center; font-weight: 500; margin-right: 1rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 42px; padding: .5rem .9rem; font: 600 .95rem/1 system-ui, sans-serif; color: var(--ink); background: #fff; border: 1px solid #cbd5e1; border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: .3rem .6rem; font-size: .85rem; }
.alert { padding: .7rem .9rem; border-radius: 10px; margin: 0 0 1rem; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-ok { background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; }
.row { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1 1 200px; }

/* Sign-in */
body.auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, #0f172a, #1e3a8a); }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; padding: 1.6rem; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-card h1 { margin-bottom: 0; }
.auth-card p.muted { margin-top: .2rem; }

/* Superadmin */
.sa-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 16px; background: #0f172a; color: #fff; }
.sa-top .brand { color: #fff; font-weight: 700; text-decoration: none; }
.sa-top form { display: flex; align-items: center; gap: .5rem; }
.sa-top .btn-ghost { color: #fff; }
.sa-main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.sa-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.grid2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 800px) { .grid2 { grid-template-columns: 1fr 1fr; } .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; } .span2 { grid-column: span 2; } }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr.dim td { opacity: .55; }
.chip { display: inline-block; padding: .15rem .5rem; margin: 0 .25rem .25rem 0; border-radius: 999px; background: #e0e7ff; color: #1e3a8a; font-size: .8rem; text-decoration: none; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; vertical-align: middle; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-suspended { background: #fef3c7; color: #92400e; }
.badge-archived { background: #e2e8f0; color: #475569; }
.steps { margin: 0; padding-left: 1.2rem; }
.steps li { margin-bottom: .3rem; }
ul.plain { list-style: none; padding: 0; margin: 0 0 .8rem; }

/* Admin app */
body.admin { padding-bottom: 80px; }
.topbar { position: sticky; top: 0; z-index: 20; background: #0f172a; color: #fff; padding: .4rem 12px; padding-top: max(.4rem, env(safe-area-inset-top)); box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.topbar-row { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
.topbar .brand { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30%; }
.topbar .btn-ghost { color: #fff; }
.topbar .status { flex: 1; color: #cbd5e1; font-size: .85rem; }
.tv-select { flex: 1; min-width: 0; font-weight: 700; background: #1e293b; color: #fff; border-color: #334155; }
.dropdown { position: absolute; right: 12px; top: 100%; min-width: 250px; background: #fff; color: var(--ink); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25); overflow: hidden; }
.dropdown button { display: block; width: 100%; text-align: left; padding: .85rem 1rem; font: inherit; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.dropdown form { margin: 0; }
.wrap { max-width: 820px; margin: 0 auto; padding: 12px; }
.preview-wrap { position: sticky; top: 104px; z-index: 10; margin: 0 -12px 10px; padding: 0 12px 6px; background: var(--bg); }
.preview { width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
@media (max-height: 560px) { .preview-wrap { position: static; } }
.tabs { display: flex; gap: .4rem; margin: 6px 0 12px; }
.tab { flex: 1; padding: .7rem; font: 600 .95rem system-ui; border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.slots { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: slot; }
.slot { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.slot.off { opacity: .6; }
.slot.over { border-style: dashed; }
.slot-head { display: flex; align-items: center; gap: .6rem; padding: .5rem; cursor: pointer; }
.slot-num { counter-increment: slot; width: 26px; text-align: center; color: var(--muted); font-weight: 700; }
.slot-num::before { content: counter(slot); }
.slot-thumb { width: 64px; height: 48px; border-radius: 8px; object-fit: cover; background: #e2e8f0; flex: none; }
.slot-info { flex: 1; min-width: 0; }
.slot-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-info span { font-size: .85rem; color: var(--muted); }
.slot-body { padding: .2rem .8rem .8rem; border-top: 1px solid var(--line); }
.slot-tools { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.pick { display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; padding: .5rem .6rem; margin: .3rem 0 .8rem; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 10px; font: inherit; cursor: pointer; }
.pick img { width: 54px; height: 40px; border-radius: 6px; object-fit: cover; }
.pick .grow { flex: 1; min-width: 0; }
.switch { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
details.style { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .8rem; margin-top: .4rem; }
details.style > summary { cursor: pointer; font-weight: 700; padding: .3rem 0; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.stepper { display: flex; align-items: center; gap: .3rem; margin-top: .3rem; }
.stepper button { width: 44px; height: 42px; flex: none; font: 700 1.3rem/1 system-ui; border: 1px solid #cbd5e1; background: #f8fafc; border-radius: 10px; cursor: pointer; }
.stepper input { text-align: center; padding: .55rem .2rem; }
.colors { display: flex; gap: .6rem; align-items: center; margin-top: .3rem; }
.toggles { display: flex; gap: .4rem; margin: .3rem 0 .8rem; }
.toggles button { min-width: 44px; height: 40px; border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; font: 700 1rem Georgia, serif; cursor: pointer; }
.toggles button.on { background: var(--ink); color: #fff; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; margin-bottom: 12px; }
.section h3 { margin: 0 0 .7rem; font-size: 1rem; }

/* Bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-panel { width: 100%; max-width: 820px; max-height: 88vh; display: flex; flex-direction: column; background: #fff; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 820px) { .sheet { align-items: center; } .sheet-panel { border-radius: 16px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: .6rem .6rem .6rem 1rem; border-bottom: 1px solid var(--line); }
.sheet-body { overflow-y: auto; padding: .8rem 1rem 1.2rem; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist h4 { margin: .8rem 0 .3rem; font-size: .8rem; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.plist button { display: flex; width: 100%; justify-content: space-between; gap: 1rem; padding: .75rem .4rem; font: inherit; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.plist button.sel { background: #eff6ff; font-weight: 700; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo-grid button { position: relative; padding: 0; border: 3px solid transparent; border-radius: 10px; overflow: hidden; background: #e2e8f0; aspect-ratio: 4 / 3; cursor: pointer; }
.photo-grid button.sel { border-color: var(--brand); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .del { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 26px; }
.upload { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.upload label { margin: 0; }
.upload input[type=file] { display: none; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; max-width: 92vw; padding: .7rem 1rem; border-radius: 10px; background: #0f172a; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.toast.error { background: var(--danger); }
.field { margin-bottom: .8rem; }
.field-label { display: block; font-weight: 600; font-size: .9rem; }
.tab-icon { flex: 0 0 auto; padding: .7rem .8rem; font-size: .85rem; }
@media (max-width: 600px) { .topbar .brand { display: none; } }
