:root {
  --ink: #1e2921;
  --muted: #627064;
  --line: #b9c5ae;
  --paper: #e5e8d9;
  --panel: #f4f4e8;
  --white: #fffdf4;
  --green: #5f7d4b;
  --green-dark: #263c2b;
  --olive: #74805a;
  --rust: #9b6842;
  --amber: #c6a35b;
  --forest: #3f5b43;
  --brand-highlight: #95b35f;
  --brand-theme: #2c4531;
  --shadow: 0 24px 60px rgba(42, 65, 45, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 76% 4%, rgba(107, 139, 79, 0.22), transparent 28rem),
    linear-gradient(rgba(53, 76, 55, .03) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 100% 28px, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body:not(.authenticated) { overflow: hidden; }

button, input { font: inherit; }
button { cursor: pointer; }

.auth-gate { min-height: 100dvh; position: fixed; inset: 0; z-index: 100; padding: 20px; display: grid; place-items: center; overflow-y: auto; background: radial-gradient(circle at 70% 12%, var(--green), transparent 35rem), var(--brand-theme); }
.auth-gate.hidden { display: none; }
.login-card { width: min(420px, 100%); padding: 30px; display: grid; gap: 16px; border: 1px solid #809879; border-radius: 18px; color: var(--ink); background: var(--panel); box-shadow: 0 35px 90px rgba(8, 25, 13, .38); }
.login-card .brand-mark { width: 46px; height: 46px; }
.login-card h1 { margin: 0; font-size: 32px; letter-spacing: -.045em; }
.login-card > p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.login-card input { height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: white; }
.login-card input:focus { border-color: #6b8961; box-shadow: 0 0 0 3px rgba(95,125,75,.15); }
.login-card small { color: var(--muted); text-align: center; font-size: 9px; }
.login-error { min-height: 15px; color: #a33d30 !important; font-weight: 750; }
.login-secondary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.login-divider { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; background: var(--line); }
.oauth-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.oauth-button { display: flex; align-items: center; justify-content: center; gap: 8px; border-color: var(--line); background: white; }
.oauth-button b { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--forest); font-size: 10px; }
.oauth-button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.topbar {
  min-height: 76px;
  padding: 10px clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 26, 23, 0.1);
  background: rgba(229, 232, 217, 0.92);
  backdrop-filter: blur(16px);
  position: relative;
  z-index: 10;
}
.brand-intro { min-width: 0; display: flex; align-items: center; gap: clamp(14px, 2.5vw, 38px); }
.top-tagline { margin: 0; display: flex; align-items: baseline; gap: 7px; white-space: nowrap; pointer-events: none; }
.top-tagline strong { font-size: 11px; letter-spacing: .04em; }
.top-tagline em { color: #587250; font-family: Georgia, serif; font-size: 13px; }

.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong, .brand small { display: block; line-height: 1; }
.brand strong { font-size: 14px; text-transform: uppercase; letter-spacing: 0.14em; }
.brand small { margin-top: 5px; color: var(--muted); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; }

.brand-mark {
  width: 38px;
  height: 38px;
  padding: 5px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  border-radius: 10px;
  background: var(--ink);
  transform: rotate(-5deg);
}

.brand-mark span { border-radius: 2px; background: var(--brand-highlight); }
.top-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.top-action-button { min-height: 40px; color: #f7f8ed; border-color: #314a35; background: var(--forest); }
.top-action-button:hover { background: #527054; }
.single-heading { display:flex; align-items:end; justify-content:space-between; gap:18px; }
.account-menu-wrap { position: relative; }
.account-menu-button { display: flex; align-items: center; gap: 7px; }
.account-menu-button span { color: var(--muted); font-size: 9px; }
.account-menu { width: 220px; padding: 7px; display: grid; position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; border: 1px solid var(--line); border-radius: 10px; background: var(--white); box-shadow: 0 18px 45px rgba(30, 50, 33, .2); }
.account-menu strong { padding: 9px 10px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.account-menu button { min-height: 36px; padding: 0 10px; border: 0; border-radius: 6px; color: var(--ink); background: transparent; text-align: left; font-size: 10px; font-weight: 750; }
.account-menu button:hover { background: #e8eddf; }
.account-menu #logoutButton { color: #8c4638; border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; }
.status-dot, .live-pill { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.status-dot i, .live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(95, 125, 75, 0.14); }

.button {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 750;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:hover { transform: translateY(-1px); }
.button-primary { color: #f7f8ed; background: var(--forest); border-color: #314a35; }
.button-primary:hover { background: #527054; }
.button-secondary { background: var(--white); border-color: var(--line); }
.button-ghost { background: transparent; border-color: var(--line); }
.button-large { min-width: 210px; min-height: 58px; display: grid; place-content: center; }
.button-large span { font-size: 15px; }
.button-large small { margin-top: 2px; color: #536344; font-size: 10px; font-weight: 600; }

main { width: min(1440px, calc(100% - 40px)); margin: 0 auto; }

.mode-tabs {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  border: 1px solid #aebba5;
  border-radius: 14px;
  background: rgba(247, 248, 237, .66);
  box-shadow: 0 12px 30px rgba(42, 65, 45, .08);
}
.mode-tab {
  min-height: 64px;
  padding: 11px 16px;
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}
.mode-tab > span { grid-row: 1 / 3; width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: 8px; font-weight: 850; }
.mode-tab strong { color: var(--ink); font-size: 13px; }
.mode-tab small { font-size: 10px; }
.mode-tab.active { color: #c6d59e; border-color: #2b4530; background: #2c4531; box-shadow: 0 8px 18px rgba(37, 65, 42, .2); }
.mode-tab.active strong { color: #fff7eb; }
.mode-tab.active small { color: #bacbb3; }
.mode-panel { animation: mode-in 180ms ease; }
@keyframes mode-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.ad-slot {
  width: min(970px, 100%);
  min-height: 90px;
  margin: 26px auto;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  border: 1px dashed #718467;
  border-radius: 12px;
  color: #f8ead7;
  background: linear-gradient(120deg, #486049, #273b2d);
  box-shadow: 0 14px 35px rgba(42, 65, 45, .15);
}
.ad-slot-bottom { margin-top: 40px; margin-bottom: 70px; background: linear-gradient(120deg, #4d5941, #303a2e); border-color: #758066; }
.ad-label { padding: 5px 7px; border: 1px solid rgba(255,255,255,.25); border-radius: 4px; color: #d7dda8; font-size: 8px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; }
.ad-slot div { min-width: 0; }
.ad-slot strong, .ad-slot small { display: block; }
.ad-slot strong { font-family: Georgia, serif; font-size: 16px; letter-spacing: .01em; }
.ad-slot small { margin-top: 4px; color: #d4c0aa; font-size: 10px; }
.ad-cta { color: #d7dda8; font-size: 9px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }

.eyebrow { margin: 0 0 12px; color: var(--forest); font-size: 11px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.single-heading { max-width: 720px; padding: 48px 0 22px; }
.single-heading h2 { margin-bottom: 10px; font-size: 34px; letter-spacing: -.045em; }
.single-heading p:last-child { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }

.workspace { display: grid; grid-template-columns: minmax(330px, 0.72fr) minmax(560px, 1.28fr); gap: 20px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { min-height: 72px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-heading > div { display: flex; align-items: center; gap: 12px; }
.panel-heading h2, .action-card h2 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.panel-heading-actions { display: flex; align-items: center; gap: 4px; }
.preview-colour-control { display: grid; gap: 4px; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.preview-colour-control select { max-width: 170px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: var(--white); font-size: 10px; font-weight: 750; text-transform: none; }
.step { min-width: 27px; height: 27px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: #7c857c; font-size: 9px; font-weight: 800; }
.text-button { padding: 8px; border: 0; color: var(--muted); background: none; font-size: 12px; font-weight: 700; }

.control-section { padding: 21px 22px 23px; border-bottom: 1px solid var(--line); }
.control-section:last-child { border-bottom: 0; }
.section-label { margin-bottom: 17px; display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.axis-grid, .two-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.axis-control { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.axis-control label, .field-label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 700; }
.stepper { display: grid; grid-template-columns: 30px minmax(0, 1fr) 30px; align-items: center; gap: 3px; }
.stepper button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: #f8f8f4; font-size: 18px; line-height: 1; }
.stepper output { text-align: center; font-size: 22px; font-weight: 800; }
input[type="range"] { width: 100%; margin-top: 12px; accent-color: var(--green); }

.choice-row { display: flex; gap: 6px; }
.choice-row > button { min-width: 43px; height: 40px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--white); font-size: 12px; font-weight: 750; }
.choice-row > button.active { color: var(--ink); border-color: #79936a; background: #e2ead4; }
.base-shape-toggle { margin-bottom: 16px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border: 1px solid var(--line); border-radius: 9px; background: #e4e8da; }
.base-shape-toggle button { min-height: 36px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 800; }
.base-shape-toggle button.active { color: white; background: var(--forest); }
.number-field { display: grid; gap: 7px; margin-top: 16px; color: var(--muted); font-size: 11px; font-weight: 700; }
.number-field.compact { width: 77px; height: 40px; margin: 0 0 0 auto; padding: 0 8px; display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.number-field.compact input { width: 43px; padding: 0; border: 0; background: transparent; outline: 0; font-size: 12px; font-weight: 750; }
.number-field.compact span { font-size: 10px; }
.input-wrap { height: 40px; padding: 0 10px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.input-wrap input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-weight: 750; }
.input-wrap select { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-weight: 750; }
.input-wrap b { color: var(--muted); font-size: 10px; }

.switch-row { margin-top: 16px; display: grid; grid-template-columns: 1fr auto; align-items: center; cursor: pointer; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { color: var(--ink); font-size: 12px; }
.switch-row small { margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 500; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { width: 38px; height: 22px; padding: 3px; border-radius: 20px; background: #cdd2ca; transition: background 150ms ease; }
.switch-row i::after { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: transform 150ms ease; }
.switch-row input:checked + i { background: var(--green); }
.switch-row input:checked + i::after { transform: translateX(16px); }
.conditional.disabled { opacity: 0.38; pointer-events: none; }

.preview-column { min-width: 0; display: grid; gap: 20px; }
.preview-stage { min-height: 465px; position: relative; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle at center, #faffef 0, #e8eddd 64%, #d4ddca 100%); }
.preview-stage::before { content: ""; position: absolute; inset: 0; opacity: 0.35; background-image: linear-gradient(rgba(30,35,29,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(30,35,29,.055) 1px, transparent 1px); background-size: 24px 24px; mask-image: radial-gradient(circle, black, transparent 73%); }
#trayPreview { width: 92%; height: auto; max-height: 440px; position: relative; filter: drop-shadow(0 24px 18px rgba(41, 49, 33, 0.18)); }
.dimension { position: absolute; z-index: 2; padding: 5px 8px; border: 1px solid #b4c2aa; border-radius: 5px; color: #3d5c43; background: rgba(250,255,241,.9); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.dimension-width { bottom: 33px; left: 50%; transform: translateX(-50%); }
.dimension-depth { top: 48%; right: 18px; transform: rotate(90deg); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.stats div { padding: 18px; border-right: 1px solid var(--line); }
.stats div:last-child { border-right: 0; }
.stats span, .stats strong { display: block; }
.stats span { margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.stats strong { font-size: 12px; }

.action-card { padding: 25px; display: flex; align-items: center; justify-content: space-between; gap: 30px; border-radius: 16px; color: white; background: #263a2b; box-shadow: var(--shadow); }
.action-card > div:first-child { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; }
.action-card .step { grid-row: span 2; color: #aeb5aa; border-color: #50564e; }
.action-card p { grid-column: 2; max-width: 500px; margin: 8px 0 0; color: #aeb5aa; font-size: 11px; line-height: 1.6; }
.action-buttons { display: flex; gap: 9px; }
.action-card .button-secondary { color: white; border-color: #4a5048; background: transparent; }

.army-section { padding: 70px 0 10px; }
.army-heading { margin-bottom: 22px; display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.army-heading h2 { margin-bottom: 10px; font-size: 34px; letter-spacing: -.045em; }
.army-heading p:last-child { max-width: 680px; margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.catalogue-pill { padding: 8px 11px; border: 1px solid #879c79; border-radius: 30px; color: #36503b; background: #e4ebd9; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.army-workspace { display: grid; grid-template-columns: minmax(300px, .68fr) minmax(500px, 1.32fr); gap: 20px; align-items: start; }
.army-input-card, .army-results-wrap { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.army-input-card { padding: 22px; }
.army-project-bar { margin-bottom: 18px; display: grid; grid-template-columns: 1fr auto auto; gap: 6px; }
.army-project-bar input, .army-project-bar button { min-width: 0; height: 36px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); }
.army-project-bar input { padding: 0 10px; outline: 0; }
.army-project-bar button { padding: 0 10px; color: var(--forest); font-size: 9px; font-weight: 800; }
.army-input-card label { display: block; margin-bottom: 10px; font-size: 12px; font-weight: 800; }
.army-input-card textarea { width: 100%; min-height: 260px; padding: 14px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; outline: 0; color: var(--ink); background: white; font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }
.army-input-card textarea:focus { border-color: #78936a; box-shadow: 0 0 0 3px rgba(95, 125, 75, .14); }
.army-input-actions { margin-top: 12px; display: flex; justify-content: space-between; gap: 10px; }
.army-note { margin: 15px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.army-results-heading { min-height: 64px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.army-results-heading > div { display: flex; align-items: center; gap: 10px; }
.army-results-heading h3 { margin: 0; font-size: 14px; }
.army-results-heading > span { color: var(--muted); font-size: 10px; font-weight: 750; }
.army-results { min-height: 320px; padding: 12px; display: grid; gap: 10px; }
.army-tray-tabs { padding: 10px 10px 0; display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.army-tray-tabs button { min-width: 170px; padding: 7px 9px 8px; display: grid; grid-template-columns: 60px 1fr; align-items: center; gap: 6px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; color: var(--muted); background: #e8ecdc; text-align: left; }
.army-tray-tabs button span { min-width: 0; display: grid; gap: 3px; }
.army-tray-tabs button strong { color: var(--ink); font-size: 10px; white-space: nowrap; }
.army-tray-tabs button small { font-size: 8px; font-weight: 750; }
.army-tray-tabs button.active { border-color: #3d5c43; color: #c5d5a5; background: #2d4532; }
.army-tray-tabs button.active strong { color: #fff7ec; }
.empty-army { min-height: 295px; display: grid; place-items: center; padding: 30px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; font-size: 11px; }
.tray-thumb { width: 100%; height: auto; overflow: visible; }
.tray-thumb rect { fill: #78955c; stroke: #35503a; stroke-width: 4px; }
.tray-thumb line { stroke: #b6cc91; stroke-width: 1px; opacity: .65; }
.army-unit { min-height: 270px; padding: 24px; display: grid; grid-template-columns: 190px minmax(190px, 1fr) auto; grid-template-rows: 1fr auto; align-items: center; gap: 20px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.army-unit-preview { padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: radial-gradient(circle, #f8fbef, #e3e9d8); }
.army-unit-name { min-width: 0; }
.army-unit-name h4 { margin: 0; font-family: Georgia, serif; font-size: 24px; font-weight: 600; }
.army-unit-name p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.match-pill { margin-top: 8px; display: inline-block; padding: 4px 7px; border-radius: 5px; color: #51603f; background: #e6ead9; font-size: 8px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.match-pill.unknown { color: #8b6529; background: #fff2d9; }
.army-unit-fields { display: grid; grid-template-columns: repeat(4, 72px); gap: 7px; }
.army-bases-field { display:flex; align-items:center; justify-content:center; padding:6px; border:1px solid var(--line); border-radius:6px; background:#fbfbf7; }
.army-bases-field input { width:18px; height:18px; }
.army-mini-field { display: grid; gap: 4px; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.army-mini-field input { min-width: 0; width: 100%; height: 34px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fbfbf7; font-size: 11px; font-weight: 750; }
.army-unit-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 7px; }
.army-unit-actions button { height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: #fbfbf7; font-size: 10px; font-weight: 800; }
.army-unit-actions button:last-child { color: white; border-color: #314a35; background: var(--forest); }
.army-unit-actions button:disabled { opacity: .4; cursor: not-allowed; }
.army-edit-shell { display: grid; gap: 12px; }
.army-edit-bar { padding: 12px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: #e3ead9; }
.army-edit-bar strong, .army-edit-bar small { display: block; }
.army-edit-bar small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.army-edit-bar button { height: 36px; padding: 0 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); font-size: 10px; font-weight: 800; }
.army-edit-bar button:last-child { color: white; border-color: #314a35; background: var(--forest); }
.army-edit-shell .workspace { grid-template-columns: minmax(300px, .75fr) minmax(460px, 1.25fr); }
.army-edit-shell .action-card { display: none; }

.storage-workspace { display: grid; grid-template-columns: minmax(320px, .72fr) minmax(540px, 1.28fr); gap: 20px; align-items: start; }
.storage-input-card { display: grid; gap: 14px; }
.storage-box-controls { padding-top: 14px; display: grid; gap: 10px; border-top: 1px solid var(--line); }
.storage-box-controls label, .storage-options label, .storage-unit label { display: grid; gap: 5px; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.storage-box-controls select, .storage-box-controls input, .storage-unit input, .storage-unit select { min-width: 0; width: 100%; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fbfbf7; font-size: 10px; font-weight: 750; }
.storage-options { display: grid; gap: 10px; }
.radio-panel { padding: 11px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfbf7; }
.radio-panel strong { flex: 1 0 100%; color: var(--ink); font-size: 11px; }
.radio-panel label { display: inline-flex !important; align-items: center; gap: 5px; text-transform: none !important; }
.radio-panel input { width: 16px; height: 16px; accent-color: var(--forest); }
.print-output-panel { margin-top: 16px; }
.storage-switch { margin: 0; padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: #fbfbf7; }
.storage-preview-panel { padding: 14px; display: grid; gap: 12px; border-bottom: 1px solid var(--line); background: radial-gradient(circle, #f8fbef, #e3e9d8); }
.storage-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.storage-preview-heading h3 { margin: 0; font-size: 14px; }
#storagePreview { width: 100%; min-height: 300px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.62); }
.storage-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.storage-stats div { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.75); }
.storage-stats span, .storage-stats strong { display: block; }
.storage-stats span { color: var(--muted); font-size: 8px; font-weight: 850; text-transform: uppercase; }
.storage-stats strong { margin-top: 4px; font-size: 11px; }
.storage-results { min-height: 220px; }
.storage-unit { padding: 12px; display: grid; grid-template-columns: minmax(180px, 1fr) repeat(5, 74px) minmax(86px, auto); align-items: end; gap: 8px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.storage-unit.needs-base { border-color: #b67a47; }
.storage-unit strong, .storage-unit small { display: block; }
.storage-unit small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.storage-unit button { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #fbfbf7; font-size: 9px; font-weight: 800; }
.storage-unit button:disabled { opacity: .42; cursor: not-allowed; }
.storage-unit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.storage-unit-actions button:last-child { grid-column: 1 / -1; }

.app-dialog { width: min(920px, calc(100% - 28px)); max-height: min(760px, calc(100vh - 28px)); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--panel); box-shadow: 0 35px 90px rgba(24, 43, 28, .3); }
.app-dialog::backdrop { background: rgba(20, 35, 24, .65); backdrop-filter: blur(4px); }
.dialog-heading { min-height: 76px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 23px; }
.dialog-heading .eyebrow { margin-bottom: 5px; }
.dialog-close { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: var(--white); font-size: 22px; }
.catalogue-layout { padding: 18px; display: grid; grid-template-columns: 1.3fr .7fr; gap: 18px; }
.catalogue-filters { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(170px, .9fr) minmax(200px, 1.2fr); gap: 7px; }
.catalogue-note { margin: 8px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.dialog-label { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 800; }
.dialog-input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: white; outline: 0; }
.catalogue-list { max-height: 440px; margin-top: 10px; display: grid; gap: 6px; overflow: auto; }
.catalogue-entry, .saved-armies-list article { padding: 10px; display: grid; grid-template-columns: 1fr 70px auto; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.catalogue-entry strong, .catalogue-entry small, .saved-armies-list strong, .saved-armies-list small { display: block; }
.catalogue-entry small, .saved-armies-list small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.catalogue-system { display: inline-block; margin-top: 5px; padding: 3px 6px; border-radius: 5px; color: #314a35; background: #e6ead9; font-size: 8px; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; }
.catalogue-entry input { min-width: 0; width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 6px; text-align: center; }
.catalogue-entry.single-catalogue-entry { grid-template-columns: 1fr auto; }
.catalogue-entry button, .saved-armies-list button { height: 34px; padding: 0 10px; border: 1px solid #78936a; border-radius: 6px; color: white; background: var(--forest); font-size: 9px; font-weight: 800; }
.custom-unit-form { align-self: start; padding: 15px; display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 10px; background: #e8eddf; }
.custom-unit-form h3 { margin: 0; font-size: 15px; }
.custom-unit-form label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.custom-unit-form input { min-width: 0; width: 100%; height: 38px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.dialog-field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.saved-armies-list { padding: 18px; display: grid; gap: 8px; }
.saved-armies-list article { grid-template-columns: 1fr auto auto; }
.saved-armies-list button:last-child { color: var(--muted); border-color: var(--line); background: white; }
.dialog-empty { padding: 30px; color: var(--muted); text-align: center; font-size: 11px; }
.account-dialog { width: min(760px, calc(100% - 28px)); }
.account-page-nav { padding: 12px 18px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.account-page-nav button { min-height: 40px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--white); font-size: 10px; font-weight: 800; }
.account-page-nav button.active { color: white; border-color: #314a35; background: var(--forest); }
.account-pages { padding: 18px; }
.account-page { width: 100%; }
.account-profile-form, .account-orders { padding: 18px; display: grid; align-content: start; gap: 12px; border: 1px solid var(--line); border-radius: 10px; background: #f5f6ef; }
.account-profile-form h3, .account-orders h3 { margin: 0; font-family: Georgia, serif; font-size: 20px; }
.account-profile-form p, .account-orders p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.account-profile-form label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.account-profile-form input:not([type="checkbox"]) { min-width: 0; width: 100%; height: 38px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.account-profile-form .account-consent { grid-template-columns: auto 1fr; align-items: center; justify-content: start; text-transform: none; }
#accountOrdersList { display: grid; gap: 8px; }
.account-order { padding: 12px; display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.account-order strong, .account-order small { display: block; }
.account-order small { color: var(--muted); font-size: 9px; }
.account-order b { font-size: 11px; }
.account-order button { grid-column: 2; min-height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--forest); background: var(--white); font-size: 9px; font-weight: 800; }
.account-order-detail { padding: 16px; display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.account-order-detail h4 { margin: 0; font-size: 17px; }
.order-detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.order-detail-grid div { padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: #f8f8f3; }
.order-detail-grid span, .order-detail-grid strong { display: block; }
.order-detail-grid span { color: var(--muted); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.order-detail-grid strong { margin-top: 4px; font-size: 10px; }
.order-status-track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.order-status-track span { padding: 8px 4px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #f5f5f0; text-align: center; font-size: 8px; font-weight: 800; text-transform: uppercase; }
.order-status-track span.done { color: white; border-color: #314a35; background: var(--forest); }
.order-status-note { padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: #f8f8f3; }
.order-detail-items, .order-events { display: grid; gap: 7px; }
.order-detail-items p, .order-events p { margin: 0; padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: #f8f8f3; }
.order-events h5 { margin: 2px 0; font-size: 11px; }
.order-events small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.order-events span { display: block; margin-top: 3px; color: var(--ink); font-size: 9px; }
.order-events .event-provider_message, .order-events .event-customer_message { background: #eef3e8; }
.order-events .event-decline { color: #803b2f; background: #fff0ed; }
.order-message-form, .order-rating-form { padding: 12px; display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8f8f3; }
.order-message-form label, .order-rating-form label { display: grid; gap: 5px; color: var(--muted); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.order-message-form textarea, .order-rating-form textarea, .order-rating-form select { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.order-rating-form h5, .order-rating-form p { margin: 0; }
.order-rating-form p { color: var(--muted); font-size: 9px; line-height: 1.5; }
.privacy-panel { margin-top: 24px; padding-top: 20px; display: grid; gap: 12px; border-top: 1px solid var(--line); }
.privacy-panel h3 { font-size: 17px; }
.button-danger { color: white; border-color: #7c3932; background: #98463d; }
.button-danger:hover { background: #813c35; }

.export-dialog { width: min(680px, calc(100% - 28px)); }
.export-choices { padding: 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.export-choice { min-height: 210px; padding: 22px; display: grid; place-items: center; align-content: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: white; text-align: center; }
.export-choice:hover { border-color: #78936a; background: #edf2e5; }
.export-choice strong { font-family: Georgia, serif; font-size: 19px; }
.export-choice small { max-width: 220px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.choice-icon, .print-order-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; color: #eff5e6; background: var(--forest); font-size: 12px; font-weight: 900; }
.ad-gate, .print-order { min-height: 380px; padding: 28px; display: grid; place-items: center; align-content: center; gap: 16px; text-align: center; }
.ad-gate-creative { width: min(500px, 100%); min-height: 180px; padding: 25px; display: grid; place-items: center; align-content: center; border: 1px dashed #8ca07e; border-radius: 12px; color: white; background: linear-gradient(130deg, #526f4e, #243b2a); }
.ad-gate-creative strong { font-family: Georgia, serif; font-size: 20px; }
.ad-gate-creative p { margin: 8px 0 0; color: #c9d8bd; font-size: 10px; }
.ad-gate > p { margin: 0; color: var(--muted); font-size: 11px; font-weight: 800; }
.ad-export-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.print-order h3 { margin: 0; font-family: Georgia, serif; font-size: 23px; }
.print-order > p { max-width: 480px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.print-order dl { width: min(460px, 100%); margin: 0; display: grid; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.print-order dl div { padding: 10px 12px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); background: white; }
.print-order dl div:last-child { border-bottom: 0; }
.print-order dt { color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.print-order dd { margin: 0; font-size: 10px; font-weight: 800; }
.print-order small { color: var(--muted); font-size: 9px; }
.action-card p, .action-card small, .button-large small { color: #34483a; }
.preview-stage { position:relative; touch-action:none; }
#trayPreview { cursor:grab; touch-action:none; }
#trayPreview:active { cursor:grabbing; }
.preview-angle-controls { position:absolute; top:10px; right:10px; z-index:3; display:flex; gap:4px; }
.preview-angle-controls button { min-height:30px; padding:0 9px; border:1px solid var(--line); border-radius:6px; color:var(--forest); background:rgba(255,255,255,.88); font-size:9px; font-weight:800; }
.provider-filters { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; text-align: left; }
.provider-filters label { display: grid; gap: 4px; color: var(--muted); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.provider-filters select { min-width: 0; width: 100%; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.provider-quotes { width: 100%; display: grid; gap: 8px; text-align: left; }
.provider-quote { padding: 11px; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.provider-quote.selected { border-color: var(--forest); box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 25%, transparent); }
.provider-colour { width: 28px; height: 28px; border: 1px solid rgba(0,0,0,.14); border-radius: 50%; }
.provider-main strong, .provider-main small, .provider-main em, .provider-price strong, .provider-price small { display: block; }
.provider-main small { margin-top: 3px; }
.provider-main em { margin-top: 4px; color: #8b6529; font-size: 8px; font-style: normal; font-weight: 800; }
.provider-price { text-align: right; }
.provider-price strong { font-size: 13px; }
.provider-quote details { grid-column: 2 / 4; color: var(--muted); font-size: 8px; }
.provider-quote details span { margin: 5px 10px 0 0; display: inline-block; }
.provider-quote button { height: 34px; padding: 0 10px; border: 1px solid var(--forest); border-radius: 7px; color: white; background: var(--forest); font-size: 9px; font-weight: 800; }
.provider-empty { padding: 24px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; font-size: 10px; }

.presets-section { padding: 70px 0 90px; }
.presets-heading { margin-bottom: 20px; display: flex; align-items: end; justify-content: space-between; }
.presets-heading h2 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.presets-heading > p { margin: 0; color: var(--muted); font-size: 11px; }
.presets-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.preset-card, .empty-presets { min-height: 130px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.55); }
.preset-card { display: flex; flex-direction: column; justify-content: space-between; transition: transform 150ms ease, background 150ms ease; }
.preset-card:hover { transform: translateY(-2px); background: white; }
.preset-card h3 { margin: 0; font-size: 14px; }
.preset-card p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.preset-actions { display: flex; gap: 7px; }
.preset-actions button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--muted); font-size: 10px; font-weight: 750; }
.empty-presets { grid-column: 1 / -1; display: grid; place-items: center; color: var(--muted); font-size: 12px; border-style: dashed; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; padding: 13px 17px; border-radius: 9px; color: white; background: var(--ink); box-shadow: 0 16px 35px rgba(0,0,0,.18); font-size: 12px; font-weight: 700; opacity: 0; transform: translateY(12px); pointer-events: none; transition: 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .top-actions { width: 100%; justify-content: flex-end; }
  .workspace { grid-template-columns: 1fr; }
  .controls-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .controls-panel .panel-heading { grid-column: 1 / -1; }
  .control-section { border-right: 1px solid var(--line); }
  .control-section:last-child { grid-column: 1 / -1; }
  .presets-grid { grid-template-columns: repeat(2, 1fr); }
  .army-workspace { grid-template-columns: 1fr; }
  .storage-workspace { grid-template-columns: 1fr; }
  .army-edit-shell .workspace { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  body:not(.authenticated) { overflow: auto; }
  .auth-gate { padding: 10px; place-items: start center; }
  .login-card { width: 100%; margin: auto 0; padding: 20px; gap: 12px; }
  .topbar { min-height: 0; padding: 10px 12px; display: grid; grid-template-columns: 1fr; gap: 9px; }
  .brand-intro { width: 100%; align-items: center; justify-content: space-between; gap: 8px; }
  .brand { min-width: 0; }
  .brand strong { font-size: 12px; }
  .top-tagline { min-width: 0; display: grid; gap: 1px; text-align: right; white-space: normal; }
  .top-tagline strong, .top-tagline em { font-size: 9px; }
  .top-actions { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .top-action-button { min-width: 0; min-height: 38px; padding: 0 7px; font-size: 10px; }
  .account-menu-wrap { min-width: 0; }
  .account-menu-button { width: 100%; justify-content: center; }
  .account-menu { width: min(220px, calc(100vw - 24px)); }
  main { width: min(100% - 24px, 600px); }
  .panel, .controls-panel { min-width: 0; }
  .ad-slot-top { margin: 14px auto; }
  .mode-tabs { margin-bottom: 14px; }
  .mode-tab { min-height: 62px; padding: 9px; grid-template-columns: 24px 1fr; column-gap: 7px; }
  .mode-tab > span { width: 23px; height: 23px; }
  .mode-tab strong { font-size: 11px; }
  .mode-tab small { font-size: 8px; }
  .ad-slot { min-height: 76px; padding: 12px; grid-template-columns: 1fr auto; gap: 8px; }
  .ad-label { display: none; }
  .ad-slot strong { font-size: 13px; }
  .ad-slot small { max-width: 220px; font-size: 8px; line-height: 1.4; }
  .ad-cta { font-size: 7px; }
  .workspace { min-width: 0; }
  .controls-panel { display: block; }
  .control-section { border-right: 0; }
  .choice-row { flex-wrap: wrap; }
  .number-field.compact { margin-left: 0; }
  .preview-stage { min-height: 330px; }
  .preview-panel .panel-heading { min-height: 90px; align-items: flex-start; flex-direction: column; justify-content: center; gap: 8px; }
  .preview-colour-control, .preview-colour-control select { width: 100%; max-width: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .action-card { align-items: stretch; flex-direction: column; }
  .action-buttons { display: grid; grid-template-columns: 1fr 1.4fr; }
  .button-large { min-width: 0; }
  .presets-grid { grid-template-columns: 1fr; }
  .presets-heading { align-items: start; flex-direction: column; gap: 10px; }
  .army-heading { align-items: start; flex-direction: column; gap: 12px; }
  .army-project-bar { grid-template-columns: 1fr 1fr; }
  .army-project-bar input { grid-column: 1 / -1; }
  .army-unit { grid-template-columns: 1fr; }
  .army-unit-preview { max-width: 230px; margin: 0 auto; }
  .army-unit-name h4 { font-size: 20px; }
  .army-unit-fields { grid-template-columns: repeat(4, 1fr); }
  .single-heading { align-items:start; flex-direction:column; }
  .army-unit-actions { grid-template-columns: repeat(3, 1fr); }
  .storage-stats { grid-template-columns: 1fr 1fr; }
  .storage-unit { grid-template-columns: 1fr 1fr; }
  .storage-unit > div { grid-column: 1 / -1; }
  .storage-unit > button, .storage-unit-actions { grid-column: 1 / -1; }
  .army-edit-bar { grid-template-columns: 1fr 1fr; }
  .army-edit-bar div { grid-column: 1 / -1; }
  .army-edit-shell .controls-panel { display: block; }
  .catalogue-layout, .export-choices { grid-template-columns: 1fr; }
  .catalogue-filters { grid-template-columns: 1fr; }
  .account-dialog, .app-dialog { width: calc(100% - 12px); max-height: calc(100dvh - 12px); border-radius: 10px; }
  .account-page-nav { grid-template-columns: 1fr; }
  .account-pages { padding: 10px; }
  .account-profile-form, .account-orders { padding: 13px; }
  .order-status-track { grid-template-columns: repeat(2, 1fr); }
  .order-detail-grid { grid-template-columns: 1fr; }
  .catalogue-entry { grid-template-columns: 1fr 60px auto; }
  .dialog-field-grid { grid-template-columns: 1fr; }
  .export-choice { min-height: 150px; }
  .provider-filters { grid-template-columns: 1fr; }
  .provider-quote { grid-template-columns: auto 1fr auto; }
  .provider-quote button { grid-column: 1 / -1; }
  .provider-quote details { grid-column: 2 / -1; }
}
