:root {
  --cream: #f9eee8; --cream-2: #f3e2da; --card: #fffaf7; --plum: #7b5862; --plum-dark: #5f414a;
  --ink: #4a2f35; --ink-soft: #6f565b; --line: #e2cfc8; --ok: #3f6b4a; --err: #a33b3b; --warn: #9a6a1c;
  --serif: "Libre Caslon Text", Georgia, serif; --sans: "Nunito Sans", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 400 16px/1.5 var(--sans); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0 0 .4em; line-height: 1.2; }
a { color: var(--plum-dark); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--plum); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 18px; border-radius: 999px; border: 2px solid var(--plum); background: var(--plum); color: #fff; font: 700 .95rem var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--plum-dark); border-color: var(--plum-dark); }
.btn[disabled] { opacity: .55; cursor: wait; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--cream-2); color: var(--ink); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--err); border-color: #e3b9b9; }
.btn-danger:hover { background: #fbeaea; color: var(--err); border-color: var(--err); }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: .85rem; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; cursor: pointer; font-size: 1.1rem; color: var(--ink); }
.icon-btn:hover { background: var(--cream-2); }
.muted { color: var(--ink-soft); font-size: .9rem; }
.error { color: var(--err); font-weight: 700; margin: 0; }

input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 42px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px rgba(123, 88, 98, .18); }
label { font-weight: 700; font-size: .9rem; display: block; margin-bottom: 4px; }
.hint { font-weight: 400; color: var(--ink-soft); font-size: .82rem; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.check input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--plum); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 30px; display: grid; gap: 10px; box-shadow: 0 10px 40px rgba(74, 47, 53, .1); }
.login-card img { width: 200px; margin: 0 auto; mix-blend-mode: multiply; }
.login-card h1 { text-align: center; }
.login-card .btn { margin-top: 8px; }
.login-card .muted { text-align: center; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--cream-2); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--ink); }
.side-brand img { width: 140px; mix-blend-mode: multiply; }
.side-brand span { font: 700 .75rem var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--plum); }
.side-nav { display: grid; gap: 2px; flex: 1; align-content: start; }
.side-nav a { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; }
.side-nav a:hover { background: rgba(255, 255, 255, .6); }
.side-nav a[aria-current="page"] { background: var(--plum); color: #fff; }
.count { background: var(--err); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 8px; font-weight: 800; }
.content { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.content:focus { outline: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .side-brand img { width: 90px; }
  .side-nav { order: 3; flex-basis: 100%; display: flex; overflow-x: auto; gap: 4px; }
  .side-nav a { white-space: nowrap; padding: 8px 12px; }
  .sidebar .btn-ghost { margin-left: auto; }
}

.page-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-top h1 { margin: 0; font-size: 2rem; }
.page-top p { margin: 4px 0 0; color: var(--ink-soft); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-decoration: none; color: var(--ink); }
.stat:hover { border-color: var(--plum); }
.stat b { display: block; font: 400 2.2rem var(--serif); }
.status-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.status-list li { display: flex; gap: 10px; align-items: baseline; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--err); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }

/* Tables / lists */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--cream-2); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); background: #fdf3ee; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fdf3ee; }
.thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--cream-2); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: var(--cream-2); color: var(--ink-soft); }
.pill.on { background: #e5efe6; color: var(--ok); }
.pill.off { background: #f4e4e4; color: var(--err); }
.pill.new { background: #fbe9d2; color: var(--warn); }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 180px; }

/* Quote cards */
.quote { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 14px; }
.quote-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.quote-head h3 { margin: 0; font-size: 1.3rem; }
.quote dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 18px; margin: 12px 0; }
.quote dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.quote dd { margin: 0; font-weight: 600; word-break: break-word; }
.quote .msg { white-space: pre-line; background: #fdf3ee; border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; }
.quote-photos { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.quote-photos a img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.quote-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quote-actions select { width: auto; }

/* Editor dialog */
.editor { width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0; border-radius: 18px; background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.editor::backdrop { background: rgba(50, 30, 34, .5); }
.editor-form { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.editor-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.editor-head h2 { margin: 0; }
.editor-body { padding: 20px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.editor-body .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .editor-body { grid-template-columns: 1fr; } }
.editor-foot { display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.editor-foot .spacer { flex: 1; }
.editor-foot .error { flex-basis: 100%; }

.images { display: flex; gap: 10px; flex-wrap: wrap; }
.img-item { position: relative; width: 110px; }
.img-item img { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; border: 2px solid transparent; }
.img-item:first-child img { border-color: var(--plum); }
.img-item .main-tag { position: absolute; top: 6px; left: 6px; background: var(--plum); color: #fff; font-size: .68rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; }
.img-item .img-tools { display: flex; justify-content: space-between; margin-top: 4px; }
.img-item button { border: 0; background: var(--cream-2); border-radius: 6px; cursor: pointer; font-size: .78rem; padding: 3px 7px; color: var(--ink); }
.img-item button:hover { background: var(--line); }
.upload-box { width: 110px; height: 110px; border: 2px dashed var(--line); border-radius: 10px; display: grid; place-items: center; text-align: center; cursor: pointer; font-size: .85rem; color: var(--ink-soft); padding: 8px; }
.upload-box:hover { border-color: var(--plum); color: var(--plum); }
.upload-box input { display: none; }

.opt-editor { display: grid; gap: 12px; }
.opt-group { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; display: grid; gap: 8px; }
.opt-head { display: flex; gap: 8px; }
.opt-head input { font-weight: 700; }
.opt-rows { display: grid; gap: 6px; }
.opt-row { display: grid; grid-template-columns: 1fr 130px 40px; gap: 8px; align-items: center; }
.opt-labels span { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.opt-group > .btn, .opt-editor > .btn { justify-self: start; }
.order-item { margin-bottom: 6px; }
.order-note { background: #fbe9d2; border-radius: 6px; padding: 4px 8px; margin-top: 2px; font-weight: 600; }
code { background: var(--cream-2); padding: 1px 5px; border-radius: 4px; font-size: .85em; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.settings-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .settings-grid { grid-template-columns: 1fr; } }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px; font-weight: 700; z-index: 100; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast.err { background: var(--err); }

/* ---------- Website traffic ---------- */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.seg a { padding: 8px 14px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: .9rem; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a[aria-current] { background: var(--plum); color: #fff; }
.chg { font-size: .82rem; color: var(--ink-soft); }
.chg.up { color: var(--ok); }
.chg.down { color: var(--err); }
.chart { display: flex; align-items: stretch; gap: 2px; height: 200px; padding-bottom: 22px; position: relative; border-bottom: 1px solid var(--line); }
.chart .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.chart .colbar { display: block; background: var(--plum); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.chart .col:hover .colbar { opacity: 1; background: var(--plum-dark); }
.chart .collabel { position: absolute; bottom: -20px; left: 0; font-size: .72rem; color: var(--ink-soft); white-space: nowrap; }
.traffic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 0 18px; }
.bar-list { list-style: none; margin: 0 0 8px; padding: 0; }
.bar-list li { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; margin-bottom: 4px; border-radius: 6px; overflow: hidden; }
.bar-list .bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--cream-2); z-index: 0; }
.bar-list .bar-name, .bar-list b { position: relative; z-index: 1; }
.bar-list .bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Colors & logo ---------- */
.logo-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 280px; max-width: 100%; min-height: 120px; display: grid; place-items: center; padding: 14px; border: 1px dashed var(--line); border-radius: 12px; background: var(--cream); }
.logo-preview img { max-width: 100%; max-height: 140px; height: auto; }
.logo-row > div:last-child { flex: 1 1 260px; }
.upload-btn { cursor: pointer; margin-right: 8px; }
.palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 18px; }
.palette { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 12px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; font: inherit; text-align: left; }
.palette[aria-pressed] { border-color: var(--plum); box-shadow: 0 0 0 3px rgba(0, 0, 0, .08); }
.palette .sw { width: 22px; height: 22px; border-radius: 50%; }
.palette .pname { flex-basis: 100%; font-weight: 700; font-size: .9rem; margin-top: 4px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.color-field { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--card); }
.color-field input[type=color] { width: 52px; height: 52px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: none; cursor: pointer; flex: none; }
.theme-preview { --p-accent: #7b5862; --p-ink: #4a2f35; --p-bg: #f9eee8; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--p-bg); color: var(--p-ink); }
.tp-band { background: var(--p-accent); color: #fff; padding: 10px 16px; font-weight: 700; text-align: center; }
.tp-body { padding: 18px; }
.tp-body h4 { font: 400 1.5rem var(--serif); margin: 0 0 6px; color: var(--p-ink); }
.tp-body p { margin: 0 0 14px; opacity: .85; }
.tp-card { display: inline-flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 10px; background: rgba(255, 255, 255, .55); border: 1px solid rgba(0, 0, 0, .08); min-width: 200px; }
.tp-btn { background: var(--p-accent); color: #fff; padding: 8px 14px; border-radius: 999px; text-align: center; font-weight: 700; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
