/* Plan Manager (/manage) — office UI for the stock plan catalog.
   Brand: navy #3c4856, steel blue #5f7fa3, sand #c8bcab, cream #f7f4ee. Fonts self-hosted. */
@font-face { font-family: 'Cormorant Garamond'; font-display: swap; src: url('/fonts/CormorantGaramond.woff2') format('woff2'); font-weight: 100 700; }
@font-face { font-family: 'Open Sans'; font-display: swap; src: url('/fonts/OpenSans.woff2') format('woff2'); font-weight: 100 800; }

:root {
  --navy: #3c4856; --navy-dark: #2c3540; --blue: #5f7fa3; --blue-wash: #eef2f7; --sand: #c8bcab; --cream: #f7f4ee;
  --ink: #2b3138; --muted: #6b7480; --rule: #e3ddd1; --paper: #fff; --ok: #2f7d4a; --err: #c0392b; --warn: #b26a00;
  --radius: 4px; --shadow: 0 10px 30px rgba(44, 53, 64, .10);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Open Sans', system-ui, sans-serif; font-size: 15px; line-height: 1.6; color: var(--ink); background: var(--cream); }
h1, h2, h3 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; color: var(--navy); margin: 0 0 .4em; line-height: 1.15; letter-spacing: .01em; }
h1 { font-size: 36px; } h2 { font-size: 28px; } h3 { font-size: 22px; }
a { color: var(--blue); }
a:hover { color: var(--navy); }
img { max-width: 100%; height: auto; display: block; }
.muted { color: var(--muted); } .small { font-size: 13px; } .loading { padding: 40px; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--navy); color: #fff; padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button { font: inherit; }

/* ── Auth ── */
.auth { max-width: 420px; margin: 8vh auto 40px; background: var(--paper); border: 1px solid var(--rule); padding: 40px 36px 28px; box-shadow: var(--shadow); }
.auth-logo { width: 200px; margin: 0 auto 22px; }
.auth h1 { text-align: center; font-size: 30px; }
.auth p.lead { text-align: center; color: var(--muted); margin: 0 0 22px; }
.auth form label { display: block; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--navy); margin: 14px 0 6px; }
.auth form .hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
.auth .btn { width: 100%; margin-top: 18px; }
.auth .links { display: flex; justify-content: center; gap: 18px; margin: 16px 0 0; font-size: 13px; }

