:root {
  --paper: #f4efe4;
  --surface: #fffdf7;
  --surface-2: #faf5ea;
  --border: #e3dac7;
  --ink: #2a2620;
  --ink-muted: #7c7364;
  --accent: #3d5a80;
  --accent-soft: #dbe3ee;
  --ok: #4a7c59;
  --fail: #a8432c;
  --warn: #b07d2b;
  --shadow: 0 1px 2px rgba(40, 32, 20, .05), 0 3px 10px rgba(40, 32, 20, .04);
  --radius: 10px;
  --serif: Georgia, "Iowan Old Style", serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--ink); }

a { color: var(--accent); }

/* ---- shell: sidebar + main ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand { font-family: var(--serif); font-size: 20px; margin: 0 0 4px 8px; }
.brand-sub { color: var(--ink-muted); font-size: 12px; margin: 0 0 20px 8px; }
.navbtn {
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font: inherit;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.navbtn:hover { background: var(--surface-2); color: var(--ink); }
.navbtn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.navbtn .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .7; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.lan-line { color: var(--ink-muted); font-size: 12px; }

.main { padding: 32px 40px; max-width: 1180px; }
.view { display: none; }
.view.active { display: block; }
.view-head { margin: 0 0 4px; font-size: 26px; }
.view-sub { color: var(--ink-muted); margin: 0 0 28px; }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 24px;
}
.card > h3 { margin: 0 0 16px; font-size: 17px; }
.card-note { color: var(--ink-muted); font-size: 13px; margin: 4px 0 0; }

/* ---- stat tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.tile .label { color: var(--ink-muted); font-size: 12.5px; letter-spacing: .02em; text-transform: uppercase; }
.tile .figure { font-family: var(--serif); font-size: 34px; line-height: 1.1; margin-top: 8px; color: var(--ink); }
.tile .sub { color: var(--ink-muted); font-size: 12px; margin-top: 4px; }

/* ---- bar charts (single hue) ---- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.barrow { display: grid; grid-template-columns: 150px 1fr auto; gap: 14px; align-items: center; }
.barrow .blabel { color: var(--ink); font-size: 13.5px; }
.barrow .btrack { position: relative; height: 16px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.barrow .bfill { height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
.barrow .bval { font-variant-numeric: tabular-nums; color: var(--ink-muted); font-size: 13px; white-space: nowrap; }
.barrow.muted .bfill { background: var(--ink-muted); opacity: .5; }

.scrollpanel { max-height: 420px; overflow-y: auto; padding-right: 8px; }
.scrollpanel .barrow { grid-template-columns: 100px 1fr auto; gap: 12px; }
.scrollpanel .barrow .blabel { font-variant-numeric: tabular-nums; }

/* ---- forms ---- */
.field { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
input, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > .field { flex: 1; margin-bottom: 0; }

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.06); }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.ghost:hover { background: var(--accent-soft); filter: none; }
button.danger { background: transparent; color: var(--fail); border: 1px solid var(--fail); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.muted { color: var(--ink-muted); font-size: 13px; }
.hint { color: var(--ink-muted); font-size: 12.5px; margin-top: 6px; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--ink-muted); font-weight: 600; font-size: 12.5px; }
tbody tr:nth-child(even) { background: var(--surface-2); }
td.check { width: 34px; }

/* ---- steps ---- */
.step-title { display: flex; align-items: center; gap: 10px; }
.step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 13px; font-weight: 700; flex: none;
}

/* ---- progress + pills ---- */
.prog { height: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin: 12px 0; }
.prog > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.fail { background: color-mix(in srgb, var(--fail) 16%, transparent); color: var(--fail); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.neutral { background: var(--surface-2); color: var(--ink-muted); border: 1px solid var(--border); }

.counters { display: flex; gap: 20px; flex-wrap: wrap; margin: 8px 0; }
.counters .c { display: flex; flex-direction: column; }
.counters .c b { font-family: var(--serif); font-size: 22px; }
.counters .c span { color: var(--ink-muted); font-size: 12px; }

.confirm { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--border); padding: 12px 14px; border-radius: 8px; margin: 14px 0; }
.confirm input { width: auto; margin-top: 3px; }

.pause-banner { background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px solid var(--warn); color: var(--warn); font-weight: 600; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }

.pager { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
tbody tr.jobrow-active { background: var(--accent-soft); }
#jobLog { max-height: 460px; overflow-y: auto; }
.selbar { display: flex; gap: 14px; align-items: center; margin: 12px 0; }
.selcount { font-weight: 600; color: var(--accent); }

/* ---- charts ---- */
.chart-box { position: relative; height: 300px; margin-top: 8px; }
.chart-scroll { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: var(--surface); }
#versionCanvasWrap, #versionOldCanvasWrap { position: relative; }

/* ---- shuttle / dual-listbox ---- */
.shuttle { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: start; margin-top: 14px; }
.shuttle-col { min-width: 0; }
.shuttle-head { font-family: var(--serif); font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.shuttle-mid { display: flex; flex-direction: column; gap: 10px; padding-top: 40px; }
.shuttle-mid button { white-space: nowrap; }
.add-n { display: flex; gap: 6px; align-items: center; }
.add-n input { width: 68px; padding: 8px 6px; }
.add-n button { flex: 1; padding: 10px 12px; }
.add-n-note { font-size: 12.5px; color: var(--ink-muted); min-height: 0; max-width: 170px; }
.add-n-note:empty { display: none; }
.listbox {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  height: 340px;
  overflow-y: auto;
}
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13.5px;
}
.lb-row:last-child { border-bottom: 0; }
.lb-row:hover { background: var(--surface-2); }
.lb-row.sel { background: var(--accent-soft); }
.lb-row.taken { opacity: .4; cursor: default; }
.lb-row .lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .lb-ver { color: var(--ink-muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.lb-row .lb-x { color: var(--fail); font-weight: 700; padding: 0 4px; }
.lb-empty { padding: 16px; color: var(--ink-muted); font-size: 13px; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .shuttle { grid-template-columns: 1fr; }
  .shuttle-mid { flex-direction: row; flex-wrap: wrap; padding-top: 0; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .brand, .brand-sub { margin: 0 12px 0 0; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .main { padding: 20px 16px; }
  .barrow { grid-template-columns: 90px 1fr auto; }
}

/* ---- auth ---- */
.logout-form { margin-top: 10px; }
button.small { padding: 5px 12px; font-size: 13px; }
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 380px; margin: 0; }
.login-card .brand, .login-card .brand-sub { margin-left: 0; }
.login-error { background: color-mix(in srgb, var(--fail) 12%, transparent); border: 1px solid var(--fail); color: var(--fail); padding: 8px 12px; border-radius: 8px; font-size: 13.5px; }

/* ---- data import ---- */
.rules { margin: 14px 0 0; padding-left: 20px; color: var(--ink-muted); font-size: 13.5px; }
.rules li { margin: 3px 0; }
.fields-table td ul { margin: 0; padding-left: 18px; }
.fields-table td { vertical-align: top; }
.prompt-box { margin-top: 18px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; background: var(--surface-2); }
.prompt-box summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.prompt-pre { white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 12.5px; margin: 0; }
.dl-link { font-weight: 600; font-size: 14px; }
.import-section { margin-top: 14px; }
.import-section summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.import-section .tablewrap { max-height: 360px; overflow: auto; }
.info-banner { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); padding: 10px 14px; border-radius: 8px; margin: 10px 0; font-size: 13.5px; }
.lb-row .lb-days { color: var(--ink-muted); font-size: 11.5px; white-space: nowrap; }
