/* Epic Boilers business app.
   --brand and --accent are injected per-business from the database in
   base.html, so nothing here is specific to one company. */

:root {
  --brand: #1A2E4A;
  --accent: #E8870A;

  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --line: #E2E8F0;
  --line-2: #CBD5E1;
  --bg: #F1F5F9;
  --surface: #FFFFFF;

  --ok: #16A34A;
  --warn: #B45309;
  --danger: #DC2626;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

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

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  min-height: 56px;
  background: var(--brand);
  color: #fff;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 650;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 10px;
  height: 22px;
  border-radius: 3px;
  background: var(--accent);
  flex: none;
}

.nav {
  display: flex;
  gap: 4px;
  margin-right: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav a {
  color: rgba(255, 255, 255, .82);
  padding: 8px 12px;
  border-radius: 7px;
  font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; text-decoration: none; }
.nav a.is-active { background: rgba(255, 255, 255, .16); color: #fff; }

.topbar-end { display: flex; align-items: center; gap: 14px; }
.icon-link { color: rgba(255, 255, 255, .82); font-weight: 500; }
.icon-link:hover { color: #fff; }

.inline { display: inline; }

.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 500;
  color: rgba(255, 255, 255, .82);
  cursor: pointer;
}
.linklike:hover { color: #fff; text-decoration: underline; }

/* ---------- Layout ---------- */

.wrap { max-width: 1140px; margin: 0 auto; padding: 28px 20px 60px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; }
.page-sub { margin: 4px 0 0; color: var(--muted); }

.columns {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  align-items: start;
}

.footer {
  padding: 24px 20px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Cards & panels ---------- */

.cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.card-stat { display: flex; flex-direction: column; gap: 4px; color: inherit; }
.card-stat:hover { text-decoration: none; border-color: var(--line-2); }
.card-stat.is-flagged { border-left: 3px solid var(--accent); }

.stat-value { font-size: 25px; font-weight: 680; letter-spacing: -0.02em; color: var(--brand); }
.stat-label { font-size: 13px; color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
  margin: 0 0 18px;
}

fieldset.panel { border: 1px solid var(--line); }

.panel-title {
  font-size: 15px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 0;
  margin: 0 0 14px;
}

.panel-subtitle {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 22px 0 10px;
}

.panel-note { margin: -6px 0 14px; color: var(--muted); font-size: 13.5px; }

/* ---------- Lists ---------- */

.list { list-style: none; margin: 0; padding: 0; }

.list-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; padding-bottom: 0; }

.list-compact .list-row { padding: 8px 0; }

.list-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--brand);
  white-space: nowrap;
  flex: none;
}

.list-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.list-meta { font-size: 13px; color: var(--muted); }

.list-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  white-space: nowrap;
}
.is-overdue { color: var(--danger); }

.muted { color: var(--muted); margin: 0; }

/* ---------- Badges ---------- */

.badge {
  font-size: 11.5px;
  font-weight: 640;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-2);
  white-space: nowrap;
  flex: none;
}

