/* Bay Cypress – admin panel */
:root {
  --forest: #0e1a13; --moss: #1f3a2b; --sage: #a3b59a; --cream: #f5f0e6; --paper: #faf8f3;
  --ink: #1d221d; --muted: #6b7369; --line: #e5dfd3; --accent: #c8954a; --danger: #b4443a; --ok: #3f7d4f; --warn: #b07a1e;
  --r: 14px; --ease: cubic-bezier(.22,.8,.2,1);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Manrope, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 15px; line-height: 1.55; }
a { color: var(--moss); }
img { max-width: 100%; display: block; }
code { background: #efe9dc; padding: 1px 6px; border-radius: 5px; font-size: .9em; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 500; margin: 0 0 14px; }
h2 small { font-family: system-ui, sans-serif; font-size: .8rem; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); } .small { font-size: .85rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .25s var(--ease), box-shadow .25s, background .25s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px -10px rgba(0,0,0,.5); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: #e7c3bf; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 14px; font-size: .85rem; }

/* Notices */
.notice { padding: 12px 16px; border-radius: 10px; background: #f1ead9; margin: 0 0 14px; }
.notice.ok { background: #e3f0e2; color: #234d2c; } .notice.err { background: #f8e1de; color: #7a2820; }
.flash { animation: flashIn .6s var(--ease); }
@keyframes flashIn { from { opacity: 0; transform: translateY(-10px); } }

/* Auth / installer */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at top, var(--moss), var(--forest)); }
.auth-card { width: min(420px, 100%); background: var(--paper); border-radius: 22px; padding: 36px; display: grid; gap: 14px; box-shadow: 0 40px 80px -30px #000; animation: flashIn .8s var(--ease); }
.auth-card.wide { width: min(620px, 100%); }
.auth-logo { width: 74px; height: 74px; object-fit: contain; background: var(--forest); border-radius: 50%; padding: 10px; margin: 0 auto; }
.auth-card h1 { text-align: center; font-size: 1.6rem; }
.auth-card label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
.auth-card label.check { display: flex; gap: 10px; font-weight: 400; align-items: flex-start; }
.stack { display: grid; gap: 14px; }
input, textarea, select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; transition: border-color .2s, box-shadow .2s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,149,74,.2); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea.code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85rem; line-height: 1.5; tab-size: 2; background: #fcfbf8; }

/* Layout */
.admin { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--forest); color: var(--cream); display: flex; flex-direction: column; padding: 20px 14px; }
.side-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; padding: 4px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 12px; }
.side-brand img { width: 42px; height: 42px; object-fit: contain; }
.side-brand span { font-family: Fraunces, Georgia, serif; font-size: 1.2rem; line-height: 1.1; }
.side-brand small { display: block; font-family: system-ui; font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: rgba(245,240,230,.75); text-decoration: none; font-size: .92rem; transition: background .2s, color .2s; }
.sidebar nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; flex-shrink: 0; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.on { background: var(--accent); color: #fff; }
.pill { margin-left: auto; background: #e07a5f; color: #fff; font-size: .72rem; padding: 1px 8px; border-radius: 99px; }
.side-foot { margin-top: auto; padding-top: 20px; display: grid; gap: 6px; font-size: .85rem; }
.side-foot a { color: var(--sage); text-decoration: none; padding: 4px 12px; }
.content { padding: 0 clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 18px 0; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); margin-bottom: 10px; }
.topbar h1 { margin: 0; font-size: 1.6rem; flex: 1; }
.burger { display: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); position: relative; cursor: pointer; }
.burger span { position: absolute; left: 10px; right: 10px; height: 2px; background: var(--ink); }
.burger span:nth-child(1) { top: 13px; } .burger span:nth-child(2) { top: 19px; } .burger span:nth-child(3) { top: 25px; }
.scrim { display: none; }

/* Cards & forms */
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: clamp(18px, 2.5vw, 28px); margin-bottom: 22px; animation: flashIn .5s var(--ease) both; }
.card + .card { animation-delay: .06s; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.grid-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.cell.wide { grid-column: 1 / -1; }
.fld { display: grid; gap: 6px; }
.fld > label { font-weight: 600; font-size: .88rem; }
.fld em { color: var(--danger); font-style: normal; }
.help { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; align-items: center; }
.inline { display: inline; margin: 0; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; } .inline-form input { flex: 1; min-width: 220px; }
.mini { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); font-weight: 400; }

