:root {
  color-scheme: dark;
  --bg: #08070d;
  --panel: #13111d;
  --panel-2: #1b1729;
  --line: #342c48;
  --text: #f8f6fb;
  --muted: #aaa4b7;
  --gold: #f1c361;
  --green: #6ad8b0;
  --red: #ff8e9d;
  --blue: #8eb9ff;
}

* { box-sizing: border-box; }
html { font-family: Arial, sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% 0, #251a40 0, transparent 36%), var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.admin-shell { width: min(1440px, calc(100% - 32px)); margin: 0 auto; }
.admin-header { position: sticky; top: 0; z-index: 20; background: rgba(8,7,13,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.header-row { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #8e6b2d; border-radius: 50%; color: var(--gold); font-weight: 900; background: #17121d; }
.brand strong { display: block; font-size: 19px; }
.brand small { color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.btn { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 17px; color: var(--text); background: var(--panel-2); cursor: pointer; }
.btn:hover, .btn:focus-visible { border-color: var(--gold); outline: none; }
.btn-primary { color: #17110a; background: var(--gold); border-color: var(--gold); font-weight: 800; }
.btn-danger { color: #ffdce1; border-color: #6a3440; background: #28141a; }
.btn-quiet { background: transparent; }

.login-screen { min-height: calc(100vh - 77px); display: grid; place-items: center; padding: 40px 0; }
.login-card { width: min(560px, 100%); text-align: center; padding: clamp(28px, 6vw, 56px); border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(145deg, rgba(34,27,53,.96), rgba(15,13,22,.98)); box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.login-card .brand-mark { width: 72px; height: 72px; margin: 0 auto 24px; font-size: 25px; }
.login-card h1 { font-size: clamp(30px, 6vw, 48px); margin: 0 0 14px; }
.login-card p { color: var(--muted); line-height: 1.7; margin: 0 0 24px; }
.login-note { font-size: 13px; margin-top: 18px !important; }
.login-error { min-height: 22px; color: var(--red) !important; }

.dashboard { padding: 28px 0 60px; }
.welcome { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.welcome h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 42px); }
.welcome p { margin: 0; color: var(--muted); }
.live-pill { display: inline-flex; align-items: center; gap: 8px; color: var(--green); border: 1px solid #245443; background: #10251f; border-radius: 999px; padding: 8px 12px; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: rgba(19,17,29,.92); }
.stat small { color: var(--muted); }
.stat strong { display: block; margin-top: 9px; font-size: 32px; }
.stat.new strong { color: var(--gold); }
.stat.open strong { color: var(--blue); }
.stat.closed strong { color: var(--green); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 20px; background: rgba(19,17,29,.95); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 20px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; }
.control { min-height: 42px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: #0e0c15; padding: 0 12px; }
.control:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.search { width: min(260px, 100%); }

.lead-list { display: grid; }
.lead-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lead-card:last-child { border-bottom: 0; }
.lead-card:hover, .lead-card:focus-visible, .lead-card.active { background: #1d182b; outline: none; }
.lead-title { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.lead-title strong { font-size: 17px; }
.lead-card p { margin: 8px 0 0; color: var(--muted); }
.lead-time { color: var(--muted); font-size: 12px; text-align: left; }
.badge { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; font-size: 12px; }
.badge-new { color: var(--gold); border-color: #745a29; background: #271e0d; }
.badge-pending { color: var(--gold); border-color: #745a29; background: #271e0d; }
.badge-approved { color: var(--green); border-color: #2d644e; background: #10251d; }
.badge-contacted { color: var(--blue); border-color: #314f73; background: #101d2b; }
.badge-quoted { color: #d0a8ff; border-color: #5b387c; background: #21132f; }
.badge-booked { color: var(--green); border-color: #2d644e; background: #10251d; }
.badge-declined { color: #ffb8b8; border-color: #743f48; background: #2a1117; }
.badge-closed { color: var(--muted); }
.empty { padding: 44px 24px; text-align: center; color: var(--muted); }

.side-stack { display: grid; gap: 18px; position: sticky; top: 98px; }
.detail { padding: 18px; }
.detail h3 { margin: 0 0 16px; }
.detail-grid { display: grid; gap: 12px; margin-bottom: 16px; }
.detail-row small { display: block; color: var(--muted); margin-bottom: 4px; }
.detail-row a { color: var(--text); }
.detail textarea { width: 100%; min-height: 100px; padding: 12px; resize: vertical; }
.detail select { width: 100%; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.detail-actions .btn { padding: 0 10px; }

.quick-list { display: grid; gap: 8px; padding: 14px 18px 18px; }
.quick-item { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; padding: 10px; background: #0e0c15; border-radius: 11px; }
.quick-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold); }
.quick-item.done span { color: var(--muted); text-decoration: line-through; }
.quick-item button { border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.quick-form { display: flex; gap: 8px; padding: 0 18px 18px; }
.quick-form input { min-width: 0; flex: 1; }

.admin-tabs { display: flex; gap: 8px; margin-bottom: 18px; padding: 5px; width: fit-content; border: 1px solid var(--line); border-radius: 14px; background: #0e0c15; }
.admin-tab { min-height: 42px; padding: 0 18px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; font-weight: 700; }
.admin-tab:hover, .admin-tab:focus-visible { color: var(--text); outline: 2px solid var(--gold); outline-offset: 1px; }
.admin-tab.active { color: #17110a; background: var(--gold); }
.eyebrow { display: block; margin-bottom: 6px; color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.content-view { display: grid; gap: 18px; }
.cms-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 390px); gap: 18px; padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(135deg, rgba(38,29,59,.94), rgba(14,12,21,.96)); }
.cms-intro h2 { margin: 0 0 8px; font-size: clamp(23px, 3vw, 34px); }
.cms-intro p { margin: 0; max-width: 760px; color: var(--muted); line-height: 1.65; }
.cms-publish-note { display: grid; align-content: center; gap: 6px; padding: 16px; border: 1px solid #5e4923; border-radius: 15px; background: rgba(48,37,15,.72); }
.cms-publish-note span { color: #dacda9; font-size: 13px; line-height: 1.55; }
.cms-layout { display: grid; grid-template-columns: 290px minmax(340px, 420px) minmax(460px, 1fr); gap: 18px; align-items: start; }
.cms-sidebar, .cms-editor-panel, .cms-preview-panel { min-height: 690px; }
.cms-sidebar-body { display: grid; gap: 9px; padding: 16px; }
.cms-sidebar-body label { color: var(--muted); font-size: 13px; font-weight: 700; }
.cms-sidebar-body .control { width: 100%; }
.cms-field-list { display: grid; gap: 7px; max-height: 520px; margin-top: 5px; overflow: auto; padding-left: 3px; }
.cms-field-button { display: grid; gap: 5px; width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: #0e0c15; text-align: right; cursor: pointer; }
.cms-field-button:hover, .cms-field-button:focus-visible, .cms-field-button.active { border-color: var(--gold); background: #211a2e; outline: none; }
.cms-field-button small { color: var(--gold); font-size: 11px; }
.cms-field-button span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.cms-editor-panel { display: grid; grid-template-rows: auto 1fr auto auto; }
.cms-editor-head { align-items: start; }
.cms-change-pill { display: inline-flex; min-height: 30px; align-items: center; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #0e0c15; font-size: 12px; white-space: nowrap; }
.cms-change-pill.changed { color: var(--gold); border-color: #745a29; background: #271e0d; }
.cms-editor-form { min-height: 0; overflow: auto; }
.cms-editor-empty { display: grid; place-items: center; align-content: center; min-height: 440px; padding: 30px; text-align: center; }
.cms-editor-empty h3 { margin: 18px 0 7px; }
.cms-editor-empty p { margin: 0; color: var(--muted); line-height: 1.6; }
#cms-editor-fields { display: grid; gap: 15px; padding: 18px; }
.cms-field-control { display: grid; gap: 7px; }
.cms-field-control label { color: var(--muted); font-size: 13px; font-weight: 700; }
.cms-field-control textarea { min-height: 170px; padding: 12px; resize: vertical; line-height: 1.65; }
.cms-field-control input { width: 100%; }
.cms-field-help { margin: -3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.cms-media-library { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 280px; overflow: auto; }
.cms-media-option { position: relative; overflow: hidden; min-height: 86px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #09080d; cursor: pointer; }
.cms-media-option:hover, .cms-media-option:focus-visible, .cms-media-option.selected { border-color: var(--gold); outline: none; }
.cms-media-option img { width: 100%; height: 86px; object-fit: cover; }
.cms-media-option span { position: absolute; right: 4px; bottom: 4px; left: 4px; overflow: hidden; padding: 4px; border-radius: 6px; background: rgba(0,0,0,.74); color: white; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.cms-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 15px 18px; border-top: 1px solid var(--line); }
.cms-editor-actions .btn-primary { margin-right: auto; }
.cms-status { min-height: 24px; margin: 0; padding: 0 18px 15px; color: var(--muted); font-size: 13px; }
.cms-status.error { color: var(--red); }
.cms-status.success { color: var(--green); }
.cms-preview-panel { overflow: hidden; }
.cms-preview-frame { height: 620px; padding: 12px; background: #06050a; }
.cms-preview-frame iframe { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 12px; background: white; }

.toast { position: fixed; left: 18px; bottom: 18px; z-index: 50; max-width: min(420px, calc(100% - 36px)); padding: 14px 17px; border: 1px solid #516f64; border-radius: 12px; background: #11241e; color: #dff9ef; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1260px) {
  .cms-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .cms-preview-panel { grid-column: 1 / -1; min-height: 600px; }
  .cms-preview-frame { height: 540px; }
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .side-stack { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cms-intro { grid-template-columns: 1fr; }
  .cms-layout { grid-template-columns: 1fr; }
  .cms-sidebar, .cms-editor-panel, .cms-preview-panel { min-height: auto; }
  .cms-preview-panel { grid-column: auto; }
}

@media (max-width: 640px) {
  .admin-shell { width: min(100% - 20px, 1440px); }
  .header-row { min-height: 66px; }
  .brand small, #user-label { display: none; }
  .header-actions .btn { padding: 0 12px; }
  .welcome { display: block; }
  .live-pill { margin-top: 14px; }
  .stats { gap: 9px; }
  .stat { padding: 15px; }
  .stat strong { font-size: 26px; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .search { width: 100%; grid-column: 1 / -1; }
  .lead-card { grid-template-columns: 1fr; }
  .lead-time { text-align: right; }
  .admin-tabs { width: 100%; }
  .admin-tab { flex: 1; padding: 0 10px; }
  .cms-intro { padding: 17px; }
  .cms-media-library { grid-template-columns: repeat(2, 1fr); }
  .cms-editor-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .cms-editor-actions .btn-primary { grid-column: 1 / -1; margin: 0; }
  .cms-preview-frame { height: 430px; padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
