:root {
  --ink: #161B22;
  --ink-soft: #57606A;
  --paper: #F6F8FA;
  --card: #FFFFFF;
  --line: #E2E6EB;
  --brand: #2F6698;
  --brand-light: #EAF2FA;
  --pools: #0891B2;
  --pools-light: #E3F6FA;
  --accent: #C1622E;
  --good: #1E7B3D;
  --good-bg: #E6F6EA;
  --warn: #B9812E;
  --warn-bg: #FBF1DD;
  --bad: #B3261E;
  --bad-bg: #FCE8E6;
  --sidebar-w: 240px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20,20,30,0.06), 0 8px 24px rgba(20,20,30,0.06);
  font-size: 15px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
a { color: inherit; }
button { font: inherit; }

/* ---- Login ---- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #161B22, #2F6698);
  padding: 1.5rem;
}
.login-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}
.login-card .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.6rem;
}
.login-card .brand img { height: 32px; }
.login-card .brand span { font-weight: 800; font-size: 1.1rem; }
.login-card h1 { font-size: 1.3rem; margin: 0 0 0.4rem; }
.login-card p.sub { color: var(--ink-soft); margin: 0 0 1.4rem; font-size: 0.9rem; }
.login-card label { display: block; font-size: 0.82rem; font-weight: 700; margin-bottom: 0.4rem; color: var(--ink-soft); }
.login-card input {
  width: 100%;
  padding: 0.8em 1em;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  margin-bottom: 1rem;
}
.login-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.login-card button {
  width: 100%;
  padding: 0.85em;
  border: none;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.login-card button:hover { background: #000; }
.login-error {
  background: var(--bad-bg);
  color: var(--bad);
  padding: 0.7em 1em;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.login-error.is-visible { display: block; }

/* ---- Shell: sidebar + content ---- */
.dashboard-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--ink);
  color: rgba(255,255,255,0.82);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; height: 100vh;
  overflow-y: auto;
  z-index: 30;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; padding: 1.25rem 1.3rem; font-weight: 800; color: white; border-bottom: 1px solid rgba(255,255,255,0.1); flex: none; }
.sidebar-brand img { height: 22px; }
.sidebar-nav { flex: 1; padding: 0.8rem; display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-nav-item {
  display: flex; align-items: center; gap: 0.7em;
  padding: 0.62em 0.8em; border-radius: 8px;
  background: none; border: none; color: rgba(255,255,255,0.72);
  font-weight: 600; font-size: 0.87rem; cursor: pointer; text-align: left; width: 100%;
}
.sidebar-nav-item svg { width: 17px; height: 17px; flex: none; }
.sidebar-nav-item:hover { background: rgba(255,255,255,0.07); color: white; }
.sidebar-nav-item.is-active { background: rgba(255,255,255,0.16); color: white; }
.sidebar-nav-item .badge { margin-left: auto; background: var(--bad); color: white; font-size: 0.66rem; font-weight: 800; padding: 0.12em 0.5em; border-radius: 999px; }
.sidebar-foot { padding: 0.8rem; border-top: 1px solid rgba(255,255,255,0.1); display: flex; flex-direction: column; gap: 0.4rem; flex: none; }
.sidebar-foot a, .sidebar-foot button {
  display: flex; align-items: center; gap: 0.6em;
  padding: 0.55em 0.8em; border-radius: 8px;
  background: rgba(255,255,255,0.06); border: none; color: white;
  font-size: 0.8rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.sidebar-foot a:hover, .sidebar-foot button:hover { background: rgba(255,255,255,0.16); }
.sidebar-foot svg { width: 15px; height: 15px; flex: none; }

.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 1.8rem 2rem 4rem; max-width: calc(100vw - var(--sidebar-w)); }
.content-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 1.2rem; }
.content-head h1 { font-size: 1.4rem; margin: 0; }
.content-head p { margin: 0.2em 0 0; color: var(--ink-soft); font-size: 0.88rem; }