/* ── Inputs ── */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid #cfc7b8; border-radius: var(--radius); padding: 10px 12px; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(95,127,163,.18); }
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--navy); vertical-align: -3px; margin-right: 8px; }
.field { margin: 0 0 16px; }
.field > label, .field > .lbl { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--navy); margin-bottom: 6px; }
.field .help { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 600; letter-spacing: .03em; text-decoration: none; transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); color: #fff; }
.btn-ghost { background: #fff; color: var(--navy); border-color: #cfc7b8; }
.btn-ghost:hover { border-color: var(--navy); }
.btn-danger { background: #fff; color: var(--err); border-color: #e4b9b3; }
.btn-danger:hover { background: #fbf1ef; border-color: var(--err); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled], form.busy .btn { opacity: .55; pointer-events: none; }
.btn-link { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; text-decoration: underline; font-size: 13px; }
.btn-link:hover { color: var(--navy); }

/* ── Shell ── */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #fff; padding: 24px 18px; display: flex; flex-direction: column; gap: 22px; }
.side .brand img { width: 170px; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a, .side nav button { display: flex; align-items: center; justify-content: space-between; color: rgba(255,255,255,.82); text-decoration: none; padding: 10px 12px; border-radius: var(--radius); background: none; border: 0; cursor: pointer; font-size: 14.5px; text-align: left; transition: background-color .15s ease, color .15s ease; }
.side nav a:hover, .side nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.side nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.side nav .count { font-size: 12px; background: rgba(255,255,255,.14); padding: 1px 8px; border-radius: 10px; }
.side .foot { margin-top: auto; font-size: 12.5px; color: rgba(255,255,255,.6); }
.side .foot a { color: rgba(255,255,255,.85); }
.main { padding: 32px 40px 60px; max-width: 1180px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.topbar p { margin: 0; color: var(--muted); }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 14px 16px; gap: 10px; }
  .side .brand img { width: 130px; }
  .side nav { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .side nav a, .side nav button { padding: 8px 10px; font-size: 13.5px; }
  .side .foot { display: none; }
  .main { padding: 20px 16px 50px; }
}

/* ── Cards / tables ── */
.card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; }
.card h2 { font-size: 24px; margin-bottom: 12px; }
.card .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.table td { padding: 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table tr:hover td { background: var(--blue-wash); }
.table .thumb { width: 72px; height: 44px; object-fit: cover; border-radius: 3px; background: var(--cream); }
.table .name { font-weight: 600; color: var(--navy); }
.table .name a { text-decoration: none; }
.table .name a:hover { text-decoration: underline; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; padding: 2px 9px; border-radius: 10px; background: var(--blue-wash); color: var(--blue); }
.pill.active { background: #e6f2ea; color: var(--ok); } .pill.draft { background: #fbf3e1; color: var(--warn); } .pill.archived { background: #f0eeea; color: var(--muted); }
.pill.star { background: #fff4d6; color: #8a5a00; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); border: 1px dashed #d9d2c4; border-radius: var(--radius); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type="text"] { max-width: 280px; }
.note { background: var(--blue-wash); border-left: 3px solid var(--blue); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; font-size: 14px; margin: 0 0 18px; }
.note.warn { background: #fbf3e1; border-color: var(--warn); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; }
.stat .n { font-family: 'Cormorant Garamond', serif; font-size: 34px; font-weight: 600; color: var(--navy); line-height: 1; }
.stat .l { font-size: 12.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }

/* ── Editor ── */
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.editor-head .crumbs { font-size: 13px; color: var(--muted); }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sticky-save { position: sticky; bottom: 0; background: rgba(247,244,238,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--rule); padding: 12px 0; margin-top: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; z-index: 5; }
.sticky-save .status { color: var(--muted); font-size: 13px; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row-item { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: center; }
.row-item.sheet { grid-template-columns: 96px 1fr 1fr auto; }
.row-item .thumb { width: 96px; height: 60px; object-fit: cover; border-radius: 3px; background: var(--cream); border: 1px solid var(--rule); }
.row-item .move { display: flex; gap: 4px; }
.icon-btn { width: 34px; height: 34px; border: 1px solid #cfc7b8; background: #fff; border-radius: var(--radius); cursor: pointer; color: var(--navy); display: inline-flex; align-items: center; justify-content: center; transition: border-color .15s ease, background-color .15s ease; }
.icon-btn:hover { border-color: var(--navy); background: var(--blue-wash); }
.icon-btn.danger:hover { border-color: var(--err); color: var(--err); background: #fbf1ef; }
.img-pick { display: grid; grid-template-columns: 160px 1fr; gap: 14px; align-items: start; }
.img-pick .preview { width: 160px; height: 100px; object-fit: cover; border: 1px solid var(--rule); border-radius: 3px; background: var(--cream); }
.img-pick .preview.empty-img { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
.img-pick .controls { display: flex; flex-direction: column; gap: 8px; }
.img-pick .controls .btns { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 720px) { .row-item, .row-item.sheet { grid-template-columns: 1fr; } .img-pick { grid-template-columns: 1fr; } }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.media-item { background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.media-item img { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: var(--cream); }
.media-item .meta { padding: 8px 10px; font-size: 12.5px; }
.media-item .meta .lbl { font-weight: 600; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item .meta .btns { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.media-item.selectable { cursor: pointer; transition: box-shadow .15s ease, transform .15s ease; }
.media-item.selectable:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.dropzone { border: 2px dashed #cfc7b8; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); transition: border-color .15s ease, background-color .15s ease; }
.dropzone.over { border-color: var(--blue); background: var(--blue-wash); }
.dropzone input { display: none; }
.progress { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; margin-top: 10px; display: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--blue); transition: width .2s ease; }

/* ── Modal (image picker) ── */
.overlay { position: fixed; inset: 0; background: rgba(44,53,64,.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 40; }
.dialog { background: #fff; border-radius: var(--radius); width: min(960px, 100%); max-height: 90vh; overflow: auto; padding: 22px 24px; box-shadow: var(--shadow); }
.dialog .dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }

/* ── Messages ── */
.form-msg { min-height: 20px; margin: 12px 0 0; font-size: 14px; }
.form-msg.ok { color: var(--ok); } .form-msg.err { color: var(--err); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px); background: var(--navy); color: #fff; padding: 12px 20px; border-radius: var(--radius); font-size: 14px; opacity: 0; transition: opacity .2s ease, transform .2s ease; z-index: 60; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; } }

/* sidebar logo: the navy mark on the navy rail — same inversion the home header uses */
.side .brand img { filter: brightness(0) invert(1); opacity: .92; }

/* ── Plan files: drop zone, list, readiness checklist ─────────────────── */
.dropzone {
  border: 1.5px dashed var(--line, #cfd6dd);
  border-radius: 6px;
  background: var(--surface-2, #f7f9fa);
  padding: 26px 20px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color .18s ease, background-color .18s ease;
}
.dropzone:hover,
.dropzone:focus-visible { border-color: var(--accent, #3c4856); background: #fff; }
.dropzone:focus-visible { outline: 2px solid var(--accent, #3c4856); outline-offset: 2px; }
.dropzone.over { border-color: var(--accent, #3c4856); border-style: solid; background: #fff; }
.dropzone strong { font-size: 15px; }
.dropzone span { font-size: 13px; color: var(--muted, #6b7680); }

.filelist { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.filelist li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line, #e2e7ec); border-radius: 5px; background: #fff;
}
.filelist .ext {
  flex: none; min-width: 46px; text-align: center;
  font-size: 10.5px; letter-spacing: .06em; font-weight: 700;
  color: var(--accent, #3c4856); background: var(--surface-2, #eef2f5);
  border-radius: 3px; padding: 5px 6px;
}
.filelist .fname { flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; padding: 5px 7px; font-size: 14px; border-radius: 4px; }
.filelist .fname:hover { border-color: var(--line, #e2e7ec); }
.filelist .fname:focus { border-color: var(--accent, #3c4856); background: #fff; outline: none; }
.filelist .size { flex: none; font-size: 12px; color: var(--muted, #6b7680); font-variant-numeric: tabular-nums; }
.filefoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }

.checklist { list-style: none; margin: 16px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.checklist li { display: flex; align-items: flex-start; gap: 11px; }
.checklist .tick {
  flex: none; width: 20px; height: 20px; border-radius: 50%; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  background: var(--line, #cfd6dd);
}
.checklist li.done .tick { background: #2e7d5b; }
.checklist li > span:nth-child(2) { display: flex; flex-direction: column; gap: 2px; }
.checklist strong { font-size: 14px; font-weight: 600; }

.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14.5px; margin-top: 4px; }
.toggle input { width: 17px; height: 17px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 640px) {
  .filelist li { flex-wrap: wrap; }
  .filelist .fname { flex-basis: 100%; order: 3; }
}