/* Switch */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; font-size: .9rem; padding: 8px 0; }
.switch input[type=checkbox] { position: absolute; opacity: 0; }
.switch span { flex-shrink: 0; width: 42px; height: 24px; border-radius: 24px; background: #d7d0c2; position: relative; transition: background .3s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .3s var(--ease); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(200,149,74,.4); }

/* Image field */
.img-field { display: grid; grid-template-columns: 180px 1fr; gap: 16px; align-items: start; }
.img-prev { aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/16px 16px; border: 1px solid var(--line); display: grid; place-items: center; }
.img-prev img { width: 100%; height: 100%; object-fit: contain; }
.img-prev.empty span { color: var(--muted); font-size: .85rem; }
.img-ctl { display: grid; gap: 10px; }
.drop { display: grid; place-items: center; min-height: 74px; border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); cursor: pointer; text-align: center; padding: 10px; transition: border-color .2s, background .2s; position: relative; }
.drop:hover, .drop.over { border-color: var(--accent); background: #fbf5ea; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.color-row, .range-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.color-row input[type=color] { width: 54px; height: 40px; padding: 2px; }
.swatches { display: flex; gap: 6px; }
.swatches button { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.range-row input { flex: 1; padding: 0; } .range-row output { min-width: 3ch; font-weight: 700; }

/* HTML tools */
.html-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.html-tools button { font: inherit; font-size: .8rem; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: #f6f2ea; cursor: pointer; }
.html-tools button:hover { border-color: var(--accent); }
.html-tools .sp { flex: 1; }
.html-tools .preview-html { background: var(--moss); color: #fff; border-color: var(--moss); }
.html-preview { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.html-preview iframe { width: 100%; height: 520px; border: 0; display: block; }

/* Items list */
.items { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 14px; background: #fff; transition: box-shadow .25s, opacity .25s; }
.item.off .item-row { opacity: .55; }
.item.dragging { opacity: .5; box-shadow: 0 0 0 2px var(--accent); }
.item.drop-target { box-shadow: 0 -3px 0 var(--accent); }
.item-row { display: flex; align-items: center; gap: 14px; padding: 10px 14px; }
.handle { cursor: grab; color: var(--muted); font-size: 1.2rem; user-select: none; padding: 4px; }
.thumb { width: 64px; height: 52px; border-radius: 10px; overflow: hidden; flex-shrink: 0; background: var(--cream); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb i { font-style: normal; font-family: Fraunces, Georgia, serif; font-size: 1.4rem; color: var(--moss); }
.thumb.stat { font-family: Fraunces, Georgia, serif; font-size: 1.3rem; color: var(--accent); background: var(--forest); }
.thumb.stat small { font-size: .6em; color: var(--cream); }
.item-text { flex: 1; min-width: 0; display: grid; }
.item-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-text small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-text .file { color: var(--accent); font-family: ui-monospace, monospace; font-size: .75rem; }
.item-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.vis-toggle { font: inherit; font-size: .78rem; padding: 4px 10px; border-radius: 99px; border: 0; background: #e3f0e2; color: var(--ok); cursor: pointer; }
.item.off .vis-toggle { background: #eee; color: var(--muted); }
.edit-form, .new-form { padding: 18px; border-top: 1px solid var(--line); background: #fcfaf6; border-radius: 0 0 14px 14px; animation: flashIn .35s var(--ease); }
.new-form { border: 1px solid var(--accent); border-radius: 14px; margin: 12px 0; }
.asset-up { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; } .asset-up input[type=text] { flex: 1; min-width: 240px; font-family: ui-monospace, monospace; }

/* Dashboard */
.dash-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.dash-card { background: var(--forest); color: var(--cream); border-radius: 18px; padding: 22px; text-decoration: none; display: grid; gap: 4px; transition: transform .3s var(--ease); animation: flashIn .6s var(--ease) both; }
.dash-card:nth-child(2) { animation-delay: .05s; } .dash-card:nth-child(3) { animation-delay: .1s; } .dash-card:nth-child(4) { animation-delay: .15s; background: var(--accent); }
.dash-card:hover { transform: translateY(-4px); }
.dash-card strong { font-family: Fraunces, Georgia, serif; font-size: 2.4rem; font-weight: 400; line-height: 1; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checks li { padding: 10px 14px 10px 40px; border-radius: 10px; position: relative; }
.checks li::before { position: absolute; left: 14px; font-weight: 700; }
.checks .ok { background: #eef6ed; } .checks .ok::before { content: "✓"; color: var(--ok); }
.checks .warn { background: #fbf1df; } .checks .warn::before { content: "!"; color: var(--warn); }
.checks .info { background: #eef1f5; } .checks .info::before { content: "i"; color: #3a5a80; }
.msg-mini { list-style: none; padding: 0; margin: 0; }
.msg-mini li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.msg-mini li span { flex: 1; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.msg-mini li.unread strong::before { content: "● "; color: #e07a5f; }
.msg-mini time { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.quick { display: flex; flex-wrap: wrap; gap: 10px; }
.quick a { padding: 10px 16px; border-radius: 10px; background: var(--cream); text-decoration: none; font-weight: 600; }
.quick a:hover { background: var(--accent); color: #fff; }

/* Messages */
.msg { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #fff; }
.msg summary { display: flex; gap: 14px; padding: 12px 16px; cursor: pointer; list-style: none; align-items: baseline; }
.msg summary::-webkit-details-marker { display: none; }
.msg summary span { flex: 1; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.msg summary time { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.msg.unread summary strong::before { content: "● "; color: #e07a5f; }
.msg-body { padding: 0 16px 16px; }
.msg-text { background: var(--paper); padding: 14px; border-radius: 10px; border-left: 3px solid var(--accent); }
.meta .ok { color: var(--ok); } .meta .warn { color: var(--danger); }
.help-box { margin-top: 16px; } .help-box summary { cursor: pointer; font-weight: 600; }
.mini-table { border-collapse: collapse; margin-top: 10px; font-size: .88rem; width: 100%; }
.mini-table th, .mini-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }

/* Responsive */
@media (max-width: 1100px) { .dash-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .4s var(--ease); }
  #nav-toggle:checked ~ .sidebar { transform: none; }
  #nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.4); }
  .burger { display: block; }
  .grid-fields { grid-template-columns: 1fr; }
  .img-field { grid-template-columns: 1fr; } .img-prev { max-width: 240px; }
  .item-row { flex-wrap: wrap; }
  .item-actions { width: 100%; justify-content: flex-end; }
}
