/* Core layout: page shell, header, sidebar nav, input grid, buttons. Loaded first. */
:root {
  --clr-border: #1b2030;
  --clr-text-dim: #6a7390;
  --clr-text: #c8cdd8;
  --clr-text-muted: #8b93a6;
  --clr-text-bright: #c8d2e6;
  --clr-text-soft: #8a93a8;
  --clr-accent: #a8c8ff;
  --clr-green: #5ecf80;
  --clr-amber: #e0b84a;
  --clr-red: #ef6b78;
  --clr-green-alt: #46d18a;
  --clr-label: #4a5470;
  --clr-caret: #5a6478;
  --clr-hint: #3a4460;
  --clr-stat-label: #8a94ac;
  --clr-focus: #3d5a8a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #0d0f14;
  color: var(--clr-text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

header {
  background: linear-gradient(180deg, #161a26, #11131b);
  border-bottom: 1px solid var(--clr-border);
  box-shadow: 0 1px 0 rgba(90, 180, 230, 0.10), 0 6px 18px -12px rgba(0, 0, 0, 0.8);
  padding: 0 24px;
  display: flex;
  user-select: none; -webkit-user-select: none;
  align-items: stretch;
  gap: 0;
  position: relative;
  z-index: 5;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px 14px 0;
  margin-right: 16px;
}
.header-logo {
  width: 32px;
  height: 32px;
  display: block;
  filter: drop-shadow(0 0 6px rgba(90, 169, 230, 0.35));
}
.header-brand h1 { line-height: 1; }
.header-brand span { align-self: flex-end; padding-bottom: 2px; }
header h1 { font-size: 18px; font-weight: 700; color: #d2e6ff; letter-spacing: 1.6px;
  text-transform: uppercase; text-shadow: 0 0 14px rgba(90, 180, 230, 0.30); }
header .header-brand span { color: var(--clr-text-dim); font-size: 12px; }
.header-actions { margin-left: auto; display: flex; align-items: center; padding: 0 4px; }
.header-session { font-size: 12px; color: var(--clr-text-dim); }
.header-logout { color: #4a88cc; text-decoration: none; }
.header-logout:hover { text-decoration: underline; }
.header-login-btn {
  background: #1a2a3a;
  border: 1px solid #2a4a6a;
  border-radius: 4px;
  color: #5a9fd4;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  transition: background 0.15s, border-color 0.15s;
}
.header-login-btn:hover { background: #1e3448; border-color: #3a6a9a; color: #7abfe8; }

/* ── Left sidebar navigation (foldable) ──────────────────────────────────────── */
.nav-toggle {
  background: none; border: none; color: var(--clr-text-soft); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 0 16px 0 0; align-self: center;
  transition: color 0.15s;
}
.nav-toggle:hover { color: var(--clr-accent); }

.app-layout { display: flex; align-items: stretch; }

/* Flat sidebar — blends into the page (no panel/border); identity comes from the glowing
   active accent, not a boxed frame. */
.sidebar {
  flex: 0 0 208px; width: 208px;
  background: #0d0f14;
  padding: 16px 10px; position: sticky; top: 0; align-self: flex-start;
  height: calc(100vh - 62px); overflow-y: auto;
  display: flex; flex-direction: column;
  transition: flex-basis 0.18s ease, width 0.18s ease, padding 0.18s ease;
  user-select: none; -webkit-user-select: none;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar .tab {
  position: relative;
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: none; border: none; border-radius: 8px;
  color: #7c879c; cursor: pointer; font-size: 13px; font-weight: 500; letter-spacing: 0.4px;
  padding: 10px 13px; text-align: left; transition: background 0.14s, color 0.14s;
}
.sidebar .tab:hover { background: rgba(90, 160, 230, 0.07); color: var(--clr-text-bright); }
.sidebar .tab.active {
  color: #d2e6ff;
  background: linear-gradient(90deg, rgba(74, 136, 204, 0.20), rgba(74, 136, 204, 0.02));
}
/* glowing capsuleer accent bar on the active item */
.sidebar .tab.active::before {
  content: ""; position: absolute; left: 1px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 2px; background: #5ab4e6; box-shadow: 0 0 9px rgba(90, 180, 230, 0.75);
}
.nav-ico { display: none; flex: 0 0 22px; text-align: center; font-weight: 700; font-size: 11px; letter-spacing: 0; }
.nav-lbl { white-space: nowrap; overflow: hidden; }

/* PI Planner nav group: a section header + two sub-items (Find Buildables / Refill a plan). */
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-hd { display: flex; align-items: center; gap: 11px; padding: 9px 13px 3px;
  color: var(--clr-label); font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.sidebar .tab-sub { padding-left: 30px; font-size: 12.5px; }
body.nav-collapsed .nav-group-hd { display: none; }
body.nav-collapsed .sidebar .tab-sub { padding-left: 0; }

/* collapsed = narrow icon rail */
body.nav-collapsed .sidebar { flex-basis: 56px; width: 56px; padding: 16px 8px; }
body.nav-collapsed .nav-lbl { display: none; }
body.nav-collapsed .nav-ico { display: block; }
body.nav-collapsed .sidebar .tab { justify-content: center; gap: 0; padding: 10px 0; }
body.nav-collapsed .sidebar .tab.active::before { top: 6px; bottom: 6px; }

main { flex: 1 1 auto; max-width: 1300px; margin: 0 auto; padding: 22px 24px 24px 14px; min-width: 0; }

/* ── Input grid ────────────────────────────────────────────────────────────── */
.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}
.input-col { display: flex; flex-direction: column; gap: 6px; }

label {
  color: #8a94b0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.label-hint { color: var(--clr-label); text-transform: none; letter-spacing: 0; font-size: 11px; }

textarea {
  width: 100%;
  height: 160px;
  background: #141720;
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  color: var(--clr-text);
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  padding: 12px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
textarea:focus { border-color: var(--clr-focus); }
textarea::placeholder { color: #3d4255; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}
button {
  background: linear-gradient(180deg, #234572, #1a3050);
  color: #cfe4ff;
  border: 1px solid #305a8a;
  border-radius: 6px;
  padding: 9px 22px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}
button:hover { background: linear-gradient(180deg, #2a5288, #1f3a60); border-color: #4a88cc;
  box-shadow: 0 0 12px -2px rgba(90, 180, 230, 0.35); }
button:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.factories-label {
  margin-left: 8px;
  font-size: 12px;
  color: var(--clr-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.factories-input {
  width: 64px;
  background: #141720;
  border: 1px solid var(--clr-border);
  border-radius: 5px;
  color: var(--clr-text);
  font-size: 13px;
  padding: 6px 8px;
  outline: none;
  text-align: center;
}
.factories-input:focus { border-color: var(--clr-focus); }

#status { font-size: 12px; color: var(--clr-text-dim); }
#status.error { color: #e06060; }