@media (max-width: 860px) {
  .dashboard-layout { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; }
  .sidebar-brand { border-bottom: none; padding: 0.8rem 1rem; width: 100%; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; padding: 0.2rem 0.8rem 0.8rem; }
  .sidebar-nav-item { width: auto; }
  .sidebar-foot { flex-direction: row; border-top: none; padding: 0 0.8rem 0.8rem; width: 100%; }
  .main-content { margin-left: 0; max-width: 100vw; padding: 1.2rem 1rem 3rem; }
}

.view { display: none; }
.view.is-active { display: block; }

/* ---- Explanation dropdowns ("admin guide") ---- */
.admin-guide { background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: 10px; margin-bottom: 1.2rem; }
.admin-guide summary { list-style: none; cursor: pointer; padding: 0.8em 1em; font-weight: 700; font-size: 0.84rem; color: #1D4ED8; display: flex; align-items: center; gap: 0.55em; }
.admin-guide summary::-webkit-details-marker { display: none; }
.admin-guide summary::before { content: "▶"; font-size: 0.62em; transition: transform .15s ease; }
.admin-guide[open] summary::before { transform: rotate(90deg); }
.admin-guide__body { padding: 0 1.1em 1em; font-size: 0.85rem; color: #1E3A5F; line-height: 1.55; }
.admin-guide__body ul { margin: 0.4em 0 0; padding-left: 1.2em; }
.admin-guide__body li { margin-bottom: 0.3em; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.6rem; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; }
.stat-card .label { font-size: 0.78rem; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 2rem; font-weight: 800; margin-top: 0.3rem; }
.stat-card .sub { font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.2rem; }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; }
.panel h2 { margin: 0 0 1rem; font-size: 1.05rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.6rem; }

.chart { height: 160px; display: flex; flex-direction: column; }
.line-chart-svg { width: 100%; height: 132px; flex: none; display: block; overflow: visible; }
.chart-x-labels { display: flex; justify-content: space-between; margin-top: 0.4rem; }
.chart-x-labels span { font-size: 0.62rem; color: var(--ink-soft); white-space: nowrap; }
.chart-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: 0.88rem; text-align: center; }
.chart-legend { display: flex; gap: 1rem; font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.6rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.4em; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.pavers { background: var(--brand); }
.dot.pools { background: var(--pools); }

.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tab-btn { padding: 0.5em 1.1em; border-radius: 999px; border: 1.5px solid var(--line); background: white; cursor: pointer; font-weight: 700; font-size: 0.85rem; }
.tab-btn.is-active { background: var(--ink); color: white; border-color: var(--ink); }

select, input[type=text], input[type=search], input[type=email], input[type=tel], input[type=url] {
  padding: 0.55em 0.8em; border: 1.5px solid var(--line); border-radius: 8px; font-size: 0.88rem; background: white;
}

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; padding: 0.7em 0.6em; color: var(--ink-soft); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--line); }
td { padding: 0.8em 0.6em; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.pill { display: inline-block; padding: 0.25em 0.7em; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-transform: capitalize; }
.pill.site-pavers { background: var(--brand-light); color: var(--brand); }
.pill.site-pools { background: var(--pools-light); color: var(--pools); }
.pill.status-new { background: var(--warn-bg); color: var(--warn); }
.pill.status-contacted { background: var(--brand-light); color: var(--brand); }
.pill.status-quoted { background: #EFE7FB; color: #6B3FA0; }
.pill.status-won { background: var(--good-bg); color: var(--good); }
.pill.status-lost { background: var(--bad-bg); color: var(--bad); }
.status-select { border: 1.5px solid var(--line); border-radius: 6px; padding: 0.3em 0.5em; font-size: 0.78rem; font-weight: 700; }
.icon-btn { background: none; border: none; color: var(--ink-soft); cursor: pointer; padding: 0.3em; border-radius: 6px; }
.icon-btn:hover { background: var(--bad-bg); color: var(--bad); }
.services-list { font-size: 0.8rem; color: var(--ink-soft); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--ink-soft); }

/* ---- Media library ---- */
.dropzone {
  border: 2px dashed var(--line); border-radius: 12px; padding: 2.2rem 1rem; text-align: center;
  color: var(--ink-soft); font-weight: 600; font-size: 0.9rem; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s; margin-bottom: 1.2rem;
}
.dropzone.is-dragover { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }
.dropzone input { display: none; }
.dropzone strong { display: block; font-size: 1rem; margin-bottom: 0.3em; color: var(--ink); }
.dropzone.is-dragover strong { color: var(--brand); }

.gallery-manager-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.9rem; }
.gallery-manager-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: white; position: relative; }
.gallery-manager-item[draggable="true"] { cursor: grab; }
.gallery-manager-item.is-dragging { opacity: 0.35; }
.gallery-manager-item.drag-over-before { box-shadow: -3px 0 0 var(--brand) inset; }
.gallery-manager-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.gallery-manager-item .gm-body { padding: 0.6rem; display: grid; gap: 0.4rem; }
.gallery-manager-item input { width: 100%; padding: 0.4em 0.6em; border: 1px solid var(--line); border-radius: 6px; font-size: 0.78rem; }
.gallery-manager-item .gm-row { display: flex; gap: 0.4rem; }
.gallery-manager-item .gm-row button { flex: 1; padding: 0.4em; border-radius: 6px; border: 1px solid var(--line); background: white; cursor: pointer; font-size: 0.76rem; font-weight: 700; }
.gallery-manager-item .gm-row button.save { background: var(--ink); color: white; border-color: var(--ink); }
.gallery-manager-item .gm-row button.del { color: var(--bad); }
.drag-handle { position: absolute; top: 0.4rem; left: 0.4rem; background: rgba(0,0,0,0.55); color: white; font-size: 0.7rem; padding: 0.2em 0.5em; border-radius: 6px; }

