:root {
  --maroon: #603336; --maroon-deep: #4a2629; --amber: #f3a253; --cream: #fbf4ea;
  --ink: #2b1b1c; --muted: #7a6667; --line: #e6d8c7; --ok: #2f7a45; --warn: #a86b12; --bad: #b3261e;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); font-size: 16px; line-height: 1.5; }
a { color: var(--maroon); }
h1 { font-size: 1.8rem; margin: 0 0 .5rem; color: var(--maroon); }
h2 { font-size: 1.25rem; margin: 0 0 .75rem; color: var(--maroon); }
h3 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
code { background: #fff; padding: .1rem .35rem; border-radius: 4px; }

/* Top bar */
.top { position: fixed; top: 0; left: 0; right: 0; height: 60px; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: 0 1rem; background: var(--maroon); color: #fff; }
.top .logo { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 800; }
.top .logo img { height: 30px; filter: brightness(0) invert(1); }
.top-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.top .btn.ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; }

/* Side nav */
.side { position: fixed; top: 60px; bottom: 0; left: 0; width: 240px; overflow-y: auto; background: #fff; border-right: 1px solid var(--line); padding: .75rem .5rem 2rem; z-index: 15; }
.side a { display: flex; gap: .6rem; align-items: center; padding: .5rem .75rem; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; }
.side a span { width: 1.4rem; text-align: center; }
.side a:hover { background: var(--cream); }
.side a.on { background: var(--maroon); color: #fff; }
.side .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 1rem .75rem .3rem; font-weight: 700; }
.side form { padding: 1rem .75rem 0; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }

main.with-nav { margin-left: 240px; padding: 84px 2rem 4rem; max-width: 1200px; }
main.bare { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
@media (max-width: 860px) {
  .menu-btn { display: block; }
  .top .logo span, .top .btn.ghost { display: none; }
  .side { transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.1); }
  body.nav-open .side { transform: none; }
  main.with-nav { margin-left: 0; padding: 76px 1rem 4rem; }
}

/* Cards and forms */
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 1.25rem; }
.form-grid .wide, .form-grid .save-bar { grid-column: 1 / -1; }
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field small { display: block; color: var(--muted); font-size: .82rem; margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=time], input[type=datetime-local], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: .6rem .75rem; border: 1px solid #cdbca8; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus, .pell-content:focus { outline: 2px solid var(--amber); outline-offset: 0; border-color: var(--amber); }
.meta { color: var(--muted); font-size: .88rem; margin: -.25rem 0 1rem; }

/* Rich text */
.rte { border: 1px solid #cdbca8; border-radius: 8px; overflow: hidden; background: #fff; }
.pell-actionbar { background: #faf5ee; border-bottom: 1px solid var(--line); padding: 2px; display: flex; flex-wrap: wrap; }
.pell-button { width: 36px; height: 34px; border-radius: 6px; font-weight: 700; color: var(--ink); }
.pell-button:hover { background: #fff; }
.pell-button-selected { background: var(--amber); }
.pell-content { min-height: 120px; height: auto; max-height: 500px; padding: .5rem .9rem; }
.pell-content p { margin: .5rem 0; }

/* Images */
.image-pick { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.image-pick img { max-width: 160px; max-height: 100px; border-radius: 8px; border: 1px solid var(--line); background: #fff; object-fit: contain; }

/* Repeaters */
.repeater .rows { display: grid; gap: .75rem; margin-bottom: .75rem; }
.row { display: grid; grid-template-columns: 1fr auto; gap: .75rem; background: #fdfaf6; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.row-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 .75rem; }
.row-fields .wide { grid-column: 1 / -1; }
.repeater:not(.compact) .row-fields { grid-template-columns: 1fr; }
.repeater.compact .row { padding: .6rem .8rem; }
.repeater.compact .field { margin-bottom: .5rem; }
.row-tools { display: flex; flex-direction: column; gap: .3rem; }
.icon { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 1rem; }
.icon:hover { background: var(--cream); }
.icon.del:hover { background: #fde8e6; color: var(--bad); border-color: var(--bad); }
.filter-rows { margin-bottom: 1rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .6rem 1.1rem; border-radius: 999px; border: 2px solid transparent; font: 600 .95rem system-ui, sans-serif; cursor: pointer; text-decoration: none; background: #efe5d8; color: var(--ink); white-space: nowrap; }
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.amber { background: var(--amber); color: var(--ink); }
.btn.maroon { background: var(--maroon); color: #fff; }
.btn.ghost { background: transparent; border-color: #cdbca8; color: var(--ink); }
.btn.danger { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn.small { padding: .35rem .75rem; font-size: .85rem; }
.btn.wide { width: 100%; justify-content: center; padding: .8rem; }
.inline { display: inline; }
.save-bar { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: .6rem; padding: 1rem 0; background: linear-gradient(transparent, var(--cream) 30%); z-index: 5; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Flash */
.flash { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1.25rem; font-weight: 500; }
.flash.ok { background: #e5f3e8; color: var(--ok); border: 1px solid #b8dcc1; }
.flash.error { background: #fde8e6; color: var(--bad); border: 1px solid #f2bdb8; white-space: pre-wrap; }
.flash.warn { background: #fdf1dc; color: var(--warn); border: 1px solid #f0d3a2; }

/* Dashboard */
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; margin: 1.25rem 0 2rem; }
.status p { margin: 0 0 .75rem; }
.pill { display: inline-block; padding: .15rem .7rem; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.pill.ok { background: #e5f3e8; color: var(--ok); }
.pill.warn { background: #fdf1dc; color: var(--warn); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.tile { display: flex; flex-direction: column; gap: .2rem; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--amber); transform: translateY(-2px); }
.tile .ico { font-size: 1.5rem; }
.tile small { color: var(--muted); }
.tile em { color: var(--muted); font-size: .78rem; font-style: normal; margin-top: auto; padding-top: .4rem; }

/* Tables */
table.list, table.preview { width: 100%; border-collapse: collapse; }
table.list td, table.list th, table.preview td, table.preview th { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.preview { background: #fff; font-size: .88rem; }
table.preview th { background: var(--maroon); color: #fff; position: sticky; top: 0; }
.table-wrap { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: start; }
.row-actions details form { display: flex; gap: .4rem; margin-top: .4rem; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.nowrap { white-space: nowrap; }
.upload-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: .75rem; }

/* Login */
.login { width: min(100%, 400px); text-align: center; }
.login-logo { width: 160px; margin: .5rem auto 1rem; }
.login form { text-align: left; }
ul.roles { list-style: none; padding: 0; margin: 0 0 1rem; }
.btn.outline { background: #fff; color: var(--maroon); border-color: var(--maroon); }
/* Live site switch */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin: 1rem 0; }
.mode { position: relative; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 1.1rem 1.2rem 1.2rem; display: flex; flex-direction: column; gap: .5rem; }
.mode.on { border-color: var(--maroon); box-shadow: 0 0 0 4px rgba(96,51,54,.12); }
.mode .ico { font-size: 2rem; }
.mode h2 { margin: 0; }
.mode p { margin: 0; color: var(--muted); font-size: .92rem; flex: 1; }
.mode .badge-on { position: absolute; top: .9rem; right: .9rem; background: var(--maroon); color: #fff; font-size: .75rem; font-weight: 800; padding: .2rem .6rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .05em; }
.mode .thumb { display: block; width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #603336; position: relative; }
.thumb.splash { display: grid; place-items: center; align-content: center; gap: 8px; color: #fff6ea; text-align: center; }
.thumb.splash .t-badge { position: absolute; inset: 0; margin: auto; height: 90%; width: auto; }
.thumb.splash strong { position: relative; font-weight: 900; text-transform: uppercase; font-size: 1.35rem; line-height: .9; letter-spacing: -.02em; }
.thumb.splash strong span { color: #f3a253; }
.thumb.splash em { position: relative; color: #f3a253; font-style: normal; font-weight: 800; font-size: .7rem; text-transform: uppercase; max-width: 80%; }
.t-units { position: relative; display: flex; gap: 5px; }
.t-units i { width: 26px; height: 22px; border-radius: 5px; background: #4a2629; border: 1px solid #7a4a4d; }
.thumb.site { background: #fbf4ea; }
.t-bar { height: 16%; background: #603336; display: flex; align-items: center; gap: 6px; padding: 0 8px; }
.t-bar img { height: 60%; }
.t-bar i { margin-left: auto; width: 14%; height: 4px; background: #fff6ea; border-radius: 2px; opacity: .7; }
.t-bar i + i { margin-left: 0; }
.t-hero { height: 52%; background: #603336; display: flex; align-items: center; gap: 10px; padding: 0 10px; border-top: 1px solid #4a2629; }
.t-hero img { height: 80%; }
.t-hero div { display: grid; gap: 5px; flex: 1; }
.t-hero b { height: 7px; background: #fff6ea; border-radius: 3px; width: 90%; }
.t-hero b.short { width: 60%; background: #f3a253; }
.t-btn { width: 40%; height: 10px; border-radius: 6px; background: #f3a253; }
.t-cards { display: flex; gap: 6px; padding: 8px; }
.t-cards i { flex: 1; height: 26px; border-radius: 5px; background: #fff; border: 1px solid #e8d9c6; }
.cycle { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem; }
.cycle b { color: var(--ink); }
.check { display: flex; gap: .6rem; align-items: start; margin-bottom: 1rem; }
.check input { width: 20px; height: 20px; margin-top: .15rem; accent-color: var(--maroon); }
.range-row { display: flex; align-items: center; gap: .75rem; }
.range-row input[type=range] { flex: 1; accent-color: var(--maroon); }
.image-field.dark .image-pick img { background: var(--maroon); padding: 8px; max-width: 200px; max-height: 160px; }
