:root {
  --navy: #10263b;
  --navy-dark: #0a1a2b;
  --gold: #c9a227;
  --gold-light: #e4c86a;
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e1e6ea;
  --text: #1c2b38;
  --muted: #6b7a87;
  --ok: #1f8a4c;
  --ok-bg: #e7f6ed;
  --warning: #b8860b;
  --warning-bg: #fdf3d9;
  --danger: #c0392b;
  --danger-bg: #fbe7e4;
  --neutral: #5a6b78;
  --neutral-bg: #eceff1;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 64px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-center { justify-content: center; margin-bottom: 24px; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--navy-dark);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 14.5px; }
.brand-text small { color: var(--gold-light); font-size: 12px; }

.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a {
  color: #cdd8e2;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
}
.topnav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.topnav a.active { background: var(--gold); color: var(--navy-dark); font-weight: 600; }

.user-menu { display: flex; align-items: center; gap: 12px; color: #cdd8e2; font-size: 14px; }

.content { flex: 1; padding: 28px 24px 40px; max-width: 1200px; width: 100%; margin: 0 auto; }

.app-footer {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 12.5px;
}

.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: block;
  transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: 0 4px 14px rgba(16,38,59,0.08); text-decoration: none; }
.stat-num { font-size: 30px; font-weight: 700; color: var(--navy); }
.stat-label { color: var(--muted); font-size: 13.5px; margin: 2px 0 10px; }
.stat-sub { display: flex; gap: 6px; flex-wrap: wrap; }

/* Panels */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.panel h2 { font-size: 15.5px; margin: 0 0 12px; }
.link-more { display: inline-block; margin-top: 10px; font-size: 13.5px; }

.detail-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }
.panel-wide { min-width: 0; }

.detail-list { display: grid; grid-template-columns: 130px 1fr; row-gap: 8px; font-size: 14px; margin: 0 0 14px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
.table td.col-desc { white-space: normal; min-width: 220px; }
.table thead th { background: #f8fafb; color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.table tbody tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.inline { display: inline; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); }

/* Toolbar & filters */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-form { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.filter-form input[type=text] { min-width: 220px; }

/* Forms */
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-light); border-color: var(--gold); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.full { grid-column: 1 / -1; }

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.form-card h3 { margin: 0 0 14px; font-size: 16px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { background: #f2f4f6; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--border); }
.btn-ghost:hover { background: #eef1f3; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger-bg); }
.btn-danger-ghost:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* Login */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%);
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-card form { display: flex; flex-direction: column; gap: 14px; }

/* Parts list (chiller detail page) */
.parts-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.parts-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}
.inline-add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-add-form input[type=text] { flex: 1; min-width: 120px; }

/* Print / detailed view card */
.print-card { max-width: 720px; margin: 0 auto; }
.print-card-wide { max-width: 960px; margin: 0 auto; }
.print-card-wide h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.print-card-wide tfoot td { border-top: 2px solid var(--border); }
.print-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--navy);
}
.print-meta { font-size: 12px; text-align: right; }

/* Compact spec sheet: a dense grid of small-label/value pairs instead of
   one field per line, so the report's header section stays short and the
   service history table gets the rest of the page/printed sheet. */
.report-spec-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 18px;
  margin-bottom: 4px;
}
.spec-item { min-width: 0; }
.spec-item.full { grid-column: 1 / -1; }
.spec-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  line-height: 1.3;
}
.spec-value {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow-wrap: break-word;
}

/* Parts rendered as one flowing, comma-separated line instead of a bulleted
   list — 16 parts takes 1-2 lines instead of 16. */
.report-parts-line { font-size: 13px; line-height: 1.6; margin: 0 0 4px; }
.report-parts-line .label { font-weight: 700; color: var(--text); margin-right: 4px; }

.print-footer { margin-top: 20px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 12px; }

@media print {
  .topbar, .app-footer, .no-print { display: none !important; }
  body { background: #fff; }
  .content { max-width: 100%; padding: 0; margin: 0; }
  .print-card, .print-card-wide { border: none; box-shadow: none; padding: 0; max-width: 100%; }
  .table-wrap { border: none; }
  .table { font-size: 11.5px; }
  .table th, .table td { padding: 4px 6px; white-space: normal; }
  .table thead th { font-size: 9.5px; }
  a { color: inherit; text-decoration: none; }
  .badge { border: 1px solid currentColor; padding: 1px 6px; }
  .report-spec-grid { grid-template-columns: repeat(4, 1fr); gap: 5px 16px; }
  .spec-label { font-size: 8.5px; }
  .spec-value { font-size: 11.5px; }
  .print-card-wide h2 { font-size: 9.5px; margin: 8px 0 5px; }
}