/* ---- Forms (banners / popups / settings) ---- */
.form-grid { display: grid; gap: 0.9rem; }
.form-section-title { font-size: 0.95rem; font-weight: 800; color: var(--ink); margin: 0.8rem 0 0; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.form-grid > .form-section-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }
.form-field label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 0.35em; }
.form-field input, .form-field textarea, .form-field select { width: 100%; padding: 0.65em 0.85em; border: 1.5px solid var(--line); border-radius: 8px; font-size: 0.9rem; font-family: inherit; }
.form-field textarea { resize: vertical; min-height: 70px; }
.form-actions { display: flex; gap: 0.6rem; margin-top: 0.4rem; flex-wrap: wrap; }
.form-actions button { padding: 0.6em 1.3em; border-radius: 8px; border: 1px solid var(--line); background: white; cursor: pointer; font-weight: 700; font-size: 0.85rem; }
.form-actions button.primary { background: var(--ink); color: white; border-color: var(--ink); }

.switch-row { display: flex; align-items: center; gap: 0.6em; font-size: 0.85rem; font-weight: 700; }
.switch { position: relative; width: 40px; height: 22px; flex: none; display: inline-block; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s; }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: white; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch input:checked ~ .track { background: var(--good); }
.switch input:checked ~ .track .thumb { transform: translateX(18px); }

