
:root {
  --bg:#f5f7fb;
  --card:#ffffff;
  --ink:#172033;
  --muted:#667085;
  --line:#d8deea;
  --accent:#0f2f63;
  --accent2:#c62828;
  --danger:#b42318;
  --ok:#027a48;
  --warn:#b54708;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin:0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #fff4f4 0%, var(--bg) 260px);
  color: var(--ink);
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 14px 56px; }
.hero {
  display:flex; gap:16px; align-items:center; justify-content:space-between; margin-bottom:16px;
}
.hero-brand { display:flex; gap:16px; align-items:center; }
.hero-actions { display:flex; gap:10px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }
.hero-logo {
  width:72px; height:72px; border-radius:18px; box-shadow:0 10px 24px rgba(15,47,99,.14);
}
h1 { margin:0; font-size: clamp(1.7rem, 3vw, 2.5rem); letter-spacing:-0.035em; }
h2 { margin:0 0 14px; font-size:1.25rem; letter-spacing:-0.02em; }
h3 { margin:0 0 8px; font-size:1rem; }
.sub { color:var(--muted); margin:6px 0 0; line-height:1.45; }
.card { background:var(--card); border:1px solid var(--line); border-radius:18px; padding:18px; box-shadow: 0 16px 38px rgba(17, 24, 39, .08); margin:16px 0; }
.grid { display:grid; grid-template-columns: repeat(12, 1fr); gap:14px; }
.compact-grid { margin-top: 12px; }
.field { grid-column: span 4; }
.field.wide { grid-column: span 6; }
label { display:block; font-weight:700; font-size:.92rem; margin: 0 0 6px; }
input, textarea, select {
  width:100%;
  border:1px solid var(--line);
  border-radius:12px;
  padding:11px 12px;
  font: inherit;
  background:#fff;
  color:var(--ink);
  outline:none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent2); box-shadow:0 0 0 3px rgba(198, 40, 40, .14); }
