/* Colours taken from epiuselabs.com */
:root {
  --navy: #1B2750;
  --red: #CE181E;
  --red-hover: #BE080E;
  --blue: #294095;
  --text: #414042;
  --bg: #FAFAFA;
  --bg-alt: #F1F1F2;
  --border: #D0D0D0;
  --white: #FFFFFF;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Lato, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 20px; }

h1 { color: var(--navy); font-weight: 900; margin: 28px 0 16px; }
h2 { color: var(--navy); font-size: 17px; margin: 0 0 8px; }

/* Header & stepper */
/* White header so the logo (white background) sits cleanly; navy rule underneath */
.topbar { background: var(--white); color: var(--navy); border-bottom: 4px solid var(--navy); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 16px; }
.logo { height: 56px; width: auto; display: block; }
.app-name { font-weight: 900; font-size: 20px; letter-spacing: .3px; padding-left: 16px; border-left: 2px solid var(--border); }
.stepper { list-style: none; display: flex; gap: 20px; margin: 0; padding: 0; }
.stepper li { display: flex; align-items: center; gap: 8px; opacity: .45; font-weight: 700; }
.stepper li.active, .stepper li.done { opacity: 1; }
.stepper .num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--navy); font-size: 12px; }
.stepper li.done .num { background: var(--navy); color: var(--white); }
.stepper li.active .num { background: var(--red); border-color: var(--red); color: var(--white); }

/* Panels & fields */
.panel { background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: 20px; margin-bottom: 18px; }
.field { display: block; border: 0; padding: 0; margin: 0 0 18px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-weight: 700; color: var(--navy); margin-bottom: 6px; padding: 0; }
.req { color: var(--red); }
.hint { margin: 0 0 12px; color: #636363; }
.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 22px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--blue); }