/* ---- Item cards (banners / popups lists) ---- */
.item-card { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: 0.8rem; display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.item-card.is-active { border-color: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.item-card h4 { margin: 0 0 0.3em; font-size: 0.95rem; display: flex; align-items: center; gap: 0.5em; }
.item-card p { margin: 0; font-size: 0.82rem; color: var(--ink-soft); }
.item-card .item-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.item-card .item-actions button { padding: 0.4em 0.9em; border-radius: 7px; border: 1px solid var(--line); background: white; font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.item-card .item-actions button.primary { background: var(--ink); color: white; border-color: var(--ink); }
.item-card .item-actions button.danger { color: var(--bad); }
.status-chip { font-size: 0.66rem; font-weight: 800; text-transform: uppercase; padding: 0.2em 0.6em; border-radius: 999px; }
.status-chip.on { background: var(--good-bg); color: var(--good); }
.status-chip.off { background: var(--line); color: var(--ink-soft); }

/* ---- Page Images: grouped slot cards ---- */
.slot-group { margin-bottom: 1.6rem; }
.slot-group:last-child { margin-bottom: 0; }
.slot-group-head { font-size: 0.92rem; font-weight: 800; color: var(--ink); margin: 0 0 0.2rem; }
.slot-group-hint { font-size: 0.78rem; color: var(--ink-soft); margin: 0 0 0.8rem; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.slot-card { border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; background: white; display: flex; flex-direction: column; }
.slot-card-preview { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: var(--paper); display: block; }
.slot-card-placeholder { width: 100%; aspect-ratio: 16/10; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: 0.78rem; }
.slot-card-body { padding: 0.7rem 0.8rem; display: grid; gap: 0.5rem; }
.slot-card-label { font-size: 0.82rem; font-weight: 700; line-height: 1.3; }
.slot-card-change { padding: 0.45em 0.8em; border-radius: 7px; border: 1px solid var(--line); background: var(--paper); font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.slot-card-change:hover { background: var(--brand-light); border-color: var(--brand); }

/* ---- Photo picker modal (shared by every "Change Photo" button) ---- */
.photo-picker { position: fixed; inset: 0; z-index: 100; display: none; }
.photo-picker.is-open { display: block; }
.photo-picker-backdrop { position: absolute; inset: 0; background: rgba(15,18,24,0.55); }
.photo-picker-dialog { position: relative; z-index: 1; background: white; border-radius: 14px; box-shadow: var(--shadow); width: min(920px, 94vw); max-height: 88vh; margin: 6vh auto 0; display: flex; flex-direction: column; overflow: hidden; }
.photo-picker-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); }
.photo-picker-head h2 { margin: 0; font-size: 1.15rem; }
.photo-picker-close { background: none; border: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--ink-soft); padding: 0.2rem 0.4rem; }
.photo-picker-close:hover { color: var(--ink); }
.photo-picker-toolbar { padding: 1rem 1.4rem 0; }
.photo-picker-upload { display: inline-flex; align-items: center; gap: 0.5em; padding: 0.55em 1em; border-radius: 8px; border: 1.5px solid var(--line); background: white; font-size: 0.84rem; font-weight: 700; cursor: pointer; }
.photo-picker-upload:hover { background: var(--paper); }
.photo-picker-cats { padding: 0.9rem 1.4rem 0; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.photo-picker-body { padding: 1rem 1.4rem 1.4rem; overflow-y: auto; flex: 1; }
.photo-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.9rem; }
.photo-picker-tile { border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: white; cursor: pointer; text-align: left; padding: 0; }
.photo-picker-tile img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.photo-picker-tile .pp-name { display: block; padding: 0.4em 0.6em; font-size: 0.72rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-picker-tile:hover { border-color: var(--brand); }
.photo-picker-tile.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.photo-picker-foot { display: flex; justify-content: flex-end; gap: 0.6rem; padding: 1rem 1.4rem; border-top: 1px solid var(--line); }
.photo-picker-foot button { padding: 0.6em 1.3em; border-radius: 8px; border: 1px solid var(--line); background: white; cursor: pointer; font-weight: 700; font-size: 0.85rem; }
.photo-picker-foot button.primary { background: var(--ink); color: white; border-color: var(--ink); }
.photo-picker-foot button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.photo-picker-empty { color: var(--ink-soft); font-size: 0.85rem; padding: 1rem 0; }

.upload-form { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.2rem; }
.upload-form input[type=file] { font-size: 0.82rem; }
.upload-form button { background: var(--ink); color: white; border: none; padding: 0.6em 1.2em; border-radius: 8px; cursor: pointer; font-weight: 700; }
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--ink); color: white; padding: 0.8em 1.2em; border-radius: 10px; font-size: 0.85rem; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: all .2s ease; pointer-events: none; z-index: 50; }
.toast.is-visible { opacity: 1; transform: none; }
