:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fb;
  --panel: #ffffff;
  --header: #dce8f6;
  --ink: #1f2933;
  --ink-2: #52606d;
  --ink-3: #8a96a3;
  --line: #d7dee8;
  --brand: #3d6fb6;
  --brand-dark: #2b568f;
  --tile-line: #7d9fd0;
  --icon: #8a94a3;
  --good: #1f9d55;
  --good-bg: #e3f6ea;
  --bad: #d64545;
  --bad-bg: #fde8e8;
  --mr: #d98a00;
  --mr-bg: #fff3d6;
  --down: #c2410c;
  --down-bg: #ffedd5;
  --out: #8a96a3;
  --out-bg: #e6eaf0;
  --live: #1aa0e6;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }

/* ---- header (TrakIt look) ---- */
.hub-header {
  display: flex; align-items: center; gap: 16px;
  background: var(--header); padding: 6px 16px; min-height: 52px;
}
.hub-logo {
  font-weight: 800; font-size: 26px; letter-spacing: -.5px; color: #1b2430;
  text-decoration: none; line-height: 1; white-space: nowrap;
}
.hub-logo .bang { color: #e0393e; }
.hub-logo small { font-size: 13px; font-weight: 600; color: var(--brand); margin-left: 6px; letter-spacing: 0; }
.hub-title { font-size: 18px; font-weight: 600; color: var(--ink); }
.hub-spacer { flex: 1; }
.hub-badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .4px;
}
.hub-badge.mock { background: #fff3d6; color: #8a5a00; }
.hub-badge.dry { background: #e8eefc; color: #2b568f; }
.hub-badge.livewrite { background: #fde8e8; color: #a32020; }
.hub-user {
  display: flex; align-items: stretch; border-radius: 4px; overflow: hidden;
  background: var(--brand-dark); color: #fff; font-weight: 600; font-size: 14px;
}
.hub-user span { padding: 7px 12px; display: flex; align-items: center; gap: 6px; }
.hub-user button {
  border: 0; background: #234a7c; color: #fff; padding: 0 12px; cursor: pointer;
}
.hub-user button:hover { background: #1b3b63; }
.hub-plant { font: inherit; font-size: 13px; font-weight: 600; color: var(--brand-dark); background: #fff; border: 1px solid #b9cce4; border-radius: 6px; padding: 4px 6px; }
.hub-home { display: flex; align-items: center; color: var(--brand-dark); text-decoration: none; font-weight: 600; font-size: 14px; gap: 4px; }

/* ---- generic ---- */
.wrap { padding: 20px 24px 40px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 9px 16px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink);
  min-height: 40px;
}
.btn:hover { background: var(--bg-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.lg { min-height: 52px; font-size: 16px; padding: 12px 22px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .3px; }
.input, select.input, textarea.input {
  border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; background: #fff; min-height: 40px; width: 100%;
}
.input:focus { outline: 2px solid #b9d0f0; border-color: var(--brand); }
.input.lg { font-size: 20px; min-height: 52px; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.err { color: var(--bad); font-size: 14px; }

/* ---- modal / toast ---- */
.hub-modal-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px;
}
.hub-modal {
  background: #fff; border-radius: 10px; width: min(520px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.hub-modal.wide { width: min(720px, 100%); }
.hub-modal header { padding: 16px 20px 0; font-weight: 700; font-size: 18px; }
.hub-modal .body { padding: 12px 20px; color: var(--ink-2); line-height: 1.45; }
.hub-modal footer { padding: 12px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.hub-toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1100; }
.hub-toast {
  background: #1f2933; color: #fff; padding: 10px 14px; border-radius: 6px; max-width: 420px;
  box-shadow: var(--shadow); font-size: 14px;
}
.hub-toast.error { background: #a32020; }
.hub-toast.ok { background: #17663b; }

@media (max-width: 640px) {
  .hub-header { flex-wrap: wrap; padding: 8px 16px; }
  .wrap { padding: 16px; }
  .hub-title { display: none; }
}

/* elements marked hidden stay hidden even when a component sets display */
[hidden] { display: none !important; }