input[type="text"] {
  font: inherit; color: var(--text);
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px;
  width: 100%; max-width: 420px; background: var(--white);
}
input[type="text"]:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
select { font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--white); min-width: 240px; max-width: 420px; cursor: pointer; }
select:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
select.invalid { border-color: var(--red); background: #FFF5F5; }
input.invalid { border-color: var(--red); background: #FFF5F5; }

.error { color: var(--red); font-size: 13px; display: block; min-height: 1em; margin-top: 4px; }
.error:empty { display: none; }
.error.block { margin-top: 10px; }

.notice { background: #EEF1F9; border-left: 4px solid var(--blue); padding: 12px 16px; margin-bottom: 18px; border-radius: 4px; }

/* Product route builder sections (shown with titles when both products are selected) */
.builder + .builder, #controlCenter:not(.inline) + #builders { margin-top: 36px; }
/* Control Center title: section header when separate, panel heading when inside a single builder */
#controlCenter .panel-title, #controlCenter.inline .builder-title { display: none; }
#controlCenter.inline .panel-title { display: block; }
/* Label and control on one line; any error message wraps onto the next line */
.field-inline { display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; }
.field-inline .label { margin-bottom: 0; }
.field-inline .error { flex-basis: 100%; }
.builder-title { font-size: 20px; color: var(--white); background: var(--navy); border-left: 6px solid var(--red); padding: 10px 16px; border-radius: 4px; margin: 0 0 14px; }

/* Buttons */
.btn { font: inherit; font-weight: 700; border-radius: 4px; padding: 9px 18px; cursor: pointer; border: 2px solid transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--red-hover); }
.btn-secondary { background: var(--white); color: var(--blue); border-color: var(--blue); }
.btn-secondary:hover { background: #EEF1F9; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--border); }
.icon-btn { font: inherit; background: none; border: 1px solid transparent; border-radius: 4px; color: var(--blue); cursor: pointer; padding: 2px 6px; line-height: 1.2; }
.icon-btn:hover:not(:disabled) { background: var(--bg-alt); border-color: var(--border); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.danger { color: var(--red); }
.actions { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0 40px; }
.actions .btn-primary:only-child { margin-left: auto; }
.actions .save-status { margin-left: auto; }   /* status sits just left of the primary button */

/* SID/client entry table */
.entry { border-collapse: collapse; margin-bottom: 12px; }
.entry th { text-align: left; color: var(--navy); font-size: 13px; padding: 4px 8px; }
.entry td { padding: 4px 8px; vertical-align: top; }
.entry td:first-child { color: #888; padding-top: 12px; width: 30px; }
.entry input[type="text"] { width: 110px; text-transform: uppercase; }
.entry .error { max-width: 240px; }

/* Cards */
/* Cards and the empty route slots share one fixed size, so a slot is exactly a card's footprint */
:root { --card-w: 130px; --card-h: 44px; }
.card, .slot { box-sizing: border-box; width: var(--card-w); height: var(--card-h); border-radius: 5px; }
.card {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--white); border: 2px solid var(--navy); border-left: 6px solid var(--red);
  padding: 0 8px; font-weight: 700; color: var(--navy);
  cursor: grab; user-select: none; white-space: nowrap;
}
.slot { border: 2px dashed var(--border); background: var(--white); }
.card .sep { color: #999; font-weight: 400; }
.card:hover { box-shadow: 0 2px 6px rgba(27,39,80,.2); }
.card.selected { outline: 3px solid var(--blue); outline-offset: 2px; }
.card.dragging { opacity: .4; }

.tray { display: flex; flex-wrap: wrap; gap: 10px; min-height: 64px; padding: 12px; border: 2px dashed var(--border); border-radius: 6px; background: var(--bg-alt); }

/* Routes grid */
.grid-scroll { overflow-x: auto; margin-bottom: 12px; }
.routes { border-collapse: separate; border-spacing: 6px; }
.routes th { background: var(--navy); color: var(--white); padding: 8px 10px; border-radius: 4px; font-weight: 700; white-space: nowrap; }
.routes th.corner { background: transparent; color: #888; font-weight: 400; font-size: 12px; }
.routes th.side { width: var(--card-w); box-sizing: border-box; }
.routes th.arrow-col { background: transparent; }
.routes td.arrow-col { color: var(--navy); font-size: 22px; font-weight: 700; text-align: center; padding: 0 4px; }
.routes .row-num { color: #888; text-align: center; min-width: 24px; }
.routes td.opts { vertical-align: middle; padding: 0 8px; white-space: nowrap; }
.routes td.opts .check { display: flex; margin: 3px 0; font-size: 14px; }
.routes tr.row-invalid td.opts { color: var(--red); }
/* The cell itself has no box; its .slot (or card) is the visible drop target */
.cell { padding: 0; vertical-align: middle; }
.cell .card { display: flex; }
.cell.can-place { cursor: pointer; }
.cell.can-place .slot { border-color: var(--blue); }
.routes tr.row-invalid .slot { border-color: var(--red); background: #FFF5F5; }
.routes tr.row-invalid .row-num { color: var(--red); font-weight: 700; }

.tray.over, .cell.over .slot { border-color: var(--red); background: #FFF5F5; }
.cell.over .card { outline: 3px solid var(--red); outline-offset: 2px; }

/* Results preview */
.kv { border-collapse: collapse; width: 100%; max-width: 640px; }
.kv th, .kv td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--bg-alt); }
.kv thead th { background: var(--navy); color: var(--white); }
/* Output lists (Users, RFCs): columns size to their content and never wrap; scroll sideways if needed */
.kv.output { width: auto; max-width: none; }
.kv.output th, .kv.output td { white-space: nowrap; }
.muted { color: #999; font-style: italic; }

/* Header link (Admin / Back) */
.header-link { color: var(--blue); font-weight: 700; text-decoration: none; }
.header-link:hover { color: var(--red); text-decoration: underline; }

/* Admin page */
.admin-table input[type="text"] { width: 260px; text-transform: none; }
.save-status { align-self: center; font-weight: 700; }
.save-status.pending { color: #8a6d00; }
.save-status.ok { color: #2e7d32; }
.save-status.error { color: var(--red); }

.warn { color: var(--red); font-weight: 700; }
