/* Mister Admin — Apple-style design system */
:root {
  --bg: #eef1f6; --panel: rgba(255,255,255,.62); --panel-2: rgba(255,255,255,.45); --panel-solid: #ffffff; --glass-border: rgba(255,255,255,.75); --glass-shine: rgba(255,255,255,.55); --text: #1d1d1f; --text-2: #6e6e73; --muted: #86868b;
  --line: rgba(0,0,0,.08); --line-2: rgba(0,0,0,.14);
  --primary: #0071e3; --primary-hover: #0077ed; --primary-soft: rgba(0,113,227,.10);
  --danger: #ff3b30; --danger-soft: rgba(255,59,48,.10); --ok: #34c759; --ok-soft: rgba(52,199,89,.14); --warn: #ff9f0a; --warn-soft: rgba(255,159,10,.16);
  --r-sm: 10px; --r: 14px; --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
  --shadow: 0 2px 6px rgba(0,0,0,.05), 0 12px 32px rgba(0,0,0,.06);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Inter, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0b10; --panel: rgba(36,36,42,.55); --panel-2: rgba(60,60,70,.45); --panel-solid: #1c1c1e; --glass-border: rgba(255,255,255,.12); --glass-shine: rgba(255,255,255,.08); --text: #f5f5f7; --text-2: #a1a1a6; --muted: #86868b;
    --line: rgba(255,255,255,.10); --line-2: rgba(255,255,255,.18); --primary: #0a84ff; --primary-hover: #3395ff; --primary-soft: rgba(10,132,255,.18);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.5); --shadow: 0 2px 8px rgba(0,0,0,.5); --shadow-lg: 0 24px 64px rgba(0,0,0,.7); }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.015em; line-height: 1.15; font-weight: 700; }
h1 { font-size: 2rem; letter-spacing: -0.025em; } h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85em; background: var(--panel-2); padding: .15em .45em; border-radius: 6px; border: 1px solid var(--line); word-break: break-all; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.centered { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.hidden { display: none !important; }
.spacer { flex: 1; }
::selection { background: var(--primary-soft); }

/* ---------- Liquid glass backdrop ---------- */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 600px at 8% -10%, rgba(120,170,255,.55), transparent 60%),
    radial-gradient(800px 600px at 100% 0%, rgba(255,150,210,.45), transparent 60%),
    radial-gradient(900px 700px at 60% 110%, rgba(140,230,200,.45), transparent 60%),
    var(--bg); }
@media (prefers-color-scheme: dark) { body::before { background:
    radial-gradient(900px 600px at 8% -10%, rgba(40,90,200,.45), transparent 60%),
    radial-gradient(800px 600px at 100% 0%, rgba(170,60,140,.35), transparent 60%),
    radial-gradient(900px 700px at 60% 110%, rgba(30,140,110,.35), transparent 60%),
    var(--bg); } }
