/* My Milk Map admin: shared brand styles.
   Palette from App/lib/config/theme.dart (2026-07 lock, 60-30-10):
   cream #FAFAF6, deep sage #7A8472, terracotta #C97862, blush #E4BFB1,
   charcoal #1F2937. Cormorant Garamond headings, Mulish body.
   The .lesson-* block at the end is the member lesson template used by the
   editor preview; keep it in step with the app renderer (WP-05). */

:root {
  --cream: #FAFAF6;
  --white: #FFFFFF;
  --sage: #7A8472;
  --sage-light: #99A192;
  --sage-dark: #5E6657;
  --sage-stone: #E9EBE3;
  --sage-pale: #DFE2D8;
  --terracotta: #C97862;
  --terracotta-light: #D99584;
  --terracotta-dark: #A65F4B;
  --blush: #E4BFB1;
  --blush-quiet: #F5EAE4;
  --charcoal: #1F2937;
  --muted: #6C7566;
  --error: #B4573F;
  --warning: #D4A35A;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(31, 41, 55, 0.06), 0 4px 16px rgba(31, 41, 55, 0.05);
  --font-head: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "Mulish", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--cream);
  color: var(--charcoal);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-variant-numeric: lining-nums; font-family: var(--font-head); font-weight: 600; color: var(--charcoal); margin: 0 0 0.5em; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
a { color: var(--terracotta-dark); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1 1 auto; }

/* ── Header and navigation ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--sage-stone);
}
.brand { font-family: var(--font-head); font-size: 1.45rem; font-weight: 600; color: var(--sage-dark); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--terracotta); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 auto; }
.nav a {
  padding: 7px 14px; border-radius: 999px; text-decoration: none;
  color: var(--charcoal); font-weight: 600; font-size: 0.9rem;
}
.nav a:hover { background: var(--sage-stone); }
.nav a[aria-current="page"] { background: var(--sage); color: var(--white); }
.who { display: flex; gap: 10px; align-items: center; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

main { padding: 24px; max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }

/* ── Cards, buttons, forms ─────────────────────────────────────────────── */
.card { background: var(--white); border: 1px solid var(--sage-stone); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 0.9rem var(--font-body);
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--terracotta); background: var(--terracotta); color: var(--white);
  text-decoration: none; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--terracotta-dark); border-color: var(--terracotta-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--white); color: var(--sage-dark); border-color: var(--sage); }
.btn.secondary:hover { background: var(--sage-stone); }
.btn.ghost { background: transparent; color: var(--sage-dark); border-color: transparent; }
.btn.ghost:hover { background: var(--sage-stone); }
.btn.danger { background: var(--white); color: var(--error); border-color: var(--error); }
.btn.danger:hover { background: var(--blush-quiet); }
.btn.small { padding: 5px 12px; font-size: 0.8rem; }
.btn.block { width: 100%; }

label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="url"], input[type="number"], input[type="search"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; font: 400 0.95rem var(--font-body); color: var(--charcoal);
  padding: 9px 12px; border: 1.5px solid var(--sage-pale); border-radius: var(--radius-sm); background: var(--white);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--sage); outline-offset: 1px; }
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

.error { color: var(--error); font-weight: 600; }
.notice { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--sage-stone); color: var(--sage-dark); }
.notice.bad { background: var(--blush-quiet); color: var(--error); }

/* Status chips */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; background: var(--sage-stone); color: var(--sage-dark); white-space: nowrap; }
.chip.published, .chip.ready, .chip.granted, .chip.ok { background: var(--sage); color: var(--white); }
.chip.draft, .chip.awaiting_upload, .chip.uploaded { background: var(--sage-stone); color: var(--sage-dark); }
.chip.coming_soon, .chip.transcoding { background: var(--blush-quiet); color: var(--terracotta-dark); }
.chip.error, .chip.failed, .chip.revoked { background: var(--terracotta); color: var(--white); }
.chip.changes { background: var(--blush); color: var(--charcoal); }

/* Pills (segmented toggles and toolbar) */
.pills { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pill {
  font: 600 0.8rem var(--font-body); padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--sage-pale); background: var(--white); color: var(--charcoal);
}
.pill:hover { border-color: var(--sage); }
.pill[aria-pressed="true"] { background: var(--sage); border-color: var(--sage); color: var(--white); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 8px 10px; border-bottom: 1.5px solid var(--sage-stone); }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--sage-stone); vertical-align: middle; }