input[readonly] { background:#f2f4f7; color:#344054; font-weight:700; }

.time-field { grid-column: span 4; }
.time-control {
  display:grid;
  grid-template-columns: 66px 12px 66px minmax(112px, 1fr);
  gap:8px;
  align-items:center;
}
.time-hour, .time-minute {
  text-align:center;
  font-size:1.08rem;
  font-weight:900;
  letter-spacing:.02em;
}
.time-colon {
  font-size:1.35rem;
  font-weight:900;
  color:var(--accent);
  text-align:center;
  line-height:1;
}
.ampm-toggle {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:5px;
  padding:4px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#f8fafc;
}
.period-btn {
  padding:10px 8px;
  border-radius:10px;
  border:1px solid var(--line);
  background:#fff;
  color:#344054;
  font-size:.95rem;
  font-weight:900;
}
.period-btn.active {
  background:linear-gradient(135deg, var(--accent2), #8f1d1d);
  border-color:var(--accent2);
  color:#fff;
  box-shadow:0 6px 16px rgba(198, 40, 40, .22);
}
.hidden { display:none !important; }
.hint { font-size:.82rem; color:var(--muted); margin-top:6px; line-height:1.35; }
.tabs { display:flex; gap:8px; flex-wrap:wrap; justify-content:center; margin:12px 0 4px; }
.tab {
  border:1px solid var(--line);
  background:#fff;
  color:#344054;
  border-radius:999px;
  padding:9px 13px;
  font-weight:800;
  cursor:pointer;
}
.tab.active { background:var(--accent); color:#fff; border-color:var(--accent); }
.pane { display:none; }
.pane.active { display:block; }
.row {
  display:grid;
  grid-template-columns: minmax(0, 1fr) 110px 44px;
  gap:10px;
  align-items:end;
  margin: 0 0 10px;
}
.actions { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-top:12px; }
.compact-actions { margin-top:8px; }
button {
  border:0;
  border-radius:12px;
  padding:10px 14px;
  font-weight:800;
  cursor:pointer;
  background:#e9eef8;
  color:#172033;
}
button.primary { background:linear-gradient(135deg, var(--accent), var(--accent2)); color:#fff; }
button.danger { background:#fee4e2; color:var(--danger); }
button.ghost { background:#fff; color:#344054; border:1px solid var(--line); }
button.ok { background:#dcfae6; color:var(--ok); }
button.warn { background:#fff6ed; color:var(--warn); }
button.small { padding:7px 10px; border-radius:10px; font-size:.86rem; }
button:disabled { opacity:.45; cursor:not-allowed; }
.totals { display:flex; gap:10px; flex-wrap:wrap; margin-top:10px; }
.pill { border:1px solid var(--line); background:#f8fafc; border-radius:999px; padding:8px 11px; font-size:.92rem; }
.pill strong { color:var(--accent2); }
.preview {
  min-height:112px;
  white-space:pre-wrap;
  background:#f8fafc;
  border:1px dashed var(--line);
  border-radius:14px;
  padding:12px;
  color:#344054;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height:1.35;
}
.status { min-height:22px; margin-top:12px; font-weight:800; color:var(--muted); }
.status.ok { color:var(--ok); }
.status.err { color:var(--danger); }
.status.warn { color:var(--warn); }
.library-head {
  display:grid;
  grid-template-columns: 1fr auto;
  gap:12px;
  align-items:end;
  margin-bottom:10px;
}
.trip-list { display:grid; gap:10px; }
.trip-card {
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px;
  background:#fff;
  display:grid;
  grid-template-columns: 1fr auto;
  gap:12px;
  align-items:center;
}
.trip-title { font-weight:900; letter-spacing:-0.01em; }
.trip-meta { color:var(--muted); font-size:.88rem; margin-top:4px; line-height:1.35; }
.trip-actions { display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; }
.empty {
  border:1px dashed var(--line);
  border-radius:16px;
  padding:18px;
  color:var(--muted);
  background:#f8fafc;
  text-align:center;
}
.summary-grid { display:grid; grid-template-columns: repeat(3, 1fr); gap:10px; }
.summary-box { border:1px solid var(--line); border-radius:14px; padding:12px; background:#f8fafc; }
.summary-box .num { font-size:1.45rem; font-weight:900; color:var(--accent); }
.summary-box .lbl { color:var(--muted); font-size:.84rem; }
.mode-card {
  margin-top: 14px;
  border:1px solid var(--line);
  background:#fcfcfd;
  border-radius:16px;
  padding:14px;
}
.mode-head { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.toggle-line { display:flex; align-items:center; gap:8px; margin:0; }
.toggle-line input { width:auto; }
.spacer { height:12px; }
.top-gap { margin-top:12px; }
.bullets { margin:0; padding-left:18px; line-height:1.5; }
code { background:#f2f4f7; padding:2px 6px; border-radius:8px; }
@media (max-width: 760px) {
  .hero { align-items:flex-start; flex-direction:column; }
  .hero-brand { align-items:flex-start; }
  .field, .field.wide, .time-field { grid-column: 1 / -1; }
  .row { grid-template-columns: 1fr 92px 40px; }
  .library-head { grid-template-columns: 1fr; }
  .trip-card { grid-template-columns: 1fr; }
  .trip-actions { justify-content:flex-start; }
  .summary-grid { grid-template-columns: 1fr; }
  .time-control { grid-template-columns: 64px 12px 64px minmax(110px, 1fr); }
  .mode-head { flex-direction:column; align-items:flex-start; }
}


/* 5399 update */
.muted-inline { color: var(--muted); font-weight: 500; margin-left: 6px; }
.settings-details summary { cursor: pointer; font-size: 1rem; }
.g5399-grid { display: grid; gap: 10px; }
.g5399-day { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 12px; }
.g5399-day-head { display:flex; justify-content:space-between; gap:10px; align-items:center; margin-bottom:10px; }
.g5399-day-title { font-weight: 900; }
.g5399-badges { display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
.g5399-badge { border-radius:999px; padding:5px 9px; font-weight:900; font-size:.78rem; background:#eef4ff; color:var(--accent); }
.g5399-badge.holiday { background:#fff1f0; color:var(--danger); }
.g5399-fields { display:grid; grid-template-columns: repeat(6, 1fr); gap:10px; }
.g5399-fields label { font-size:.78rem; }
.g5399-fields input { padding:9px 10px; border-radius:10px; }
.g5399-fields .wide5399 { grid-column: span 2; }
.g5399-auto-note { background:#f8fafc; border:1px dashed var(--line); border-radius:12px; padding:10px; color:var(--muted); font-weight:800; }
@media (max-width: 760px) {
  .g5399-fields { grid-template-columns: repeat(2, 1fr); }
  .g5399-fields .wide5399 { grid-column: 1 / -1; }
}

/* v2.8 daily 5399 action buttons */
.g5399-day-actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:12px; }
.g5399-day-actions button { min-width: 128px; }
@media (max-width: 760px) {
  .g5399-day-actions button { flex: 1 1 135px; }
}


/* v3.0 revision badge + direct text buttons */
.rev-pill {
  display:inline-flex;
  align-items:center;
  vertical-align:middle;
  margin-left:8px;
  padding:4px 8px;
  border-radius:999px;
  background:#fff1f0;
  color:var(--accent2);
  border:1px solid rgba(198, 40, 40, .25);
  font-size:.9rem;
  font-weight:900;
  letter-spacing:0;
}
.g5399-day-actions a.small {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  border-radius:10px;
  padding:7px 10px;
  font-size:.86rem;
  font-weight:800;
  min-width:128px;
}
.g5399-day-actions a.primary { background:linear-gradient(135deg, var(--accent), var(--accent2)); color:#fff; }
.g5399-day-actions a.ghost { background:#fff; color:#344054; border:1px solid var(--line); }
@media (max-width: 760px) {
  .g5399-day-actions button, .g5399-day-actions a.small { flex: 1 1 135px; }
}


/* HC Ware v3.6 dashboard */
.dash-hero-card { border-color: rgba(198, 40, 40, .18); }
.dash-head { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; flex-wrap:wrap; }
.dashboard-grid { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:12px; }
.dash-tile {
  text-align:left;
  display:flex;
  flex-direction:column;
  gap:6px;
  min-height:126px;
  border:1px solid var(--line);
  background:#fff;
  border-radius:16px;
  padding:14px;
  color:var(--ink);
  box-shadow:0 10px 24px rgba(17, 24, 39, .06);
}
.dash-tile:hover { border-color: rgba(198, 40, 40, .35); }
.dash-title { color:var(--muted); font-size:.86rem; font-weight:900; text-transform:uppercase; letter-spacing:.02em; }
.dash-tile strong { font-size:1.2rem; line-height:1.15; color:var(--accent); }
.dash-tile small { color:var(--muted); line-height:1.35; font-weight:700; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .dashboard-grid { grid-template-columns: 1fr; } .dash-head .primary { width:100%; } }

.auth-card { border-color: rgba(198, 40, 40, .28); }
.auth-chip { display:inline-flex; align-items:center; border:1px solid var(--line); background:#fff; color:#344054; border-radius:999px; padding:8px 11px; font-size:.88rem; }
body.auth-required .tabs, body.auth-required .pane { display:none !important; }
body.auth-required #authGate { display:block !important; }

.notice-box { border:1px solid var(--line); background:#f8fafc; border-radius:14px; padding:12px; margin-top:12px; color:#344054; font-weight:700; }
.notice-box.ok { border-color:#abefc6; background:#ecfdf3; color:#027a48; }
.notice-box.warn { border-color:#fedf89; background:#fffaeb; color:#b54708; }
.notice-box.err { border-color:#fecdca; background:#fff1f0; color:#b42318; }


/* HC Ware v4.3 Box Sort */
.full-field { grid-column: 1 / -1; }
.box-sort-date-field { min-width: 190px; }
.box-table-wrap { overflow-x:auto; border:1px solid var(--line); border-radius:14px; background:#fff; }
.box-sort-table { width:100%; border-collapse:collapse; min-width:1120px; }
.box-sort-table th, .box-sort-table td { border-bottom:1px solid var(--line); padding:8px; text-align:left; vertical-align:middle; }
.box-sort-table th { background:#f8fafc; color:var(--muted); font-size:.78rem; text-transform:uppercase; letter-spacing:.02em; }
.box-sort-table td input, .box-sort-table td select { padding:8px 9px; border-radius:10px; min-width:80px; }
.box-sort-table td:first-child input, .box-sort-table td:nth-child(3) input, .box-sort-table td:nth-child(4) input { max-width:74px; }
.box-sort-table td:nth-child(7) input, .box-sort-table td:nth-child(8) input { max-width:96px; }
.box-sort-preview { min-height:180px; }
.box-review-list { display:grid; gap:10px; }
.box-review-item { border:1px solid var(--line); background:#fff7ed; border-radius:14px; padding:10px; }
.box-review-item strong { color:var(--warn); }
.box-section-block { margin:0 0 12px; }
.box-section-title { font-weight:900; color:var(--accent); margin:0 0 4px; }
.box-section-line { margin-left:10px; }
@media (max-width:760px) {
  .box-sort-date-field { width:100%; }
  .box-sort-table { min-width:960px; }
}

.section-order-manager { border:1px solid var(--line); background:#f8fafc; border-radius:16px; padding:14px; }
.section-order-head { display:flex; justify-content:space-between; align-items:flex-start; gap:14px; flex-wrap:wrap; }
.section-order-head h3 { margin:0 0 4px; font-size:1rem; }
.compact-actions { margin-top:0; }
.section-order-list { display:grid; gap:8px; margin-top:10px; }
.section-order-row { display:grid; grid-template-columns:72px minmax(180px, 1fr) auto auto; align-items:center; gap:8px; background:#fff; border:1px solid var(--line); border-radius:12px; padding:8px; }
.section-order-num { width:64px; padding:8px 9px; border-radius:10px; border:1px solid var(--line); }
.section-order-name { display:flex; flex-direction:column; gap:2px; }
.section-order-name span { color:var(--muted); font-size:.82rem; }
@media (max-width: 720px) {
  .section-order-row { grid-template-columns:58px minmax(140px, 1fr) 42px 42px; }
  .section-order-num { width:52px; }
}

/* HC Ware v6.4 gas card tracker */
.gas-header-summary { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.gas-mini { display:inline-flex; align-items:center; border-radius:999px; padding:5px 8px; font-size:.78rem; font-weight:900; border:1px solid var(--line); background:#fff; }
.gas-mini.ok { color:var(--ok); background:#ecfdf3; border-color:#abefc6; }
.gas-mini.neg { color:var(--danger); background:#fff1f0; border-color:#fecdca; }
.gas-list { display:grid; gap:10px; }
.gas-card { border:1px solid var(--line); border-radius:16px; padding:12px; background:#fff; display:grid; grid-template-columns:1fr auto; gap:12px; align-items:center; }
.gas-summary-box.gas-ok .num, .gas-remaining.ok { color:var(--ok); }
.gas-summary-box.gas-over .num, .gas-remaining.neg, .dash-tile strong.neg { color:var(--danger); }
.gas-remaining { font-weight:900; }
@media (max-width:760px) {
  .gas-card { grid-template-columns:1fr; }
}


/* HC Ware v6.5 dashboard cleanup */
.gas-mini { gap:4px; }
.gas-mini.ok { color:inherit; background:#ecfdf3; border-color:#abefc6; }
.gas-mini.neg { color:inherit; background:#fff1f0; border-color:#fecdca; }
.gas-route-label, .gas-route { color:var(--ink); font-weight:900; }
.gas-amount.ok { color:var(--ok); font-weight:900; }
.gas-amount.neg { color:var(--danger); font-weight:900; }
.gas-dash-list { display:grid; gap:4px; }
.gas-dash-line { display:block; line-height:1.25; }
.dash-tile .gas-dash-list { margin-top:2px; }
.hero-actions { justify-content:center; }

.box-second-trip-list { display:grid; gap:8px; }
.box-second-trip-row { display:grid; grid-template-columns:auto 1fr auto; gap:10px; align-items:center; border:1px solid var(--line); border-radius:12px; padding:10px; background:#fff; }
.box-second-trip-row input { width:auto; transform:scale(1.15); }
.box-second-trip-row strong { color:#172033; }
.box-second-trip-row span { color:var(--muted); font-size:.9rem; }
@media (max-width:760px){ .box-second-trip-row { grid-template-columns:auto 1fr; } .box-second-trip-row span { grid-column:2; } }