.badge-scheduled { background: #E0EAFB; color: #1E3A8A; }
.badge-in_progress { background: #FEF3C7; color: #92400E; }
.badge-complete { background: #DCFCE7; color: #166534; }
.badge-cancelled { background: #F1F5F9; color: var(--muted); }
.badge-overdue { background: #FEE2E2; color: #991B1B; }
.badge-soon { background: #FEF3C7; color: #92400E; }
.badge-quiet { background: #F1F5F9; color: var(--ink-2); }

/* ---------- Forms ---------- */

.stack { display: flex; flex-direction: column; gap: 16px; }
.form-wide { max-width: 900px; }

.grid-2 {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 12.5px; font-weight: 400; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="tel"],
input:not([type]), select, textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 8px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 55%, white);
  outline-offset: 1px;
  border-color: var(--brand);
}

textarea { resize: vertical; }

/* flex-start, not center: labels wrap to two lines on a phone, and a
   centred box then floats oddly against the middle of the text. */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 14px;
  font-weight: 500;
}
.checkbox input {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--brand);
  flex: none;
}

.form-actions { display: flex; gap: 10px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, black); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 88%, black); }

.btn-quiet { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn-quiet:hover { background: var(--bg); }

.btn-block { width: 100%; }

/* ---------- Alerts ---------- */

.alert {
  padding: 11px 14px;
  border-radius: 8px;
  margin: 0 0 16px;
  font-weight: 500;
  border: 1px solid transparent;
}
.alert-error { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.alert-ok { background: #F0FDF4; color: #166534; border-color: #BBF7D0; }

/* ---------- Sign in ---------- */

body.centred {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--brand) 0%, #0B1B2E 100%);
}

.auth-wrap { width: 100%; max-width: 380px; padding: 24px; }

.auth-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 30px 28px 32px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
}

.auth-title { font-size: 21px; margin-bottom: 20px; }

/* ---------- Page head variants ---------- */

.page-head-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.crumb { margin: 0 0 6px; font-size: 13.5px; }
.crumb a { color: var(--muted); }

.head-actions { display: flex; gap: 8px; }

/* ---------- Search ---------- */

.searchbar { display: flex; gap: 8px; margin-bottom: 18px; }
.searchbar input { flex: 1; min-width: 0; }

/* ---------- Tables ---------- */

.panel-flush { padding: 0; overflow: hidden; }

/* Wide tables scroll inside their own box so the page body never does. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFC; }

.strong { font-weight: 620; }
.subtle { color: var(--ink-2); font-size: 13.5px; }
.dim { color: var(--muted); }
.wrap-any { overflow-wrap: anywhere; }
.preserve { white-space: pre-wrap; margin: 0; color: var(--ink-2); }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, white);
  color: #92400E;
  vertical-align: middle;
  margin-left: 4px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

/* ---------- Detail layout ---------- */

.columns-wide {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  align-items: start;
}

@media (max-width: 900px) {
  .columns-wide { grid-template-columns: 1fr; }
}

.panel-head { display: flex; justify-content: space-between; align-items: center; }

/* ---------- Properties & appliances ---------- */

.property {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  background: #FCFDFE;
}

.property-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.property-title { font-size: 15.5px; }
.property-sub { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.55; }

.appliances { list-style: none; margin: 14px 0 0; padding: 0; }

.appliance {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 8px;
}

.appliance summary,
.adder-summary {
  cursor: pointer;
  list-style: none;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.appliance summary::-webkit-details-marker,
.adder-summary::-webkit-details-marker { display: none; }
.appliance summary:hover { background: var(--bg); }

.appliance-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.appliance-main .dim { font-size: 12.5px; }

.inset { padding: 4px 14px 16px; }

.adder { margin-top: 6px; }
.adder-summary {
  color: var(--brand);
  font-weight: 600;
  font-size: 14px;
  border-radius: 8px;
}
.adder-summary:hover { background: var(--bg); }
.adder-major { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 14px; }

/* ---------- Danger ---------- */

.panel-danger { border-color: #FECACA; }

.btn-danger { background: #fff; color: var(--danger); border-color: #FECACA; }
.btn-danger:hover { background: #FEF2F2; }

.linklike-danger {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.linklike-danger:hover { color: var(--danger); text-decoration: underline; }

.alert-warn { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }

/* ---------- Empty state ---------- */

.empty-state { text-align: center; padding: 70px 20px; }
.empty-state h1 { font-size: 22px; margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin: 0 0 20px; }

/* ---------- Small screens ---------- */

@media (max-width: 680px) {
  .topbar { padding: 8px 14px; gap: 12px; }
  .nav { order: 3; width: 100%; margin-right: 0; padding-bottom: 2px; }
  .wrap { padding: 20px 14px 50px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 21px; }
  .list-row { flex-wrap: wrap; }
}