/* Modal confirmation */
dialog.confirm { border: none; border-radius: var(--radius); padding: 22px 24px; max-width: 440px; width: calc(100% - 32px); box-shadow: 0 10px 40px rgba(31, 41, 55, 0.25); }
dialog.confirm::backdrop { background: rgba(31, 41, 55, 0.35); }
dialog.confirm h3 { margin-bottom: 8px; }
dialog.confirm .row { justify-content: flex-end; margin-top: 18px; }

/* Toast */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--charcoal); color: var(--white); font-weight: 600; box-shadow: var(--shadow); }
.toast.bad { background: var(--error); }

/* Progress bar */
.progress { height: 8px; background: var(--sage-stone); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--sage); transition: width 0.2s; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; }
.login-card .brand { display: block; font-size: 2rem; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.not-admin { text-align: center; font-size: 1.05rem; }

/* ── Dashboard tiles ───────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.tile { background: var(--white); border: 1px solid var(--sage-stone); border-left: 5px solid var(--sage); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-height: 150px; display: flex; flex-direction: column; gap: 6px; }
.tile.attention { border-left-color: var(--terracotta); background: #FDF6F3; }
.tile.attention .big { color: var(--terracotta-dark); }
.tile.off { border-left-color: var(--sage-pale); }
.tile.wide { grid-column: span 2; }
.tile h3 { font-family: var(--font-body); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; display: flex; justify-content: space-between; gap: 8px; }
.tile .big { font-variant-numeric: lining-nums tabular-nums; font-family: var(--font-head); font-size: 2.4rem; font-weight: 600; line-height: 1; color: var(--sage-dark); }
.tile .off-note { color: var(--muted); font-style: italic; margin-top: auto; }
.tile .kv { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.85rem; }
.tile .kv b { font-size: 1.1rem; display: block; }
.tile ul.list { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; max-height: 180px; overflow: auto; }
.tile ul.list li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--sage-stone); }
.tile svg { width: 100%; height: auto; display: block; }
.tile .table-wrap { max-height: 320px; overflow: auto; }
.refresh-note { font-size: 0.8rem; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--sage); margin-right: 6px; }
.dot.bad { background: var(--terracotta); }

/* ── Content tree ──────────────────────────────────────────────────────── */
.content-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
.course-list { list-style: none; margin: 0; padding: 0; }
.course-list li { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; }
.course-list li:hover { background: var(--sage-stone); }
.course-list li[aria-selected="true"] { background: var(--white); border-color: var(--sage); }
.drag-handle { cursor: grab; color: var(--sage-light); user-select: none; font-size: 1.1rem; line-height: 1; padding: 0 2px; }
.dragging { opacity: 0.4; }
.drop-before { box-shadow: 0 -3px 0 var(--terracotta); }
.module-block { border: 1px solid var(--sage-stone); border-radius: var(--radius); margin-top: 14px; background: var(--white); }
.module-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; background: var(--sage-stone); border-radius: var(--radius) var(--radius) 0 0; }
.module-head h3 { margin: 0; font-size: 1.2rem; }
.lesson-rows { list-style: none; margin: 0; padding: 4px 0; }
.lesson-rows li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--sage-stone); }
.lesson-rows li:last-child { border-bottom: none; }
.lesson-rows li.optional { border-left: 3px dashed var(--blush); }
.lesson-rows .title { flex: 1 1 200px; font-weight: 600; }
.ctl { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.ctl select { width: auto; padding: 4px 8px; font-size: 0.8rem; }
.ctl input[type="checkbox"] { accent-color: var(--sage); }

/* ── Lesson editor ─────────────────────────────────────────────────────── */
.editor-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.editor-bar .title-input { flex: 1 1 320px; font-family: var(--font-head); font-size: 1.4rem; font-weight: 600; }
.save-state { font-size: 0.8rem; color: var(--muted); min-width: 120px; }
.save-state.dirty { color: var(--terracotta-dark); }
.editor-panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.editor-left { display: flex; flex-direction: column; gap: 10px; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar .pill { min-width: 38px; }
textarea.md { min-height: 520px; font: 400 0.92rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.editor-right { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; border-radius: var(--radius); background: #F4F4EF; padding: 14px; border: 1px solid var(--sage-stone); }
.side-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.resources-edit { list-style: none; padding: 0; margin: 0; }
.resources-edit li { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; max-height: 360px; overflow: auto; margin: 10px 0; }
.picker-grid button { text-align: left; border: 1.5px solid var(--sage-pale); background: var(--white); border-radius: var(--radius-sm); padding: 8px; cursor: pointer; font: inherit; }
.picker-grid button:hover { border-color: var(--sage); }
.picker-grid button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Member lesson template (preview). Mirrors reference/kajabi-lesson-page.png in our colours. */
.lesson-page { font-family: var(--font-body); color: var(--charcoal); }
.lesson-hero { display: grid; grid-template-columns: minmax(0, 1fr) 210px; background: var(--charcoal); border-radius: var(--radius-sm) var(--radius-sm) 0 0; overflow: hidden; }
.lesson-video { position: relative; aspect-ratio: 16 / 9; background: #2B3440; display: grid; place-items: center; color: var(--cream); }
.lesson-video video, .lesson-video img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lesson-video .placeholder { text-align: center; font-size: 0.85rem; opacity: 0.85; padding: 12px; }
.lesson-video .play { width: 54px; height: 54px; border-radius: 50%; background: rgba(250, 250, 246, 0.9); display: grid; place-items: center; margin: 0 auto 8px; color: var(--terracotta); font-size: 1.4rem; }
.lesson-side { background: #2B3440; color: var(--cream); font-size: 0.78rem; overflow: auto; max-height: 100%; }
.lesson-side .side-head { display: flex; justify-content: space-between; padding: 10px 12px; font-weight: 700; border-bottom: 1px solid rgba(250, 250, 246, 0.12); }
.lesson-side ol { list-style: none; margin: 0; padding: 0; }
.lesson-side li { display: flex; gap: 8px; padding: 8px 12px; border-bottom: 1px solid rgba(250, 250, 246, 0.06); }
.lesson-side li.current { background: rgba(201, 120, 98, 0.25); }
.lesson-side li .n { color: var(--blush); min-width: 14px; }
.lesson-side li.opt .t { font-style: italic; opacity: 0.85; }
.lesson-card { background: var(--white); padding: 22px 26px 28px; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.lesson-complete { display: block; width: 100%; padding: 12px; background: var(--white); color: var(--terracotta); border: 1.5px solid var(--terracotta); border-radius: 4px; font: 600 0.9rem var(--font-body); cursor: default; margin-bottom: 22px; }
.lesson-title { font-family: var(--font-head); font-size: 2rem; font-weight: 700; margin: 0 0 6px; }
.lesson-module { color: var(--terracotta); font-weight: 700; font-size: 1.05rem; margin: 0 0 16px; }
.lesson-body { font-size: 1rem; line-height: 1.65; }
.lesson-body h1, .lesson-body h2, .lesson-body h3 { font-family: var(--font-head); margin: 1.2em 0 0.4em; }
.lesson-body h1 { font-size: 1.7rem; }
.lesson-body h2 { font-size: 1.45rem; }
.lesson-body h3 { font-size: 1.2rem; }
.lesson-body p { margin: 0 0 0.9em; }
.lesson-body ul, .lesson-body ol { margin: 0 0 0.9em; padding-left: 1.4em; }
.lesson-body li { margin: 0.2em 0; }
.lesson-body a { color: var(--terracotta-dark); }
.lesson-body blockquote { margin: 0 0 0.9em; padding: 6px 14px; border-left: 3px solid var(--sage); color: var(--sage-dark); font-style: italic; }
.lesson-body img { max-width: 100%; border-radius: var(--radius-sm); }
.lesson-body hr { border: none; border-top: 1px solid var(--sage-stone); margin: 1.4em 0; }
.callout { margin: 0 0 1em; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--sage-stone); border-left: 4px solid var(--sage); }
.callout .callout-title { font-weight: 700; margin-bottom: 4px; color: var(--sage-dark); }
.callout p:last-child { margin-bottom: 0; }
.callout.tip { background: #EEF0E9; }
.callout.important { background: var(--blush-quiet); border-left-color: var(--terracotta); }
.callout.important .callout-title { color: var(--terracotta-dark); }
.callout.warning { background: #FBF1E2; border-left-color: var(--warning); }
.callout.warning .callout-title { color: #8A6424; }
.lesson-resources { margin-top: 26px; border-top: 1px solid var(--sage-stone); padding-top: 16px; }
.lesson-resources h3 { font-family: var(--font-head); font-size: 1.3rem; }
.lesson-resources ul { list-style: none; padding: 0; margin: 0; }
.lesson-resources li { padding: 8px 12px; border: 1px solid var(--sage-stone); border-radius: var(--radius-sm); margin-bottom: 6px; display: flex; justify-content: space-between; }

/* ── Media library ─────────────────────────────────────────────────────── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.media-card { display: flex; flex-direction: column; gap: 8px; }
.media-thumb { aspect-ratio: 16 / 9; background: #2B3440; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--cream); font-size: 0.8rem; overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dropzone { border: 2px dashed var(--sage-light); border-radius: var(--radius); padding: 22px; text-align: center; background: var(--white); }
.dropzone.over { background: var(--sage-stone); }

/* ── Tablet ────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .editor-panes { grid-template-columns: 1fr; }
  .editor-right { position: static; max-height: none; }
  .tile.wide { grid-column: auto; }
}
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  main { padding: 16px; }
  .content-layout { grid-template-columns: 1fr; }
  .lesson-hero { grid-template-columns: 1fr; }
  .lesson-side { max-height: 200px; }
  .side-panel { grid-template-columns: 1fr; }
}
.pad-note { padding: 10px 14px; margin: 0; }
.pad-row { padding: 8px 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.media-layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 20px; align-items: start; }
.media-layout #detail { position: sticky; top: 70px; }
.media-layout #detail .lesson-video { border-radius: var(--radius-sm); overflow: hidden; margin: 8px 0 12px; }
button.media-card { text-align: left; font: inherit; color: inherit; cursor: pointer; }
button.media-card[aria-pressed="true"] { border-color: var(--sage); box-shadow: 0 0 0 2px var(--sage-pale); }
#summary { gap: 18px; }
@media (max-width: 1100px) { .media-layout { grid-template-columns: 1fr; } .media-layout #detail { position: static; } }
.media-layout #detail h3 { margin-top: 18px; }
.media-layout #detail .ctl input { width: 110px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.two-col .ctl input[type="number"], .two-col .ctl input[type="text"] { width: 90px; }
table.data th[scope], #member table.data th { text-transform: none; letter-spacing: 0; font-size: 0.85rem; width: 40%; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }
#lookup input { flex: 1 1 220px; width: auto; }
.settings-form { max-width: 760px; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; }
.btn.small { min-height: 28px; }
.drag-handle { min-width: 28px; }

/* Sessions (WP-10) */
.sessions-layout { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .sessions-layout { grid-template-columns: 1fr; } }
.when-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .when-grid { grid-template-columns: 1fr; } }
.subpanel { border: 1px solid var(--sage-stone); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--cream); margin: 0 0 14px; }
.subpanel legend { font-weight: 600; font-size: 0.85rem; padding: 0 4px; }
.subpanel .ctl { color: var(--charcoal); font-size: 0.9rem; margin: 4px 0; }
select.auto, input.auto { width: auto; display: inline-block; }
input.narrow { width: 80px; }
.zone-pickers { margin-bottom: 10px; }
.zone-pickers select { flex: 1 1 120px; min-width: 0; }
#preview td, #preview th { font-size: 0.82rem; }
#preview tr.cancelled td { text-decoration: line-through; color: var(--muted); }
.occ-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.occ-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--sage-stone); }
.occ-list li .when { flex: 1 1 180px; font-size: 0.88rem; }
.occ-list li.cancelled .when { text-decoration: line-through; color: var(--muted); }
.chip.cancelled { background: var(--blush-quiet); color: var(--terracotta-dark); }
.chip.moved { background: var(--blush); color: var(--charcoal); }
#event-form > .ctl { margin-bottom: 14px; }
.subpanel input[type="date"].auto { padding: 5px 8px; }
