:root {
  --primary: #b07d2c;
  --bg: #f6f4f7;
  --surface: #ffffff;
  --text: #22202a;
  --muted: #6b6775;
  --border: #e2dee6;
  --danger: #b3261e;
  --ok: #1e7b4a;
  --warn: #9a6200;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 16px rgba(0, 0, 0, .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.small { font-size: .85rem; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; gap: .4em; padding: .55em 1em; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: .3em .7em; font-size: .85rem; }
.btn-icon { background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1; padding: .2em .4em; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.actions-left { justify-content: flex-start; }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label { font-weight: 600; font-size: .9rem; }
.hint { color: var(--muted); font-size: .8rem; }
input, select, textarea { font: inherit; padding: .55em .7em; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=color] { padding: 2px; height: 2.4em; width: 5em; }
textarea { resize: vertical; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; min-height: 14em; }
.check { display: flex; align-items: center; gap: .4rem; font-weight: normal; margin: .3rem 0; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .4rem; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; margin-bottom: 1rem; }
.alert { padding: .8rem 1rem; border-radius: 8px; margin: .8rem 0; border: 1px solid; }
.alert-error { background: #fdecea; border-color: #f5c2bd; color: #6b1510; }
.alert-ok { background: #e7f5ed; border-color: #b9e2c8; color: #12462a; }
.alert-warn { background: #fff4e0; border-color: #f2d39b; color: #5c3b00; }
.badge { display: inline-block; padding: .1em .55em; border-radius: 99px; font-size: .78rem; background: #ece8ef; color: var(--text); margin: 0 .2em .2em 0; }
.badge-ok { background: #dff1e6; color: var(--ok); }
.badge-err { background: #fbe1df; color: var(--danger); }
.badge-warn { background: #fdefd3; color: var(--warn); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-size: .9rem; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.wrap { word-break: break-word; max-width: 28rem; }
@media (max-width: 720px) {
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border: 1px solid var(--border); border-radius: 8px; margin-bottom: .6rem; padding: .3rem .5rem; background: var(--surface); }
  .table-wrap td { border: 0; padding: .25rem 0; }
  .table-wrap td::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; }
}

/* Toasts & modal */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 1000; max-width: min(28rem, calc(100vw - 2rem)); }
.toast { padding: .7rem 1rem; border-radius: 8px; color: #fff; background: var(--ok); box-shadow: var(--shadow); }
.toast-error { background: var(--danger); }
.toast-warn { background: var(--warn); }
dialog.modal { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 1.5rem)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog.modal-wide { width: min(980px, calc(100vw - 1.5rem)); }
dialog::backdrop { background: rgba(20, 16, 24, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1.2rem; max-height: calc(100vh - 8rem); overflow: auto; }

/* Auth / setup pages */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-box { width: min(440px, 100%); }
.auth-box.wide { width: min(720px, 100%); }
.auth-logo { max-height: 70px; max-width: 220px; display: block; margin: 0 auto 1rem; }
.auth-title { text-align: center; }
.steps { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.steps span { flex: 1; min-width: 6rem; text-align: center; font-size: .8rem; padding: .35rem; border-radius: 6px; background: #ece8ef; color: var(--muted); }
.steps span.active { background: var(--primary); color: #fff; }
.steps span.done { background: #dff1e6; color: var(--ok); }
.report { list-style: none; padding: 0; margin: .6rem 0; }
.report li { padding: .2rem 0; }
.report li::before { content: "• "; }

/* Admin layout */
.admin { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: #2a2a2e; color: #e8e2ec; padding: 1rem .7rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem 1rem; color: #fff; font-weight: 700; }
.sidebar .brand img { max-height: 36px; max-width: 60px; }
.sidebar nav a { display: block; padding: .55rem .8rem; border-radius: 8px; color: #e8e2ec; text-decoration: none; margin-bottom: 2px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #a99fb0; margin: 1rem .8rem .3rem; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar .user { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.menu-toggle { display: none; }
.content { padding: 1.2rem; max-width: 1200px; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.toolbar input, .toolbar select { width: auto; flex: 1 1 10rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.stat .num { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: .6rem 1rem; font: inherit; cursor: pointer; border-bottom: 3px solid transparent; color: var(--muted); }
.tabs button.active { border-color: var(--primary); color: var(--text); font-weight: 600; }
.matrix th.rot { white-space: nowrap; }
.matrix td { text-align: center; }
.matrix td:first-child { text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: #ece8ef; border-radius: 99px; padding: .15rem .3rem .15rem .7rem; font-size: .85rem; }
.chip button { border: 0; background: none; cursor: pointer; font-size: 1rem; color: var(--muted); }
.img-slot { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.img-slot .preview { width: 160px; height: 100px; border: 1px dashed var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; }
.img-slot .preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
iframe.preview { width: 100%; min-height: 420px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
pre.json { white-space: pre-wrap; word-break: break-word; font-size: .78rem; margin: 0; max-width: 30rem; }

@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-toggle { display: inline-flex; }
  .content { padding: .8rem; }
}

/* Public site */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .inner, .site-section, .site-footer .inner { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.site-header .inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-header .logos { display: flex; align-items: center; gap: 1rem; }
.site-header img { max-height: 54px; max-width: 160px; }
.site-header nav { display: flex; gap: .5rem; flex-wrap: wrap; }
.hero { background: linear-gradient(135deg, var(--primary), #2a2a2e); color: #fff; padding: 4rem 1rem; text-align: center; background-size: cover; background-position: center; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 3rem); }
.hero .btn { font-size: 1.05rem; }
.hero .cta { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; }
.hero .btn:not(.btn-primary) { background: rgba(255,255,255,.92); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.site-footer { background: #2a2a2e; color: #d9d2de; margin-top: 2rem; font-size: .9rem; }
.site-footer a { color: #fff; }
.prewrap { white-space: pre-wrap; }
