/* STL Compliance Manager — design system.
   White background, black text. A deliberately chosen dark red used sparingly
   for primary actions and attention. Clean, official/compliance feel. */

:root {
  --bg: #ffffff;
  --ink: #111111;
  --ink-soft: #555555;
  --muted: #767676;
  --line: #e2e2e2;
  --line-strong: #cfcfcf;
  --surface: #ffffff;
  --surface-2: #f7f7f6;

  --accent: #8a1c1c;        /* dark red — sparingly */
  --accent-ink: #ffffff;
  --accent-hover: #6f1616;
  --accent-tint: #f6ecec;   /* faint red wash for attention bars only */

  --ok: #1f7a3d;
  --warn: #a96a00;
  --bad: #8a1c1c;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --maxw: 980px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
/* The [hidden] attribute must win over component display rules (.field is flex). */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }

/* ---- buttons ---- */
.btn {
  font: inherit; font-weight: 600;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: .55rem .9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 1.5rem; line-height: 1; color: var(--muted); padding: .1rem .4rem;
}
.icon-btn:hover { color: var(--ink); }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 3px;
  background: var(--accent); display: inline-block; flex: none;
}

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.field input, .field select {
  font: inherit; color: var(--ink);
  padding: .55rem .65rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-error {
  color: var(--accent); font-size: .9rem; font-weight: 600;
  background: var(--accent-tint); border-left: 3px solid var(--accent);
  padding: .5rem .65rem; border-radius: 6px; margin: 0 0 .75rem;
}
.form-note {
  color: var(--ink-soft); font-size: .9rem; background: var(--surface-2);
  border-left: 3px solid var(--line-strong); padding: .5rem .65rem; border-radius: 6px; margin: 0 0 .75rem;
}
.link-inline {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  color: var(--accent); font-weight: 600; text-decoration: underline; align-self: flex-start;
  margin: -.35rem 0 .75rem;
}
.link-inline:hover { color: var(--accent-hover); }
.verify-bar { margin-bottom: 1.25rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: baseline; }
.verify-bar .link-inline { margin: 0; }

/* ---- tabs ---- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1rem 0; }
.tab {
  font: inherit; font-weight: 600; color: var(--muted);
  background: none; border: none; cursor: pointer;
  padding: .5rem .25rem; margin-right: 1rem;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---- auth view ---- */
.auth-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.auth-card { width: 100%; max-width: 380px; }

/* ---- app shell ---- */
.app-shell { min-height: 100dvh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar-right { display: flex; align-items: center; gap: .85rem; }
.user-email { font-size: .9rem; }
.main { max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.main-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }

/* ---- property list ---- */
.prop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.prop-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.prop-meta { margin: .75rem 0 0; display: grid; gap: .5rem; }
.prop-meta > div { display: grid; grid-template-columns: 110px 1fr; gap: .5rem; }
.prop-meta dt { color: var(--muted); font-size: .85rem; margin: 0; }
.prop-meta dd { margin: 0; font-size: .9rem; }

.empty { grid-column: 1 / -1; text-align: center; padding: 2.5rem 1.5rem; }
.empty h2 { margin-bottom: .25rem; }

/* ---- status (traffic light) ---- */
.status { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-green { color: var(--ok); } .status-green .dot { background: var(--ok); }
.status-amber { color: var(--warn); } .status-amber .dot { background: var(--warn); }
.status-red   { color: var(--bad); } .status-red .dot { background: var(--bad); }

/* ---- modal ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .4);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 2rem 1rem; overflow: auto; z-index: 50;
}
.modal { width: 100%; max-width: 460px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: .5rem; }

.loading { color: var(--muted); padding: 2rem; text-align: center; }
.small { font-size: .82rem; }

/* danger buttons (dark red) */
.btn-danger { color: var(--accent); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--accent-tint); border-color: var(--accent); }
.btn-danger-solid { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger-solid:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger-solid:disabled { opacity: .45; cursor: not-allowed; }

/* dashboard account footer (privacy link + delete account) */
.account-footer {
  margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line);
  display: flex; gap: 1.5rem; align-items: center; justify-content: center;
  font-size: .9rem;
}
.account-footer a { color: var(--muted); text-decoration: underline; }
.danger-link { color: var(--muted); }
.danger-link:hover { color: var(--accent); }

/* property photo */
.prop-card-photo { margin: -1rem -1rem .85rem; border-radius: 10px 10px 0 0; overflow: hidden; }
.prop-card-photo img { display: block; width: 100%; height: 140px; object-fit: cover; }
.photo-field { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.photo-preview { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

.form-section-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--ink-soft); margin: 1.1rem 0 .1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.switcher { max-width: 360px; margin-bottom: 1.25rem; }

.brand-link { background: none; border: none; cursor: pointer; padding: 0; color: inherit; font: inherit; }
.brand-link .brand-mark { vertical-align: middle; }

.prop-card { cursor: pointer; transition: border-color .12s ease, box-shadow .12s ease; }
.prop-card:hover { border-color: var(--line-strong); box-shadow: 0 2px 8px rgba(0,0,0,.07); }
.prop-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* status: neutral */
.status-none { color: var(--muted); } .status-none .dot { background: var(--muted); }

/* ---- property detail ---- */
.link-back {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font: inherit; font-weight: 600; padding: .25rem 0; margin-bottom: .5rem;
}
.link-back:hover { color: var(--ink); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.detail-head p { margin: .15rem 0 0; }
.detail-summary { margin-bottom: 1rem; }
.detail-summary .prop-meta > div { grid-template-columns: 140px 1fr; }

/* attention bar — faint red wash, used sparingly */
.attention-bar {
  background: var(--accent-tint);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: .75rem .9rem;
  font-size: .9rem;
  margin-bottom: 1.5rem;
}
/* dismiss control inside an attention bar (e.g. the CO nudge) sits on its own line */
.nudge-actions { margin-top: .55rem; }
.nudge-dismissed { margin: -.75rem 0 1.25rem; }
/* hot tub details card */
.ht-details { margin-bottom: 1.5rem; }

/* ---- documents ---- */
.docs-section { margin-bottom: 1.75rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.doc-list { display: grid; gap: .6rem; }
.doc-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; }
.doc-main { min-width: 0; }
.doc-cat { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.doc-title { font-weight: 600; margin: .1rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-side { display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; flex: none; }
.doc-actions { display: flex; gap: .4rem; }

/* deliberate-friction confirm: Cancel is the easy default, Delete sits apart */
.confirm-modal p { margin: 0 0 .65rem; }
.confirm-actions { justify-content: space-between; margin-top: 1.25rem; }

/* ---- detail tabs ---- */
.detail-tabs { margin: .5rem 0 1.25rem; flex-wrap: wrap; }
.btn-sm { padding: .35rem .6rem; font-size: .85rem; }

/* ---- alarm: rooms & devices ---- */
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.room-head h3 { margin: 0; }
.devices { display: grid; gap: .4rem; }
.device { display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; }
.device-info { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.device-type { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  padding: .12rem .4rem; border-radius: 5px; background: var(--surface-2); color: var(--ink-soft); white-space: nowrap; }
.device-type.type-co { background: var(--accent-tint); color: var(--accent); }

/* alarm Test History: prev/next month nav + a horizontally-scrolling strip of
   test cards, so a property's history never piles into one tall column */
.month-nav { display: flex; align-items: center; gap: .5rem; margin: .75rem 0; }
.month-nav input[type="month"] {
  font: inherit; padding: .4rem .5rem; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--surface);
}
.month-nav .muted.small { margin-left: auto; }
.tests-strip { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x proximity; }
.tests-strip .doc-row { flex: none; width: 230px; scroll-snap-align: start; }

/* overflow "⋯" trigger + the popover menu it opens (used on device chips so
   Move/Delete don't have to live as permanent flat buttons) */
.kebab-btn {
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
  border-radius: 8px; width: 2rem; height: 2rem; line-height: 1; font-size: 1.1rem;
  color: var(--ink-soft); flex: none;
}
.kebab-btn:hover { background: var(--surface-2); color: var(--ink); }
.menu-popover {
  position: fixed; z-index: 50; min-width: 170px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: .3rem; display: flex; flex-direction: column;
}
.menu-item {
  border: none; background: none; text-align: left; padding: .55rem .6rem; border-radius: 6px;
  font: inherit; font-size: .9rem; color: var(--ink); cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item-danger { color: var(--accent); }
.menu-item-danger:hover { background: var(--accent-tint); }

/* ---- radio group ---- */
fieldset.field { border: none; padding: 0; margin: 0 0 .85rem; }
.radio-row { display: flex; gap: 1.25rem; padding-top: .15rem; }
.radio { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; cursor: pointer; }
.field textarea { font: inherit; padding: .55rem .65rem; border: 1px solid var(--line-strong); border-radius: 8px; resize: vertical; }
.field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

/* ---- sharing / handshake ---- */
.head-actions { display: flex; gap: .6rem; }
.role-pill { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .02em; padding: .12rem .45rem; border-radius: 5px; background: var(--surface-2); color: var(--ink-soft); }
.request-inbox { margin-bottom: 1.25rem; border-left: 3px solid var(--accent); }

/* "Attention needed" dashboard panel */
.att-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }
.att-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  width: 100%; text-align: left; padding: .6rem .75rem; cursor: pointer;
  background: var(--bg, #fff); border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.att-row:hover { border-color: var(--accent); }
.att-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.att-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.att-label { font-weight: 600; }
.request-inbox h2 { margin-bottom: .75rem; }
.req-list { display: grid; gap: .6rem; }
.req-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem 0; border-top: 1px solid var(--line); }
.req-row:first-child { border-top: none; }
.shared-head { margin: 1.75rem 0 .85rem; }

.scope-editor { display: grid; gap: 1rem; margin-bottom: 1rem; }
.scope-group-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); margin-bottom: .4rem; }
.scope-check { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; cursor: pointer; font-weight: 500; }
.scope-check.ack { margin: .75rem 0; font-weight: 600; }
.full-access-btn { margin-bottom: .5rem; }
.invite-link { width: 100%; font: inherit; padding: .55rem .65rem; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--surface-2); margin: .25rem 0 .5rem; }
.manager-scopes { margin-top: .25rem; }

/* ---- tasks ---- */
.task-row.task-done .doc-title { text-decoration: line-through; color: var(--muted); }
.task-status { font: inherit; padding: .4rem .5rem; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }

@media (max-width: 520px) {
  .doc-row { flex-direction: column; align-items: stretch; }
  /* status + actions share a row and can wrap so nothing is pushed off-screen */
  .doc-side { flex-direction: row; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .5rem; min-width: 0; }
  .doc-actions { flex-wrap: wrap; }
  /* long single-line details (esp. the Activity log) wrap instead of overflowing
     the page to the right — nowrap + ellipsis on a full-width block was spilling.
     overflow-wrap: anywhere lets unbreakable tokens (long emails, filenames) break
     rather than force the card wider than the screen. */
  .doc-title, .doc-sub { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  /* dropdowns (e.g. a long assignee email) shrink to fit rather than force width */
  .task-status, .task-assignee { max-width: 100%; }
  .detail-summary .prop-meta > div { grid-template-columns: 120px 1fr; }
  .rooms { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
  .prop-meta > div { grid-template-columns: 100px 1fr; }

  /* topbar: drop the (self-evident) email, keep brand + sign-out on one tidy line */
  .topbar { padding: .7rem 1rem; }
  .user-email { display: none; }
  .brand, .brand-link { white-space: nowrap; font-size: 1rem; }
  .topbar-right .btn { white-space: nowrap; }

  /* page heading + its actions stack instead of cramming onto one row.
     overflow-x: clip is a belt-and-braces guard so no stray wide content can ever
     make the whole page scroll sideways (internal scrollers like .tests-strip and
     .detail-tabs keep their own horizontal scroll). */
  .main { padding: 1.25rem 1rem 4rem; overflow-x: clip; }
  .main-head { flex-direction: column; align-items: stretch; gap: .75rem; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 0; white-space: nowrap; }

  /* attention rows: stack label over status so the date isn't squeezed */
  .att-row { flex-direction: column; align-items: flex-start; gap: .35rem; }

  /* card + detail headers: status pill drops below the title rather than crowding it */
  .prop-card-head, .detail-head { flex-direction: column; align-items: flex-start; gap: .4rem; }

  /* detail tabs: one tidy horizontally-scrollable row instead of wrapping to two */
  .detail-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .detail-tabs .tab { flex: none; }
}
