/* Aire One · Abode Accounts portal */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7c;
  --border: #dde2e8;
  --brand: #0f4c81;
  --brand-dark: #0b3a63;
  --focus: #2f80ed;

  --green-bg: #e3f4e8; --green-fg: #156b34; --green-bd: #9fd5b0;
  --red-bg: #fde7e7;   --red-fg: #a31d1d;   --red-bd: #f1a7a7;
  --amber-bg: #fff3d6; --amber-fg: #7a4d00; --amber-bd: #f0cd7a;
  --grey-bg: #eceff3;  --grey-fg: #48525f;  --grey-bd: #c9d0d8;
  --blue-bg: #e3eefb;  --blue-fg: #0f4c81;  --blue-bd: #a9c6ea;
  --violet-bg: #efe8fb; --violet-fg: #5a2d9c; --violet-bd: #c8b4ee;

  --radius: 10px;
  font-size: 17px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--brand); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
h1 { font-size: 1.6rem; margin: 0 0 0.6rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.8rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline { display: inline; margin: 0; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 1.5rem;
  background: var(--brand); color: #fff; padding: 0.75rem 1.5rem;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.nav a, .nav .link-button { color: #fff; text-decoration: none; font-size: 0.95rem; opacity: 0.92; }
.nav a:hover, .nav .link-button:hover { opacity: 1; text-decoration: underline; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }

/* Freshness banner */
.freshness { padding: 0.5rem 1.5rem; font-size: 0.92rem; border-bottom: 1px solid var(--border); }
.freshness-ok { background: #eef3f8; color: var(--grey-fg); }
.freshness-amber { background: var(--amber-bg); color: var(--amber-fg); border-color: var(--amber-bd); }
.freshness-red { background: var(--red-bg); color: var(--red-fg); border-color: var(--red-bd); }
.freshness a { color: inherit; font-weight: 600; }

.container { max-width: 1040px; margin: 0 auto; padding: 1.5rem; }

/* Messages and notices */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message { padding: 0.7rem 1rem; border-radius: var(--radius); margin-bottom: 0.5rem; background: var(--blue-bg); color: var(--blue-fg); }
.message-error { background: var(--red-bg); color: var(--red-fg); }
.message-warning { background: var(--amber-bg); color: var(--amber-fg); }
.message-success { background: var(--green-bg); color: var(--green-fg); }
.notice { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; }
.notice-warn { background: var(--amber-bg); border-color: var(--amber-bd); color: var(--amber-fg); }
.form-error { color: var(--red-fg); background: var(--red-bg); padding: 0.5rem 0.75rem; border-radius: 6px; margin: 0.25rem 0 0.75rem; }

/* Forms and buttons */
input[type=text], input[type=password], input[type=search], input[type=email], select {
  width: 100%; font: inherit; padding: 0.65rem 0.8rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
label { display: block; font-weight: 600; margin: 0.8rem 0 0.3rem; }
button, .button {
  display: inline-block; font: inherit; font-weight: 600; padding: 0.6rem 1.1rem; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; text-decoration: none;
}
button.primary, .button.primary, .search-form button { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover, .button.primary:hover, .search-form button:hover { background: var(--brand-dark); }

/* Search */
.search-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem 1.5rem; margin-bottom: 1.2rem; }
.search-form { display: flex; gap: 0.6rem; }
.search-form input { font-size: 1.2rem; padding: 0.8rem 1rem; }
.result-count { color: var(--muted); margin: 0 0 0.6rem; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.result {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.85rem 1.1rem; color: var(--text); text-decoration: none;
}
.result:hover { border-color: var(--brand); box-shadow: 0 1px 4px rgba(15, 76, 129, 0.12); }
.result-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.result-name { font-weight: 700; font-size: 1.08rem; }
.result-meta { font-size: 0.92rem; }
.result-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem; flex-shrink: 0; }
#results[aria-busy="true"] { opacity: 0.6; }

/* Badges */
.badge { display: inline-block; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.badge-xl { font-size: 1.25rem; padding: 0.45rem 1.1rem; }
.status-active { background: var(--green-bg); color: var(--green-fg); border-color: var(--green-bd); }
.status-past-due { background: var(--red-bg); color: var(--red-fg); border-color: var(--red-bd); }
.status-closed, .status-other { background: var(--grey-bg); color: var(--grey-fg); border-color: var(--grey-bd); }
.service-aireone { background: var(--blue-bg); color: var(--blue-fg); border-color: var(--blue-bd); }
.service-abode { background: var(--amber-bg); color: var(--amber-fg); border-color: var(--amber-bd); }
.service-dealer { background: var(--violet-bg); color: var(--violet-fg); border-color: var(--violet-bd); }

/* Contract page */
.back { margin: 0 0 1rem; }
.contract-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.contract-head p { margin: 0; }
.service-box { border-radius: var(--radius); padding: 1rem 1.3rem; margin-bottom: 1rem; border: 2px solid; }
.service-box p { margin: 0; }
.service-box-aireone { background: var(--blue-bg); border-color: var(--blue-bd); color: var(--blue-fg); }
.service-box-abode { background: var(--amber-bg); border-color: var(--amber-bd); color: var(--amber-fg); }
.service-box-dealer { background: var(--violet-bg); border-color: var(--violet-bd); color: var(--violet-fg); }
.service-label { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.service-value { font-size: 1.4rem; font-weight: 800; }
.service-reason { margin-top: 0.25rem !important; font-weight: 600; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.figure { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 1rem; display: flex; flex-direction: column; }
.figure-label { color: var(--muted); font-size: 0.85rem; }
.figure-value { font-size: 1.3rem; font-weight: 700; }
.figure-alert { border-color: var(--red-bd); background: var(--red-bg); }
.figure-alert .figure-value { color: var(--red-fg); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1rem; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.2rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 0.95rem; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f0f3f6; font-weight: 700; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 0.6rem; margin-bottom: 1rem; }
.filters label { margin: 0; }
.filters select { width: auto; }
.pager { display: flex; gap: 1rem; justify-content: center; margin-top: 1rem; }

/* Sign-in pages */
.auth-page .container { max-width: 520px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem 1.8rem; margin-top: 1.5rem; }
.auth-card-wide { max-width: 640px; }
.auth-page .auth-card-wide { max-width: none; }
.auth-card button[type=submit].primary { width: 100%; margin-top: 1rem; padding: 0.75rem; }
.auth-card form + form { margin-top: 0.8rem; text-align: center; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: 0.7rem; }
.qr { margin: 0.8rem 0; }
.qr img { display: block; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.secret { display: inline-block; margin-top: 0.4rem; font-size: 1rem; letter-spacing: 0.06em; background: var(--grey-bg); padding: 0.3rem 0.6rem; border-radius: 6px; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem 1rem; font-size: 1.15rem; }
.codes code { background: var(--grey-bg); padding: 0.25rem 0.6rem; border-radius: 6px; }

/* Stats page */
.page-head p { margin: 0 0 1rem; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem; }
.kpi p { margin: 0; }
.kpi-label { color: var(--muted); font-size: 0.88rem; font-weight: 600; }
.kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin: 0.15rem 0 !important; font-variant-numeric: tabular-nums; }
.kpi-note { color: var(--muted); font-size: 0.85rem; }
.kpi-alert { border-color: var(--red-bd); }
.kpi-alert .kpi-value { color: var(--red-fg); }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.stat-card { margin-bottom: 1rem; }
.stat-card h2 { margin-bottom: 0.2rem; }
.stat-card .hint { margin: 0 0 0.6rem; }
.stat-wide { grid-column: 1 / -1; }

.meter-list { list-style: none; margin: 0 0 0.4rem; padding: 0; display: grid; gap: 0.45rem; }
.meter-row { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(4rem, 1fr) max-content; align-items: center; gap: 0.75rem; font-size: 0.93rem; }
.meter-name { overflow-wrap: anywhere; }
.meter-name .badge { white-space: normal; }
.meter-bar { display: block; width: 100%; height: 10px; }
.meter-track { fill: var(--blue-bg); }
.meter-fill { fill: var(--brand); }
.meter-figure { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }


.stat-table th, .stat-table td { padding: 0.45rem 0.6rem; }
.company-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.8rem; }
.company-list li + li { border-top: 1px solid var(--border); padding-top: 0.8rem; }
.company-list p { margin: 0; }
.company-name { font-weight: 700; }
.company-figures { display: flex; flex-wrap: wrap; gap: 0.15rem 1.1rem; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 860px) {
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .meter-row { grid-template-columns: minmax(0, 1fr) max-content; gap: 0.2rem 0.75rem; }
  .meter-bar { grid-column: 1 / -1; grid-row: 2; }
  .kpi-value { font-size: 1.5rem; }
}

@media (max-width: 640px) {
  :root { font-size: 16px; }
  .container { padding: 1rem; }
  .topbar { padding: 0.75rem 1rem; }
  .search-form { flex-direction: column; }
  .result { flex-direction: column; align-items: flex-start; }
  .result-badges { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .contract-head { flex-direction: column; }
}

@media print {
  .topbar, .freshness, .no-print, .back { display: none !important; }
  body { background: #fff; }
  .auth-card, .card { border: 0; }
}