.glass, .card, .sidebar, .topbar, .modal, .sticky-actions, .item, .media-tile, .sb-section, .dropzone, .switch, .empty, .toast, .choice {
  backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-shine), var(--shadow-sm);
}
.card, .modal { box-shadow: inset 0 1px 0 var(--glass-shine), var(--shadow); }
.modal { background: color-mix(in srgb, var(--panel-solid) 78%, transparent); }
.item-body, .sb-fields { background: color-mix(in srgb, var(--panel-solid) 35%, transparent); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], textarea, select { background: color-mix(in srgb, var(--panel-solid) 70%, transparent); }
.sidebar a.active { box-shadow: 0 4px 14px rgba(0,113,227,.35); }
.btn { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn-primary { background: linear-gradient(180deg, #2b8cff, #0071e3); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 4px 14px rgba(0,113,227,.35); }
.btn-primary:hover { background: linear-gradient(180deg, #3d97ff, #0a7bf0); }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .9rem; height: 56px; padding: 0 1.25rem; background: var(--panel); border-radius: 0; border-left: 0; border-right: 0; border-top: 0; backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; display: flex; align-items: center; gap: .55rem; color: var(--text); font-size: 1rem; letter-spacing: -0.01em; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(145deg, #2997ff, #0a5bd6); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .95rem; box-shadow: inset 0 -1px 0 rgba(0,0,0,.15); }
.topbar .site-name { font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: .5rem; }
.topbar .site-name::before { content: "›"; color: var(--muted); font-weight: 400; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 56px); }
.sidebar { padding: 1.25rem .9rem; background: var(--panel-2); border-radius: 0; border-top: 0; border-left: 0; border-bottom: 0; }
.sidebar h4 { margin: 1.25rem .75rem .4rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.sidebar h4:first-child { margin-top: 0; }
.sidebar a { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem; border-radius: var(--r-sm); color: var(--text); font-weight: 500; transition: background .12s; }
.sidebar a:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.sidebar a.active { background: var(--primary); color: #fff; }
.sidebar a .ico { width: 20px; text-align: center; opacity: .8; }
.main { padding: 2rem 2.25rem 6rem; max-width: 980px; width: 100%; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .25rem; padding: .6rem; }
  .sidebar h4 { width: 100%; margin: .3rem .5rem 0; }
  .sidebar a { padding: .4rem .7rem; }
  .main { padding: 1.25rem 1rem 6rem; }
  h1 { font-size: 1.6rem; }
}
.page-head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { flex: 1; }
.page-head .sub { width: 100%; color: var(--text-2); margin-top: -.5rem; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.5rem; box-shadow: var(--shadow-sm); margin-bottom: 1.1rem; }
.card.compact { padding: .9rem 1.1rem; border-radius: var(--r); }
.card h3 { margin-bottom: .35rem; }
.card .lead { color: var(--text-2); margin-bottom: 1rem; }
.auth-card { width: 100%; max-width: 420px; padding: 2rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.site-card { display: block; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; position: relative; }
.site-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.site-card h3 { font-size: 1.2rem; margin-bottom: .2rem; }
.site-card .url { color: var(--text-2); font-size: .9rem; margin-bottom: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-card .arrow { position: absolute; right: 1.25rem; top: 1.4rem; color: var(--muted); font-size: 1.3rem; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text-2); }
.badge-warn { background: var(--warn-soft); color: #b36b00; } @media (prefers-color-scheme: dark) { .badge-warn { color: var(--warn); } }
.badge-ok { background: var(--ok-soft); color: #1f8a3c; } @media (prefers-color-scheme: dark) { .badge-ok { color: var(--ok); } }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Forms ---------- */
label.field, .field { display: block; margin-bottom: 1.1rem; }
.lbl { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .35rem; color: var(--text); }
.field .help { display: block; color: var(--muted); font-size: .8rem; margin-top: .35rem; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], textarea, select {
  width: 100%; padding: .7rem .85rem; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-sm); transition: border-color .12s, box-shadow .12s; -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
input:disabled, textarea:disabled, select:disabled { opacity: .6; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .83rem; min-height: 320px; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > * { margin-bottom: 0; }
.check { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.color-row input[type=color] { width: 44px; height: 40px; padding: 2px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--panel); }
/* iOS-style switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem .9rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; }
.switch .lbl { margin: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .knob { width: 51px; height: 31px; border-radius: 999px; background: #e9e9eb; position: relative; transition: background .2s; flex: none; }
@media (prefers-color-scheme: dark) { .switch .knob { background: #39393d; } }
.switch .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .2s; }
.switch input:checked + .knob { background: var(--ok); }
.switch input:checked + .knob::after { transform: translateX(20px); }
.switch input:focus-visible + .knob { box-shadow: 0 0 0 4px var(--primary-soft); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem 1.1rem; font: inherit; font-weight: 600; font-size: .92rem; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); cursor: pointer; transition: background .12s, transform .05s, box-shadow .12s; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(0,113,227,.3); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: transparent; background: var(--danger-soft); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { padding: .4rem .8rem; font-size: .85rem; }
.btn-lg { padding: .85rem 1.6rem; font-size: 1.02rem; }
.btn-icon { padding: .35rem .55rem; min-width: 34px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------- Items (lists / menus) ---------- */
.item { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: .6rem; background: var(--panel); box-shadow: var(--shadow-sm); overflow: hidden; }
.item-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; cursor: pointer; user-select: none; }
.item-head:hover { background: var(--panel-2); }
.item-head .chev { color: var(--muted); width: 14px; font-size: .8rem; transition: transform .15s; }
.item-head .chev.open { transform: rotate(90deg); }
.item-head .title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-head .tools { display: flex; gap: .15rem; opacity: .55; transition: opacity .12s; }
.item-head:hover .tools, .item.open .tools { opacity: 1; }
.item-body { padding: 1rem 1.1rem 1.1rem; border-top: 1px solid var(--line); background: var(--panel); }
.tree-children { margin-left: 1.25rem; border-left: 2px solid var(--line); padding-left: .75rem; margin-top: .5rem; }
.empty { padding: 2.5rem 1.5rem; text-align: center; color: var(--text-2); border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); background: var(--panel); }
.empty .big { font-size: 2.2rem; margin-bottom: .4rem; }
.empty h3 { margin-bottom: .3rem; }

/* ---------- Images ---------- */
.img-field { display: flex; gap: 1rem; align-items: flex-start; }
.thumb { width: 104px; height: 104px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel-2); flex: none; }
.thumb.placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .78rem; }
.gallery { display: flex; flex-wrap: wrap; gap: .6rem; }
.gallery .g-item { position: relative; width: 104px; }
.gallery .g-item .g-tools { display: flex; gap: 2px; justify-content: center; margin-top: 3px; }
.media-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.media-tile { border-radius: var(--r); overflow: hidden; background: var(--panel); cursor: pointer; border: 1px solid var(--line); transition: transform .12s, box-shadow .12s; }
.media-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.media-tile.selected { outline: 3px solid var(--primary); outline-offset: -3px; }
.media-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--panel-2); }
.media-tile .meta { padding: .4rem .6rem; font-size: .76rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); padding: 2rem 1.5rem; text-align: center; color: var(--text-2); margin-bottom: 1rem; background: var(--panel); cursor: pointer; transition: border-color .12s, background .12s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .big { font-size: 2rem; margin-bottom: .3rem; }
.dropzone strong { color: var(--text); font-size: 1.02rem; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: .45rem; }
.progress > div { height: 100%; background: var(--primary); transition: width .2s; border-radius: 3px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

/* ---------- Template picker / choice cards ---------- */
.choices { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.choice { border: 1.5px solid var(--line-2); border-radius: var(--r); padding: 1rem .9rem; cursor: pointer; background: var(--panel); transition: border-color .12s, background .12s; text-align: left; font: inherit; color: var(--text); }
.choice:hover { border-color: var(--primary); }
.choice.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.choice .ico { font-size: 1.6rem; margin-bottom: .3rem; }
.choice strong { display: block; margin-bottom: .15rem; }
.choice span { font-size: .8rem; color: var(--text-2); line-height: 1.35; display: block; }
.steps { display: flex; gap: .4rem; margin-bottom: 1.25rem; }
.steps span { height: 4px; flex: 1; border-radius: 2px; background: var(--line-2); }
.steps span.done { background: var(--primary); }

/* ---------- Schema builder ---------- */
.sb-section { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); margin-bottom: .75rem; box-shadow: var(--shadow-sm); }
.sb-head { display: flex; align-items: center; gap: .6rem; padding: .75rem .9rem; }
.sb-head .title { flex: 1; font-weight: 600; }
.sb-fields { border-top: 1px solid var(--line); padding: .5rem .9rem .9rem; }
.sb-field { display: grid; grid-template-columns: 1fr 150px auto auto; gap: .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.sb-field:last-of-type { border-bottom: 0; }
@media (max-width: 640px) { .sb-field { grid-template-columns: 1fr 1fr; } }
.sb-field .mini { font-size: .8rem; color: var(--muted); }
.disclosure { border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: .3rem; }

/* ---------- Modal / toast / sticky bar ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.96) translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal { background: var(--panel); border-radius: var(--r-lg); width: 100%; max-width: 540px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.modal-wide { max-width: 960px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem .5rem; }
.modal-head h3 { font-size: 1.25rem; }
.modal-body { padding: .75rem 1.25rem 1.25rem; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem 1.25rem; }
#toasts { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: var(--panel); color: var(--text); padding: .7rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow); border: 1px solid var(--line); opacity: 0; transform: translateY(-10px); transition: all .25s; max-width: 90vw; font-weight: 500; display: flex; align-items: center; gap: .5rem; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); color: #fff; border-color: transparent; }
.toast-success { background: var(--ok); color: #fff; border-color: transparent; }
.error-list { color: var(--danger); margin: 0 0 1rem; padding: .9rem 1rem .9rem 2rem; background: var(--danger-soft); border-radius: var(--r); }
.sticky-actions { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--panel); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border: 1px solid var(--line); border-radius: 999px; padding: .5rem .6rem .5rem 1rem; display: flex; gap: .8rem; align-items: center; box-shadow: var(--shadow); z-index: 15; white-space: nowrap; }
.sticky-actions .btn { padding: .55rem 1.4rem; }
