:root {
  --g: #1d5c47; --gd: #123d2f; --gs: #e4efe9; --a: #f0a830; --bg: #f4f2ec; --line: #e2ded3; --ink: #1e2a25; --muted: #66726c; --red: #b3361d;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--g); }
h1 { font-size: 1.6rem; margin: 0 0 22px; color: var(--gd); }
h2 { font-size: 1.15rem; margin: 0 0 14px; color: var(--gd); }

/* Sidebar */
.side { position: fixed; inset: 0 auto 0 0; width: 240px; background: var(--gd); color: #cfe0d7; display: flex; flex-direction: column; z-index: 20; }
.side-brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; color: #fff; text-decoration: none; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand img { width: 36px; }
.side-brand small { display: block; font-weight: 400; font-size: .75rem; opacity: .6; text-transform: uppercase; letter-spacing: .1em; }
.side nav { padding: 12px 10px; flex: 1; overflow: auto; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: #cfe0d7; text-decoration: none; margin-bottom: 2px; }
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a.on { background: var(--a); color: var(--gd); font-weight: 600; }
.badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; padding: 0 8px; font-size: .78rem; }
.side-foot { padding: 14px 18px 20px; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 8px; }
.side-foot a { color: var(--a); text-decoration: none; }
.side-foot button { background: none; border: 0; color: #cfe0d7; padding: 0; cursor: pointer; text-align: left; font: inherit; }
.side-foot button:hover { color: #fff; }
.mob-bar { display: none; }

.content { padding: 32px 40px 60px; max-width: 1100px; }
.has-side .content { margin-left: 240px; }

/* Panels */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin-bottom: 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; text-decoration: none; color: inherit; }
.stat-card strong { display: block; font-size: 1.9rem; color: var(--g); }
.stat-card span { color: var(--muted); }
.stat-card:hover { border-color: var(--g); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; background: var(--g); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--gd); color: #fff; }
.btn-light { background: #fff; color: var(--g); border-color: var(--line); }
.btn-light:hover { background: var(--gs); color: var(--gd); }
.btn-danger { background: #fff; color: var(--red); border-color: #efc9c0; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }

/* Forms */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.field.wide, .field:has(textarea), .field:has(.img-field) { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .9rem; }
.field input[type=text], .field input[type=email], .field input[type=url], .field input[type=number], .field input[type=password], .field input[type=datetime-local], .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid #cfcabd; border-radius: 8px; font: inherit; background: #fff;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--gs); border-color: var(--g); }
.help { margin: 5px 0 0; color: var(--muted); font-size: .85rem; }
.check { display: inline-flex !important; gap: 8px; align-items: center; font-weight: 500 !important; margin-top: 8px; }
.img-field { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.img-field img { width: 140px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--gs); }
.form-actions { margin-top: 22px; display: flex; gap: 10px; align-items: center; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 6px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs a { padding: 8px 14px; border-radius: 999px; text-decoration: none; background: #fff; border: 1px solid var(--line); color: var(--ink); }
.tabs a.on { background: var(--g); color: #fff; border-color: var(--g); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td .thumb { width: 64px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--gs); display: block; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.actions form { margin: 0; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; background: var(--gs); color: var(--gd); }
.pill.off { background: #eee; color: #777; }
.unread td { font-weight: 600; background: #fffaf0; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; }
.flash-success { background: var(--gs); color: var(--gd); }
.flash-error { background: #fbe4df; color: #7d2412; }
.flash-info { background: #fff4dd; color: #6b4b0c; }
.muted { color: var(--muted); }
.checklist { margin: 0; padding-left: 20px; }
.checklist li { margin-bottom: 6px; }

/* Albums */
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: "▸ "; color: var(--muted); }
details.panel[open] > summary::before { content: "▾ "; }
.field select { width: 100%; padding: 10px 12px; border: 1px solid #cfcabd; border-radius: 8px; font: inherit; background: #fff; }
.field input[type=date] { width: 100%; padding: 9px 12px; border: 1px solid #cfcabd; border-radius: 8px; font: inherit; }
.drop { display: grid; place-items: center; gap: 4px; text-align: center; padding: 34px 20px; border: 2px dashed #bfd3c9; border-radius: 12px; background: var(--gs); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--g); background: #d7e9df; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop strong { font-size: 1.15rem; color: var(--gd); }
.drop span { color: var(--muted); font-size: .9rem; }
.upl { margin-top: 16px; }
.upl .bar { height: 10px; background: #eee; border-radius: 99px; overflow: hidden; }
.upl .bar span { display: block; height: 100%; width: 0; background: var(--g); transition: width .2s; }
.upl p { margin: 8px 0 0; font-weight: 600; }
.upl ul { color: var(--red); margin: 8px 0 0; padding-left: 20px; font-size: .9rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; display: grid; gap: 6px; }
.tile.picked { border-color: var(--g); box-shadow: 0 0 0 2px var(--gs); }
.tile-img { position: relative; display: block; cursor: pointer; }
.tile-img img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; background: var(--gs); }
.tile-img .pick { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; accent-color: var(--g); }
.cover-badge { position: absolute; bottom: 6px; left: 6px; background: var(--a); color: var(--gd); font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.tile input[type=text] { width: 100%; padding: 6px 8px; border: 1px solid #cfcabd; border-radius: 6px; font: inherit; font-size: .85rem; }
.tile-row { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; gap: 6px; }
.tile-row .order { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.tile-row .order input { width: 48px; padding: 3px 4px; border: 1px solid #cfcabd; border-radius: 5px; }
.bulk { flex-wrap: wrap; }
.bulk select { padding: 8px 10px; border: 1px solid #cfcabd; border-radius: 8px; font: inherit; max-width: 230px; }

/* Photo picker */
.or-pick { margin-top: 8px; color: var(--muted); font-size: .9rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mp { position: fixed; inset: 0; background: rgba(10, 25, 20, .6); display: none; place-items: center; z-index: 100; padding: 16px; }
.mp.open { display: grid; }
.mp-box { background: #fff; border-radius: 14px; width: min(980px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.mp-head { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mp-head strong { font-size: 1.1rem; color: var(--gd); margin-right: auto; }
.mp-head select { padding: 7px 10px; border: 1px solid #cfcabd; border-radius: 8px; font: inherit; max-width: 260px; }
.mp-x { background: none; border: 0; font-size: 1.9rem; line-height: 1; cursor: pointer; color: var(--muted); }
.mp-grid { padding: 16px 18px; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.mp-item { padding: 0; border: 3px solid transparent; border-radius: 10px; background: var(--gs); cursor: pointer; overflow: hidden; position: relative; }
.mp-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.mp-item:hover { border-color: #bfd3c9; }
.mp-item.on { border-color: var(--g); }
.mp-item.on::after { content: "✓"; position: absolute; top: 6px; right: 6px; background: var(--g); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }
.mp-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.mp-foot[hidden] { display: none; }

/* Auth screens */
.auth .content { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.auth-box { background: #fff; border-radius: 14px; padding: 32px; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.05); }
.auth-box img { width: 56px; margin-bottom: 10px; }
.auth-box h1 { margin-bottom: 6px; }
.auth-box .fields { grid-template-columns: 1fr; }
.auth-box .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 8px; }

@media (max-width: 860px) {
  .side { transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .has-side .content { margin-left: 0; padding: 20px 16px 60px; }
  .mob-bar { display: flex; gap: 12px; align-items: center; background: var(--gd); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 10; }
  .mob-bar button { background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }
  .content > h1 { display: none; }
  .fields { grid-template-columns: 1fr; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  td { border: 0; padding: 4px 0; }
  .actions { justify-content: flex-start; }
}
