:root {
  color-scheme: light;
  --navy: #123f70;
  --navy-2: #0b2d51;
  --blue: #2f6fa7;
  --blue-soft: #eaf3fa;
  --gold: #c7a13a;
  --gold-dark: #8d6c16;
  --gold-soft: #fff6d8;
  --ink: #172432;
  --muted: #607184;
  --line: #cbd6df;
  --panel: #ffffff;
  --page: #f2f6f9;
  --danger: #a33b35;
  --success: #23714f;
  --shadow: 0 1px 3px rgba(12, 38, 62, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--page); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, select, input, textarea { border-radius: 5px; }
a { color: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
}

.topbar {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  color: #fff;
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
}

.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 210px; text-decoration: none; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid var(--gold);
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 700;
}
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 18px; }
.brand small { color: #dbe8f3; font-size: 11px; }

.profile-controls { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.profile-controls label { display: flex; align-items: center; gap: 6px; color: #dbe8f3; font-size: 12px; }
.profile-controls select { min-width: 104px; padding: 7px 28px 7px 9px; color: var(--ink); background: #fff; border: 1px solid #b9cad8; font-size: 13px; }
.offline-badge { padding: 5px 8px; color: var(--gold-soft); border: 1px solid var(--gold); font-size: 11px; font-weight: 700; text-transform: uppercase; }

.icon-button { width: 36px; height: 36px; border: 1px solid transparent; background: transparent; color: inherit; cursor: pointer; }
.menu-button { display: none; font-size: 21px; }

.sidebar {
  grid-column: 1;
  grid-row: 2;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 16px 12px;
  color: #dbe8f3;
  background: var(--navy-2);
  border-right: 1px solid #163e62;
}
.nav-group { margin: 0 0 17px; }
.nav-group-title { margin: 0 9px 6px; color: #91aac0; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.nav-link { width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 9px; color: inherit; background: transparent; border: 0; text-align: left; cursor: pointer; }
.nav-link:hover { background: #164b78; }
.nav-link.active { color: #fff; background: #1d5888; box-shadow: inset 3px 0 var(--gold); }
.nav-icon { width: 21px; color: var(--gold); text-align: center; font-weight: 800; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.sidebar-footer { margin-top: 14px; padding: 12px 9px 2px; display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid #32526d; color: #91aac0; font-size: 10px; }
.sidebar-footer a { color: #d8be71; }

.workspace { grid-column: 2; grid-row: 2; min-width: 0; padding: 25px clamp(18px, 3vw, 42px) 48px; }
.page-header { max-width: 1180px; margin: 0 auto 18px; display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.page-header h1 { margin: 0 0 3px; color: var(--navy-2); font-family: Georgia, serif; font-size: 29px; }
.page-header p { margin: 0; max-width: 760px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.confidence { flex: 0 0 auto; padding: 5px 8px; color: var(--gold-dark); background: var(--gold-soft); border: 1px solid #ddc778; font-size: 11px; font-weight: 700; }

.content { max-width: 1180px; margin: 0 auto; }
.tool-layout { display: grid; grid-template-columns: minmax(280px, 390px) minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--blue); box-shadow: var(--shadow); }
.panel.gold { border-top-color: var(--gold); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 46px; padding: 10px 14px; border-bottom: 1px solid #dce4ea; }
.panel-header h2 { margin: 0; color: var(--navy); font-size: 14px; }
.panel-body { padding: 15px; }
.panel-note { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.field-grid.one { grid-template-columns: 1fr; }
.field-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; color: var(--muted); font-size: 11px; font-weight: 700; }
.field.span-2 { grid-column: span 2; }
.field input, .field select, .field textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #aebdca;
  outline: none;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 2px #d9eaf7; }
.field small { color: #7b8896; font-weight: 500; }
.check-field { flex-direction: row; align-items: center; padding-top: 19px; }
.check-field input { width: auto; }

.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.button { min-height: 36px; padding: 8px 13px; border: 1px solid var(--navy); background: var(--navy); color: #fff; font-weight: 700; cursor: pointer; }
.button:hover { background: #195487; }
.button.secondary { color: var(--navy); background: #fff; }
.button.gold { color: #2a220d; background: var(--gold); border-color: var(--gold-dark); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metric { min-height: 82px; padding: 12px; background: #f7fafc; border: 1px solid #d8e1e8; border-left: 3px solid var(--gold); }
.metric span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.metric strong { display: block; margin-top: 6px; color: var(--navy-2); font-size: 20px; overflow-wrap: anywhere; }
.metric small { display: block; margin-top: 3px; color: #738293; font-size: 10px; }
.resource-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.resource { padding: 9px 7px; text-align: center; background: var(--blue-soft); border: 1px solid #c4dbea; }
.resource span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.resource strong { display: block; margin-top: 3px; color: var(--navy); font-size: 15px; }

.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 12px; }
th, td { padding: 8px 9px; border-bottom: 1px solid #dce4ea; text-align: right; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; color: #fff; background: var(--navy); font-size: 10px; text-transform: uppercase; }
th:first-child, td:first-child { text-align: left; }
tbody tr:nth-child(even) { background: #f6f9fb; }
tbody tr:hover { background: var(--gold-soft); }
.status-official { color: var(--success); font-weight: 700; }
.status-inferred, .status-reconstructed { color: var(--gold-dark); font-weight: 700; }
.status-estimate { color: var(--danger); font-weight: 700; }

.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dashboard-card { min-height: 150px; padding: 15px; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--gold); box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.dashboard-card:hover { border-color: var(--blue); transform: translateY(-1px); }
.dashboard-card .card-icon { color: var(--blue); font-size: 20px; font-weight: 800; }
.dashboard-card h2 { margin: 15px 0 5px; color: var(--navy-2); font-size: 15px; }
.dashboard-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.dashboard-card span:last-child { margin-top: auto; padding-top: 12px; color: var(--gold-dark); font-size: 11px; font-weight: 800; }

.callout { margin-bottom: 14px; padding: 12px 14px; color: #41350f; background: var(--gold-soft); border: 1px solid #dec77a; border-left: 4px solid var(--gold); font-size: 12px; line-height: 1.45; }
.callout.info { color: var(--navy-2); background: var(--blue-soft); border-color: #b9d7ea; border-left-color: var(--blue); }
.empty { padding: 32px; color: var(--muted); text-align: center; }
.error { color: var(--danger); font-weight: 700; }
.scrim { display: none; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 226px minmax(0, 1fr); }
  .tool-layout { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .topbar { padding: 0 12px; gap: 10px; }
  .menu-button { display: inline-grid; place-items: center; }
  .brand { min-width: 0; }
  .brand small { display: none; }
  .profile-controls { margin-left: auto; }
  .profile-controls select { min-width: 74px; }
  .offline-badge { display: none; }
  .sidebar { position: fixed; z-index: 40; top: 64px; left: 0; width: min(82vw, 278px); height: calc(100vh - 64px); transform: translateX(-105%); transition: transform .18s ease; box-shadow: 8px 0 24px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .scrim { display: block; position: fixed; z-index: 30; inset: 64px 0 0; background: rgba(3, 20, 34, .5); }
  .workspace { padding: 20px 13px 38px; }
  .page-header { align-items: start; }
  .page-header h1 { font-size: 24px; }
  .confidence { display: none; }
  .dashboard-grid, .metric-grid { grid-template-columns: 1fr; }
  .field-grid, .field-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .resource-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
  .brand strong { font-size: 16px; }
  .brand-mark { width: 30px; height: 30px; }
  .profile-controls { gap: 4px; }
  .profile-field > span { display: none; }
  .field-grid, .field-grid.four { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: span 1; }
}

@media print {
  .topbar, .sidebar, .button-row { display: none !important; }
  .app-shell { display: block; }
  .workspace { padding: 0; }
  .panel { box-shadow: none; }
}

/* Travlaw classic dark theme */
:root {
  color-scheme: dark;
  --navy: #07172c;
  --navy-2: #061326;
  --blue: #6f93c6;
  --blue-soft: #17243e;
  --gold: #d6a91d;
  --gold-dark: #f0c83c;
  --gold-soft: #292815;
  --ink: #eef4ff;
  --muted: #9bb1d2;
  --line: #2a3b58;
  --panel: #17223a;
  --page: #101923;
  --danger: #f07e76;
  --success: #73cba3;
  --shadow: 0 2px 8px rgba(0, 0, 0, .22);
}
html, body { background: var(--page); }
.topbar { background: #07172c; border-bottom-color: #d6a91d; }
.sidebar { background: #061326; border-right-color: #d6a91d; }
.nav-group-title { color: #d6a91d; }
.nav-link:hover { background: #142541; }
.nav-link.active { color: #07172c; background: #d6a91d; box-shadow: none; font-weight: 800; }
.nav-link.active .nav-icon { color: #07172c; }
.sidebar-footer { border-color: #283b59; }
.workspace { background: #101923; }
.page-header h1, .panel-header h2, .dashboard-card h2, .metric strong { color: #f0c83c; }
.page-header p, .panel-note, .field, .dashboard-card p, .metric small { color: #9bb1d2; }
.confidence { color: #f0c83c; background: #222718; border-color: #665923; }
.panel { background: #17223a; border-color: #2a3b58; border-top-color: #6f93c6; }
.panel.gold { border-top-color: #d6a91d; }
.panel-header { border-bottom-color: #2a3b58; }
.field input, .field select, .field textarea { color: #eef4ff; background: #0d1a2d; border-color: #425571; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #d6a91d; box-shadow: 0 0 0 2px rgba(214,169,29,.16); }
.button { background: #d6a91d; color: #07172c; border-color: #d6a91d; }
.button:hover { background: #efc63c; }
.button.secondary { color: #f0c83c; background: #101b30; border-color: #6e5c22; }
.metric { background: #111d32; border-color: #2a3b58; border-left-color: #d6a91d; }
.resource { background: #10233b; border-color: #294b6c; }
.resource strong { color: #f0c83c; }
.table-wrap { border-color: #2a3b58; }
table { background: #111d32; }
th { background: #07172c; color: #f0c83c; }
th, td { border-color: #2a3b58; }
tbody tr:nth-child(even) { background: #162139; }
tbody tr:hover { background: #292815; }
.panel-body h3 { margin: 18px 0 7px; color: #d8e5f7; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.table-input, .table-select { min-width: 74px; max-width: 220px; padding: 7px 8px; color: #eef4ff; background: #0d1a2d; border: 1px solid #425571; outline: none; }
.table-select { min-width: 170px; }
.table-input:focus, .table-select:focus { border-color: #d6a91d; box-shadow: 0 0 0 2px rgba(214,169,29,.16); }
.row-remove { width: 30px; height: 30px; color: #f0c83c; background: #101b30; border: 1px solid #6e5c22; cursor: pointer; font-weight: 800; }
.row-remove:hover { color: #07172c; background: #d6a91d; }
.editor-table table { min-width: 650px; }
.callout { color: #eadfb9; background: #272716; border-color: #655a25; }
.callout.info { color: #c9daf5; background: #14243d; border-color: #315276; }
.dashboard-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.dashboard-card { min-height: 166px; background: #17223a; border-color: #2a3b58; border-top-color: #d6a91d; }
.dashboard-card:hover { border-color: #d6a91d; transform: translateY(-2px); }
.dashboard-card .card-icon { width: 32px; height: 32px; display: grid; place-items: center; color: #07172c; background: #d6a91d; border-radius: 5px; }
.dashboard-card span:last-child { color: #f0c83c; }
.card-top { display: flex; align-items: center; justify-content: space-between; }
.card-top small { color: #748caf; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.portal-hero { min-height: 330px; display: flex; align-items: center; padding: 34px 38px; background: #07172c url("assets/command-map.png") center / cover no-repeat; border: 1px solid #625522; box-shadow: var(--shadow); }
.hero-copy { max-width: 490px; }
.eyebrow, .section-heading span, .portal-status span { color: #d6a91d; font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.hero-copy h2 { margin: 10px 0 12px; color: #f0c83c; font-family: Georgia, serif; font-size: 42px; line-height: 1.02; }
.hero-copy p { margin: 0; color: #d7e3f7; font-size: 14px; line-height: 1.55; }
.hero-actions { display: flex; gap: 9px; margin-top: 22px; }
.portal-status { display: grid; grid-template-columns: repeat(4, 1fr); margin: 14px 0 28px; background: #17223a; border: 1px solid #2a3b58; }
.portal-status div { padding: 13px 16px; border-right: 1px solid #2a3b58; }
.portal-status div:last-child { border-right: 0; }
.portal-status span, .portal-status strong { display: block; }
.portal-status strong { margin-top: 3px; color: #eef4ff; font-size: 14px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 14px; }
.section-heading h2 { margin: 4px 0 0; color: #f0c83c; font-family: Georgia, serif; font-size: 24px; }
.section-heading p { max-width: 510px; margin: 0; color: #9bb1d2; font-size: 12px; line-height: 1.5; }

/* T4-inspired workbench controls and supplied game art */
.profile-controls { gap: 8px; }
.profile-portrait {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #f0c83c;
  background: #101d32;
  border: 1px solid #d6a91d;
  border-radius: 4px;
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 800;
}
.profile-portrait img { width: 40px; height: auto; display: block; align-self: start; }
.profile-field { padding: 3px 4px 3px 8px; background: #0b1a2f; border: 1px solid #304663; border-radius: 5px; }
.profile-field > span { color: #9bb1d2; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.profile-controls select,
.profile-controls select:hover {
  min-width: 108px;
  height: 34px;
  padding: 5px 28px 5px 9px;
  color: #fff4bf;
  background-color: #0d1a2d;
  border: 1px solid #d6a91d;
  border-radius: 4px;
  color-scheme: dark;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}
.profile-controls select option { color: #eef4ff; background: #0d1a2d; font-size: 13px; }
.profile-controls select option:checked { color: #07172c; background: #d6a91d; }
.profile-controls select:focus-visible { outline: 2px solid #f0c83c; outline-offset: 2px; }
#globalTribe { min-width: 112px; }
#globalSpeed { min-width: 86px; }

.nav-link { min-height: 48px; padding: 5px 8px; border: 1px solid transparent; border-radius: 4px; }
.nav-link:hover { border-color: #2b4160; }
.nav-icon {
  width: 40px;
  height: 38px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0d1a2d;
  border: 1px solid #2b4160;
  border-radius: 4px;
}
.nav-icon img { width: 38px; height: 36px; object-fit: contain; display: block; }
.nav-link.active .nav-icon { background: #10213b; border-color: #07172c; }
.nav-label { font-size: 12px; font-weight: 650; }

.page-heading { min-width: 0; display: flex; align-items: center; gap: 13px; }
.page-emblem {
  width: 58px;
  height: 54px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0d1a2d;
  border: 1px solid #3a4c68;
  border-bottom: 2px solid #d6a91d;
  border-radius: 5px;
}
.page-emblem img { width: 54px; height: 50px; object-fit: contain; display: block; }

.resource { min-height: 63px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.resource .resource-name { display: flex; align-items: center; justify-content: center; gap: 5px; color: #9bb1d2; font-size: 9px; text-transform: uppercase; }
.resource .resource-name span { display: inline; color: inherit; font-size: inherit; text-transform: inherit; }
.resource-icon { width: 16px; height: 16px; flex: 0 0 16px; display: block; image-rendering: auto; }

.unit-art {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  color: #f0c83c;
  background-color: #0b182b;
  background-image: var(--unit-sheet);
  background-position: var(--unit-offset) 0;
  background-repeat: no-repeat;
  border-radius: 3px;
  box-shadow: 0 0 0 1px #3a4c68;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  vertical-align: middle;
}
.unit-art--small { width: 24px; height: 24px; background-size: 300px 24px; }
.unit-art--medium { width: 32px; height: 32px; background-size: 400px 32px; }
.unit-art--large { width: 40px; height: 40px; background-size: 500px 40px; }
.unit-art--fallback { background-image: none; border: 1px dashed #6e5c22; box-shadow: none; }
.unit-picker { min-width: 0; display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 8px; }
.unit-picker-art { min-height: 38px; display: grid; place-items: center; background: #101d32; border: 1px solid #2d4260; border-radius: 4px; }
.unit-picker select { width: 100%; min-width: 0; }
.unit-summary { min-width: 0; display: flex; align-items: center; gap: 11px; margin-bottom: 12px; padding: 9px 10px; background: #0f1c30; border: 1px solid #2a3b58; border-left: 3px solid #d6a91d; }
.unit-summary strong, .unit-summary span { display: block; }
.unit-summary strong { color: #f0c83c; font-size: 13px; }
.unit-summary span { margin-top: 2px; color: #9bb1d2; font-size: 10px; }
.unit-summary .unit-art { display: inline-grid; margin: 0; }
.unit-summary-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.unit-art-cell { width: 42px; text-align: center !important; }

.dashboard-card { position: relative; overflow: hidden; }
.dashboard-card::after { content: ""; position: absolute; right: -18px; bottom: -22px; width: 82px; height: 82px; border: 1px solid rgba(111, 147, 198, .11); transform: rotate(18deg); pointer-events: none; }
.dashboard-card .card-icon {
  width: 58px;
  height: 54px;
  overflow: hidden;
  background: #0d1a2d;
  border: 1px solid #3a4c68;
  border-bottom-color: #d6a91d;
  border-radius: 5px;
}
.dashboard-card .card-icon img { width: 54px; height: 50px; object-fit: contain; display: block; }
.dashboard-card h2 { margin-top: 12px; }
@media (max-width: 1180px) { .dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 880px) { .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .portal-hero { background-position: 58% center; } }
@media (max-width: 720px) { .portal-hero { min-height: 390px; padding: 26px 22px; background-position: 52% center; } .hero-copy h2 { font-size: 34px; } .portal-status { grid-template-columns: repeat(2, 1fr); } .portal-status div:nth-child(2) { border-right: 0; } .portal-status div:nth-child(-n+2) { border-bottom: 1px solid #2a3b58; } .section-heading { display: block; } .section-heading p { margin-top: 8px; } .profile-controls select { min-width: 76px; } #globalTribe { min-width: 94px; } #globalSpeed { min-width: 76px; } }
@media (max-width: 480px) { .dashboard-grid { grid-template-columns: 1fr; } .hero-actions { align-items: stretch; flex-direction: column; } .portal-hero { background-position: 45% center; } .brand > span:last-child, .profile-portrait { display: none; } .profile-field { padding-left: 4px; } .profile-controls select { height: 32px; padding-left: 6px; padding-right: 20px; } .page-emblem { width: 50px; height: 48px; flex-basis: 50px; } .page-emblem img { width: 47px; height: 44px; } .unit-summary-row { grid-template-columns: 1fr; } }
