:root {
  color-scheme: dark;
  --bg: #070b13;
  --surface: #101724;
  --surface-2: #151f30;
  --line: #26344a;
  --text: #edf4ff;
  --muted: #91a1b9;
  --blue: #4c8dff;
  --blue-2: #286ce5;
  --green: #52d6a0;
  --red: #ff737d;
  --amber: #f5bb62;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient { position: fixed; border-radius: 50%; filter: blur(100px); opacity: .22; pointer-events: none; }
.ambient-one { width: 460px; height: 460px; background: #205fd3; top: -180px; left: -120px; }
.ambient-two { width: 380px; height: 380px; background: #164f75; bottom: -180px; right: -80px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; position: relative; }
.login-card { width: min(440px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 22px; background: rgba(16,23,36,.94); box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(145deg,var(--blue),#284d9c); font-family: Georgia,serif; font-size: 28px; font-weight: 700; box-shadow: 0 10px 28px rgba(49,116,244,.32); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 22px; }
.eyebrow { color: #6ea0f8; letter-spacing: .14em; font-size: 11px; font-weight: 800; margin: 20px 0 8px; }
h1,h2,p { margin-top: 0; }
h1 { font-size: 32px; margin-bottom: 10px; }
h2 { font-size: 21px; margin-bottom: 0; }
.muted,.hint { color: var(--muted); line-height: 1.55; }
.hint { font-size: 12px; margin: 14px 0 0; }
.stack { display: grid; gap: 16px; margin-top: 28px; }
.stack.compact { margin-top: 20px; gap: 13px; }
label { display: grid; gap: 7px; color: #c4d0e1; font-size: 13px; font-weight: 650; }
input,select,textarea { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 9px; background: #0b111c; color: var(--text); padding: 9px 12px; outline: none; }
input:focus,select:focus,textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(76,141,255,.15); }
button { border: 0; border-radius: 9px; min-height: 40px; padding: 9px 15px; color: white; font-weight: 700; }
button:disabled { cursor:not-allowed; opacity:.5; }
.primary { background: linear-gradient(180deg,var(--blue),var(--blue-2)); box-shadow: 0 8px 20px rgba(41,107,222,.22); }
.primary:hover { filter: brightness(1.08); }
.secondary { background: var(--surface-2); border: 1px solid var(--line); color: #dce8f9; }
.small-button { min-height: 34px; padding: 6px 12px; }
.text-button { background: transparent; color: #8eb5fb; padding: 0; min-height: 30px; text-align: left; }
.danger-button,.edit-button { min-height: 30px; padding: 5px 9px; background: transparent; border: 1px solid #34445d; color: #a9b9cf; font-size: 12px; }
.danger-button { border-color: #61333b; color: #ff939b; }
.status { min-height: 20px; margin: 14px 0 0; color: #ff9299; font-size: 13px; }
.status.success { color: var(--green); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 238px; display: flex; flex-direction: column; padding: 24px 18px; background: rgba(10,15,25,.97); border-right: 1px solid #1d293a; z-index: 2; }
.logo-row { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.logo-row strong,.logo-row span { display: block; }
.logo-row span { color: var(--muted); font-size: 12px; margin-top: 2px; }
nav { display: grid; gap: 6px; }
.nav-item { text-align: left; background: transparent; color: #8f9db2; font-weight: 650; }
.nav-item:hover,.nav-item.active { background: #152137; color: #eff5ff; }
.nav-item.active { box-shadow: inset 3px 0 var(--blue); }
.nav-with-count { display:flex; align-items:center; justify-content:space-between; }
.nav-count { min-width:24px; padding:2px 7px; border-radius:999px; background:#1e3150; color:#a9c8ff; text-align:center; font-size:11px; }
.nav-group-label { padding:18px 12px 4px; color:#5f718a; font-size:10px; font-weight:850; letter-spacing:.12em; text-transform:uppercase; }
.nav-subitem { padding-left:24px; min-height:36px; font-size:13px; }
.sidebar-foot { margin-top: auto; display: grid; padding: 16px 10px 0; border-top: 1px solid var(--line); color: #d5dfec; font-size: 13px; }
.workspace { grid-column: 2; min-width: 0; padding: 34px 42px 50px; position: relative; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.topbar .eyebrow { margin-top: 0; }
.topbar h1 { margin-bottom: 0; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.environment,.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; border: 1px solid #30588e; background: #10294b; color: #8ebcff; font-size: 11px; font-weight: 850; letter-spacing: .08em; }
.environment.uat { border-color: #815f25; background: #352810; color: var(--amber); }
.global { margin: -10px 0 18px; }
.metrics { display: grid; grid-template-columns: repeat(5,minmax(130px,1fr)); gap: 16px; }
.metric,.panel { border: 1px solid var(--line); background: rgba(16,23,36,.9); border-radius: 15px; }
.metric { padding: 20px; }
.metric span,.metric small { display: block; color: var(--muted); }
.metric span { font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { display: block; font-size: 34px; margin: 12px 0 5px; }
.metric small { font-size: 12px; }
.panel { padding: 22px; }
.welcome-panel { margin-top: 18px; min-height: 190px; display: flex; align-items: center; justify-content: space-between; gap: 32px; overflow: hidden; position: relative; }
.welcome-panel:after { content:""; position:absolute; width:300px; height:300px; border-radius:50%; background:#1d5dc4; filter:blur(75px); opacity:.16; right:-80px; }
.welcome-panel > * { position: relative; z-index: 1; }
.welcome-panel .primary { flex: 0 0 auto; }
.split-grid { display: grid; grid-template-columns: minmax(280px,360px) minmax(0,1fr); gap: 18px; align-items: start; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.panel-heading .eyebrow { margin-top: 0; }
.table-panel { min-width: 0; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: #718299; text-align: left; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 10px; border-bottom: 1px solid var(--line); }
td { padding: 12px 10px; border-bottom: 1px solid #1c293a; color: #cbd6e5; vertical-align: middle; }
td strong,td small { display:block; }
td small { color: #74859c; margin-top: 3px; }
.tag { display:inline-block; padding:4px 7px; border-radius:6px; background:#182a44; color:#8db8ff; font-size:10px; font-weight:800; text-transform:uppercase; }
.tag.seed { background:#143529; color:#72deb1; }
.tag.admin { background:#3a2a13; color:#f5c26d; }
.avatar-portrait { width:40px; height:40px; display:block; border:1px solid #31588e; border-radius:50%; background-image:url("avatar_sheet.png"); background-repeat:no-repeat; background-size:240px 160px; box-shadow:0 3px 12px rgba(0,0,0,.35); }
.actions { display:flex; gap:6px; justify-content:flex-end; }
.empty-row { text-align:center; color:var(--muted); padding:28px 10px; }
.region-grid { display:grid; grid-template-columns:minmax(360px,.85fr) minmax(500px,1.15fr); gap:18px; align-items:start; }
.province-map-panel { padding:26px; }
.province-map-panel .city-map-label { display:none; }
.subcity-map-label { fill:#b8d7ff; font-size:11px; font-weight:700; paint-order:stroke; stroke:#08111d; stroke-width:3px; stroke-linejoin:round; pointer-events:none; }
.map-navigation label:has(#provinceShowNames) { display:none; }
.province-toolbar { display:flex; align-items:end; justify-content:space-between; gap:18px; margin-bottom:18px; }
.province-selector { width:min(460px,100%); font-size:14px; }
.province-selector select { min-height:48px; font-size:15px; }
.province-import-replace { margin-top:-6px; }
.province-map { min-height:clamp(360px,32vw,500px); display:grid; place-items:center; position:relative; overflow:hidden; border:1px solid #21334b; border-radius:12px; background:radial-gradient(circle at 50% 42%,#12283a,#08111d 72%); }
.province-map svg { width:100%; height:clamp(360px,32vw,500px); }
.details-modal { width:min(920px,calc(100vw - 32px)); max-height:calc(100vh - 32px); padding:0; border:0; border-radius:16px; background:transparent; color:var(--text); overflow:auto; box-shadow:0 30px 90px rgba(0,0,0,.65); }
.details-modal::backdrop { background:rgba(2,6,12,.78); backdrop-filter:blur(4px); }
.details-modal .province-details { margin:0; }
.province-shape { fill:#163c4c; stroke:none; fill-rule:evenodd; }
.province-outline { fill:none; stroke:#e5bd68; stroke-width:2.4; vector-effect:non-scaling-stroke; pointer-events:none; }
.city-area-shape { stroke:#78d9f2; stroke-width:1.1; opacity:.72; vector-effect:non-scaling-stroke; fill-rule:evenodd; pointer-events:all; cursor:pointer; }
.city-area-shape.selected { stroke:#ffd166; stroke-width:3; opacity:1; filter:drop-shadow(0 0 5px #ffd166); }
.area-color-0 { fill:#205f70; }.area-color-1 { fill:#315d86; }.area-color-2 { fill:#4b557d; }.area-color-3 { fill:#265f58; }
.area-color-4 { fill:#65536e; }.area-color-5 { fill:#536843; }.area-color-6 { fill:#73544a; }.area-color-7 { fill:#3c6178; }
.city-area-label { fill:#eaf7fb; font-size:10px; font-weight:700; text-anchor:middle; dominant-baseline:middle; paint-order:stroke; stroke:#071018; stroke-width:3px; stroke-linejoin:round; pointer-events:none; }
.map-city { fill:#f4f7fb; stroke:#071018; stroke-width:1.5; vector-effect:non-scaling-stroke; }
.map-city.spawn { fill:#56d69e; }
.map-subcity { fill:#78b7ff; stroke:#071018; stroke-width:1; vector-effect:non-scaling-stroke; }
.legend-subcity { background:#78b7ff; }
.city-area-map { min-height:clamp(320px,28vw,440px); margin:2px 0 0; }
.city-area-map svg { height:clamp(320px,28vw,440px); }
.province-map .map-city { cursor:grab; stroke:#071018; stroke-width:2.5; filter:drop-shadow(0 2px 3px rgba(0,0,0,.65)); touch-action:none; }
.province-map .map-city:hover,.province-map .map-city.dragging { stroke:#fff2bf; stroke-width:3.5; }
.province-map .map-city.dragging { cursor:grabbing; }
.map-layer-hidden { display:none; }
.map-navigation { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-bottom:12px; }
.map-navigation output { min-width:48px; text-align:center; font-size:13px; }
.map-navigation label { display:flex; align-items:center; gap:7px; }
.map-navigation input { width:auto; min-height:auto; }
.map-navigation .hint { margin:0; }
#provinceMapSvg { touch-action:none; cursor:grab; }
#provinceMapSvg.panning { cursor:grabbing; }
#provinceMapSvg.hide-map-names .city-map-label,#provinceMapSvg.hide-map-names .city-area-label { display:none; }
.city-area-map .map-subcity { cursor:grab; touch-action:none; stroke-width:2; }
.city-area-map .map-subcity:hover,.city-area-map .map-subcity.dragging { stroke:#fff2bf; stroke-width:3; }
.city-area-map .map-subcity.dragging { cursor:grabbing; }
.city-map-label { fill:#fff; font-size:11px; font-weight:800; text-anchor:middle; paint-order:stroke; stroke:#071018; stroke-width:3px; stroke-linejoin:round; pointer-events:none; }
.city-area-map-footer,.map-footer { display:flex; align-items:start; justify-content:space-between; gap:20px; margin-bottom:18px; }
.city-area-map-footer .map-legend { margin-top:12px; }
.city-area-map-footer .hint,.map-footer .hint { margin-top:10px; text-align:right; }
.map-terrain { stroke:#071018; stroke-width:1.5; vector-effect:non-scaling-stroke; }
.map-terrain.mountain { fill:#b5c1cf; }.map-terrain.volcano { fill:#ff765f; }.map-terrain.river { fill:#4ea9ff; }
.map-empty { position:absolute; color:var(--muted); max-width:260px; text-align:center; line-height:1.5; }
.map-legend { display:flex; flex-wrap:wrap; gap:16px; margin-top:13px; color:var(--muted); font-size:12px; }
.map-legend button { display:flex; align-items:center; gap:6px; min-height:28px; padding:3px 5px; border-radius:6px; background:transparent; color:var(--muted); font-size:12px; font-weight:650; }
.map-legend button:hover { color:var(--text); background:#172236; }
.map-legend button[aria-pressed="false"] { opacity:.42; text-decoration:line-through; }
.map-legend i { width:11px; height:11px; border-radius:3px; display:inline-block; }
.legend-province { background:#163c4c; border:1px solid #e5bd68; }.legend-area { background:#315d86; border:1px solid #49c9ee; }.legend-city { background:#f4f7fb; border-radius:50%!important; }.legend-terrain { background:#ff765f; transform:rotate(45deg); }
.inline-form { display:grid; grid-template-columns:100px minmax(150px,1fr) auto; gap:10px; align-items:end; padding:14px; margin-bottom:16px; border-radius:11px; background:#0b111c; border:1px solid #1d2a3b; }
.inline-form.city-form { grid-template-columns:minmax(130px,1fr) 100px minmax(140px,1fr) auto; }
.inline-form.province-form { grid-template-columns:repeat(3,minmax(120px,1fr)); }
.inline-form.terrain-form { grid-template-columns:minmax(140px,1fr) 130px minmax(180px,1fr) 130px 130px auto; }
.inline-form .wide-field { grid-column:1 / -1; }
.inline-form .check-label { display:flex; align-items:center; gap:8px; }
.inline-form .check-label input { width:auto; min-height:auto; }
.import-replace { display:flex; align-items:center; gap:8px; margin:-5px 0 15px; color:var(--muted); font-size:12px; }
.import-replace input { width:auto; min-height:auto; }
.source-tools { display:grid; gap:8px; margin:0 0 16px; padding:12px; border:1px solid var(--line); border-radius:10px; background:#0b111c; }
.source-tools > div:first-child { display:flex; justify-content:space-between; gap:12px; }
.source-tools a { color:#7fb0ff; }
.source-tools .check-label { display:flex; align-items:center; gap:8px; }
.source-tools .check-label input { width:auto; min-height:auto; }
.inline-form input,.inline-form select { min-height:38px; }
.region-table { max-height:500px; }
.city-hierarchy { min-width:190px; }
.city-hierarchy > div + div { margin-top:9px; padding-top:9px; border-top:1px solid #26344a; }
.city-hierarchy strong { color:#edf4ff; }
.city-hierarchy small { line-height:1.45; }
.filter-label { max-width:220px; margin: 0 0 12px auto; }
.section-toolbar { display:grid; grid-template-columns:minmax(180px,260px) minmax(360px,1fr); gap:16px; align-items:start; margin-bottom:16px; }
.city-area-selector-toolbar { grid-template-columns:repeat(2,minmax(180px,320px)); align-items:end; }
.section-toolbar .source-tools { margin:0; }
.terrain-hint { margin:-5px 0 14px; }
@media (max-width: 1050px) {
  .metrics { grid-template-columns:repeat(2,1fr); }
  .split-grid,.region-grid { grid-template-columns:1fr; }
  .inline-form.terrain-form { grid-template-columns:repeat(2,1fr); }
}
@media (max-width: 720px) {
  .app-shell { display:block; }
  .sidebar { position:static; width:auto; min-height:auto; }
  nav { grid-template-columns:repeat(2,1fr); }
  .nav-group-label { grid-column:1 / -1; }
  .sidebar-foot { display:none; }
  .workspace { padding:24px 16px 40px; }
  .topbar { align-items:flex-start; flex-direction:column; }
  .metrics { grid-template-columns:1fr 1fr; }
  .city-area-map-footer,.map-footer { flex-direction:column; gap:0; }
  .city-area-map-footer .hint,.map-footer .hint { text-align:left; }
  .inline-form,.inline-form.city-form,.inline-form.terrain-form,.section-toolbar { grid-template-columns:1fr; }
  .province-map-panel { padding:18px; }
  .province-toolbar { align-items:stretch; flex-direction:column; }
  .province-map,.province-map svg { min-height:380px; height:380px; }
  .welcome-panel { align-items:flex-start; flex-direction:column; }
}
.city-area-selector-toolbar label:first-child { display: none; }
#newProvinceButton { display: none; }

/* The Province page contains two independent editing maps. Keep them visible
   together so the broad province and detailed city-area coordinates can be
   compared while dragging. */
@media (min-width: 1100px) {
  .workspace:has(#provincesView:not(.hidden)) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 18px;
  }
  .workspace:has(#provincesView:not(.hidden)) > .topbar,
  .workspace:has(#provincesView:not(.hidden)) > .status.global {
    grid-column: 1 / -1;
  }
  .workspace:has(#provincesView:not(.hidden)) > #provincesView,
  .workspace:has(#provincesView:not(.hidden)) > #cityAreasView {
    display: block !important;
    min-width: 0;
  }
}
