/* HEAT Contractor Portal.
   Colours are lifted from heateg.com's own stylesheet so the portal reads as
   part of the same company rather than a bolt-on: #ff4d1c on near-black. */

:root {
  --bg: #0d0d14;
  --surface: #14141e;
  --surface-2: #1c1c2a;
  --surface-3: #252535;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f0eeea;
  --muted: #888899;
  --primary: #ff4d1c;
  --primary-light: #ff7043;
  --success: #4caf50;
  --danger: #f44336;
  --warning: #ff9800;
  --info: #2196f3;
  --radius: 10px;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1rem; }
code { background: var(--surface-3); padding: .1em .4em; border-radius: 4px; font-size: .9em; }
pre { background: var(--surface-3); padding: 1rem; border-radius: var(--radius); overflow-x: auto; }
pre code { background: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ------------------------------------------------------------- chrome --- */

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar__inner {
  max-width: 1180px; margin: 0 auto; padding: 0 1rem;
  display: flex; align-items: center; gap: 1.25rem; min-height: 60px; flex-wrap: wrap;
}
.brand { font-weight: 800; letter-spacing: -.02em; color: var(--text); display: flex; align-items: center; gap: .55rem; }
.brand:hover { text-decoration: none; }
.brand__mark {
  background: var(--primary); color: #fff; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; font-size: .82rem; font-weight: 900;
}
.brand__sub { color: var(--muted); font-weight: 600; font-size: .82rem; }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--muted); padding: .45rem .75rem; border-radius: 8px; font-weight: 600; font-size: .93rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.is-on { background: var(--surface-3); color: var(--text); }
.whoami { color: var(--muted); font-size: .85rem; display: flex; align-items: center; gap: .6rem; }
.whoami b { color: var(--text); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1rem 4rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { color: var(--muted); margin: .2rem 0 0; }

/* -------------------------------------------------------------- pieces --- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem 1.25rem; }
.card + .card { margin-top: 1rem; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; }
.stat__n { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat__l { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat--warn .stat__n { color: var(--warning); }
.stat--alert .stat__n { color: var(--danger); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

.pill {
  display: inline-block; padding: .18rem .6rem; border-radius: 999px; font-size: .74rem;
  font-weight: 800; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.pill--active, .pill--resolved { background: rgba(76,175,80,.16); color: #7fd183; }
.pill--invited, .pill--open { background: rgba(33,150,243,.16); color: #74b9f5; }
.pill--suspended, .pill--urgent { background: rgba(244,67,54,.16); color: #f08a82; }
.pill--awaiting_admin, .pill--high { background: rgba(255,152,0,.16); color: #ffb74d; }
.pill--awaiting_contractor { background: rgba(255,77,28,.16); color: var(--primary-light); }
.pill--closed, .pill--low, .pill--normal { background: var(--surface-3); color: var(--muted); }
.pill--admin { background: rgba(255,77,28,.18); color: var(--primary-light); }

.btn {
  display: inline-block; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); padding: .5rem .95rem; border-radius: 8px; font-weight: 700; font-size: .92rem;
  cursor: pointer; font-family: inherit; text-align: center;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn--danger { background: transparent; border-color: rgba(244,67,54,.5); color: #f08a82; }
.btn--danger:hover { background: rgba(244,67,54,.12); }
.btn--sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: .3rem; }
label .hint { display: block; font-weight: 500; color: var(--muted); font-size: .8rem; margin-top: .1rem; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], input[type=file], select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--text); border-radius: 8px; padding: .6rem .7rem; font-family: inherit; font-size: .97rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
.field { margin-bottom: .95rem; }
.field-row { display: grid; gap: .95rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.check { display: flex; align-items: flex-start; gap: .55rem; font-weight: 600; font-size: .92rem; }
.check input { width: auto; margin-top: .25rem; }

.note { border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: 1.1rem; font-size: .93rem; border: 1px solid; }
.note--error { background: rgba(244,67,54,.1); border-color: rgba(244,67,54,.35); color: #f5a49e; }
.note--ok { background: rgba(76,175,80,.1); border-color: rgba(76,175,80,.35); color: #93d896; }
.note--info { background: rgba(33,150,243,.1); border-color: rgba(33,150,243,.35); color: #8cc5f7; }
.note--warn { background: rgba(255,152,0,.1); border-color: rgba(255,152,0,.35); color: #ffc576; }
.note code { background: rgba(0,0,0,.35); word-break: break-all; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { color: var(--muted); text-align: center; padding: 2.25rem 1rem; }
.empty p { margin-bottom: .75rem; }

/* ------------------------------------------------------------ specific --- */

.auth { max-width: 420px; margin: 8vh auto; padding: 0 1rem; }
.auth .card { padding: 1.75rem; }
.auth__head { text-align: center; margin-bottom: 1.5rem; }
.auth__head .brand { justify-content: center; font-size: 1.15rem; }

.thread { display: flex; flex-direction: column; gap: .9rem; }
.msg { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.msg--staff { border-left: 3px solid var(--primary); }
.msg--note { border-left: 3px solid var(--warning); background: rgba(255,152,0,.07); }
.msg__head { display: flex; justify-content: space-between; gap: 1rem; font-size: .84rem; margin-bottom: .45rem; flex-wrap: wrap; }
.msg__who { font-weight: 800; }
.msg__body { white-space: pre-wrap; word-wrap: break-word; }

.doc { display: flex; gap: 1rem; align-items: flex-start; padding: .9rem 0; border-bottom: 1px solid var(--border); }
.doc:last-child { border-bottom: 0; }
.doc__main { flex: 1; min-width: 0; }
.doc__title { font-weight: 700; }
.doc__meta { color: var(--muted); font-size: .84rem; }

.article { max-width: 760px; }
.article h2 { margin-top: 1.75rem; }
.article ul, .article ol { padding-left: 1.3rem; }
.article table { margin: 1rem 0; }
.article blockquote { border-left: 3px solid var(--primary); margin: 1rem 0; padding: .3rem 0 .3rem 1rem; color: var(--muted); }

.searchbar { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.searchbar input { flex: 1; }

.faq-list { display: grid; gap: .75rem; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; }
.faq-item h3 { margin-bottom: .25rem; }
.faq-item .muted { font-size: .88rem; }

@media (max-width: 640px) {
  .topbar__inner { min-height: 0; padding: .6rem 1rem; }
  .nav { order: 3; width: 100%; }
  h1 { font-size: 1.4rem; }
}
