/* ==========================================================================
   Tenpoint portal — application chrome.
   Denser than the marketing stylesheet on purpose: 13–14px base, tight rows,
   panel widgets. Layout follows the RelativityOne reference (icon rail + top
   bar + panel cards); palette stays Tenpoint navy/orange.
   ========================================================================== */

:root {
  --ink:      #0a1226;
  --ink-2:    #131f42;
  --ink-3:    #1d2c58;

  --accent:   #ff6b35;
  --accent-2: #ff9d5c;
  --accent-d: #c9430f;

  --bg:       #f4f6fa;
  --card:     #ffffff;
  --line:     #e2e7f0;
  --line-2:   #eef1f7;

  --text:     #1a2333;
  --text-2:   #47536b;
  --muted:    #6b7689;

  --ok:       #14663f;
  --ok-bg:    #e6f6ee;
  --warn:     #a15200;
  --warn-bg:  #fff3e0;
  --bad:      #b3261e;
  --bad-bg:   #fdecea;
  --info:     #1b4bb8;
  --info-bg:  #eaf1fe;

  --rail-w:   78px;
  --top-h:    52px;

  --sans: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
          Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
svg { display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
ul { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 999; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 6px; }

/* ---------- Shell --------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }
.app.is-collapsed { --rail-w: 56px; }
.main { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Icon rail ----------------------------------------------------- */
.rail {
  background: var(--ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.rail__brand {
  height: var(--top-h); display: grid; place-items: center; flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.rail__brand svg { width: 26px; height: 26px; }
.rail__nav { padding: 8px 6px; display: grid; gap: 2px; overflow-y: auto; }
.rail__item {
  display: grid; justify-items: center; gap: 4px;
  padding: 9px 4px; border-radius: 7px; cursor: pointer;
  color: #93a3c4; font-size: 10.5px; line-height: 1.2; text-align: center;
  border: 0; background: none; width: 100%;
  transition: background-color .14s ease, color .14s ease;
}
.rail__item svg { width: 19px; height: 19px; }
.rail__item:hover { background: rgba(255, 255, 255, .07); color: #dfe5f2; }
.rail__item.is-on { background: rgba(255, 107, 53, .16); color: #fff; }
.rail__item.is-on svg { color: var(--accent-2); }
.is-collapsed .rail__item span { display: none; }
.rail__foot { margin-top: auto; padding: 8px 6px; border-top: 1px solid rgba(255, 255, 255, .08); }

/* The chevron points the way it will go: "<" to collapse, ">" to expand.
   A static "<" while already collapsed reads as a dead control. */
[data-collapse] svg { transition: transform .16s ease; }
.is-collapsed [data-collapse] svg { transform: rotate(180deg); }

/* ---------- Top bar ------------------------------------------------------- */
.top {
  height: var(--top-h); flex-shrink: 0;
  background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  position: sticky; top: 0; z-index: 20;
}
.top__crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.top__crumb a:hover { color: var(--text); }
.top__crumb b { color: var(--text); font-weight: 650; font-size: 14.5px; }
.top__crumb .sep { color: #c3ccdb; }
.top__actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.search {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 6px; background: #fbfcfe;
  padding: 5px 9px; width: 230px; color: var(--muted);
}
.search svg { width: 14px; height: 14px; flex-shrink: 0; }
.search input { border: 0; background: none; outline: 0; font: inherit; font-size: 13px; width: 100%; color: var(--text); }
.search kbd {
  font: inherit; font-size: 10px; color: var(--muted); background: #fff;
  border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px;
}

.iconbtn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--text-2);
}
.iconbtn:hover { background: var(--line-2); color: var(--text); }
.iconbtn svg { width: 17px; height: 17px; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink-3); color: #fff; font-size: 11px; font-weight: 650;
  display: grid; place-items: center; letter-spacing: .02em;
}

/* ---------- Dropdown ------------------------------------------------------ */
.menu { position: relative; }
.menu__pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 28px rgba(10, 18, 38, .14); padding: 5px; z-index: 40;
}
.menu__pop[hidden] { display: none; }
.menu__pop a, .menu__pop button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 10px; border-radius: 6px; font-size: 13px; border: 0; background: none;
  cursor: pointer; text-align: left; color: var(--text);
}
.menu__pop a:hover, .menu__pop button:hover { background: var(--line-2); }
.menu__pop svg { width: 15px; height: 15px; color: var(--muted); }
.menu__sep { height: 1px; background: var(--line); margin: 5px 0; }
.menu__head { padding: 8px 10px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu__head b { display: block; font-size: 13px; }
.menu__head span { font-size: 11.5px; color: var(--muted); }

/* ---------- Page ---------------------------------------------------------- */
.page { padding: 18px 20px 40px; flex: 1; min-width: 0; }
.page__head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page__head h1 { font-size: 19px; }
.page__head .sub { font-size: 12.5px; color: var(--muted); }
.page__head .spacer { margin-left: auto; }

/* ---------- Buttons ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 6px 13px; border-radius: 6px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  transition: background-color .14s ease, border-color .14s ease;
}
.btn:hover { background: #f7f9fc; border-color: #cfd7e6; }
.btn svg { width: 14px; height: 14px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #f75c22; border-color: #f75c22; }
.btn--sm { padding: 4px 9px; font-size: 12px; }
.btn--danger { color: var(--bad); }
.btn--danger:hover { background: var(--bad-bg); border-color: #f3c6c2; }

/* ---------- Panels -------------------------------------------------------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.panel + .panel { margin-top: 14px; }
.panel__head {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px; border-bottom: 1px solid var(--line); background: #fbfcfe;
}
.panel__head h2, .panel__head h3 { font-size: 13px; font-weight: 650; }
.panel__head .chev { color: var(--muted); }
.panel__head .spacer { margin-left: auto; }
.panel__body { padding: 14px; }
.panel__body--flush { padding: 0; }
.panel__foot {
  padding: 8px 13px; border-top: 1px solid var(--line); background: #fbfcfe;
  display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted);
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- KPI tiles ----------------------------------------------------- */
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 7px; padding: 12px 14px;
}
.kpi b { display: block; font-size: 24px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.kpi span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.kpi--alert b { color: var(--accent-d); }

/* ---------- Tables -------------------------------------------------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line-2); }
.tbl thead th {
  background: #f7f9fc; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; white-space: nowrap; border-bottom-color: var(--line);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fafbfe; }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .strong { font-weight: 600; }
.tbl .dim { color: var(--muted); font-size: 12px; }
.tbl--click tbody tr { cursor: pointer; }
.table-scroll { overflow-x: auto; }

/* ---------- Tags ---------------------------------------------------------- */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650; white-space: nowrap;
}
.tag--ok    { background: var(--ok-bg);   color: var(--ok); }
.tag--warn  { background: var(--warn-bg); color: var(--warn); }
.tag--bad   { background: var(--bad-bg);  color: var(--bad); }
.tag--info  { background: var(--info-bg); color: var(--info); }
.tag--grey  { background: #eef1f6;        color: var(--muted); }

/* ---------- Property cards ------------------------------------------------ */
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.prop {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  padding: 15px 16px; transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.prop:hover { border-color: #c9d3e4; box-shadow: 0 3px 12px rgba(10, 18, 38, .07); transform: translateY(-1px); }
.prop__top { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.prop__top h3 { font-size: 14.5px; }
.prop__top .addr { font-size: 12px; color: var(--muted); }
.prop__badge { margin-left: auto; }
.prop__progs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.prop__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.prop__stats div b { display: block; font-size: 16px; font-weight: 650; line-height: 1.2; }
.prop__stats div span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.prop__stats .alert b { color: var(--accent-d); }

/* ---------- Forms --------------------------------------------------------- */
.form { display: grid; gap: 14px; max-width: 620px; }
.field { display: grid; gap: 5px; }
.field label { font-size: 12px; font-weight: 650; color: var(--text-2); }
.field input, .field select, .field textarea {
  font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 107, 53, .13);
}
.field .hint { font-size: 11.5px; color: var(--muted); }
.field--row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; }
.check input { margin-top: 3px; }

/* ---------- Empty / misc -------------------------------------------------- */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.note {
  background: var(--warn-bg); border: 1px solid #ffdcb0; border-radius: 7px;
  padding: 11px 14px; font-size: 12.5px; color: #7a3a18;
}
.note b { color: var(--accent-d); }

/* ---------- Login ---------------------------------------------------------
   Centred card on a deep field. Restraint is the point: this is a door people
   walk through every morning, not a place to sell to them. One background
   treatment, no pattern overlays, no marketing copy, generous spacing.

   Sized independently of .form / .field / .btn above — that scale is tuned for
   dense tables, and 36px inputs on a sign-in page look unfinished.
   -------------------------------------------------------------------------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  /* 32px, not 40 — at 720px the taller padding pushed the page 2px over and
     produced a scrollbar, which also knocked the card off centre. */
  padding: 32px 24px;
  background: #0a1226;
  position: relative;
  overflow: hidden;
}
/* A single, wide, very soft warm light. Nothing else. */
.login::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 50% -20%, rgba(255, 107, 53, .16), transparent 60%);
  pointer-events: none;
}

.login__box { position: relative; width: 100%; max-width: 424px; }

.login__brand {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  margin-bottom: 26px;
}
.login__brand svg { width: 28px; height: 28px; color: #fff; }
.login__brand span {
  font-size: 20px; font-weight: 700; letter-spacing: -.03em; color: #fff;
}

.login__card {
  background: var(--card);
  border-radius: 12px;
  padding: 40px 40px 32px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18), 0 24px 56px rgba(0, 0, 0, .30);
}

.login__card h1 {
  font-size: 21px; letter-spacing: -.022em; font-weight: 650; margin-bottom: 7px;
}
.login__card .sub { font-size: 13.5px; color: var(--muted); margin: 0 0 30px; }

.login__field { display: grid; gap: 7px; margin-bottom: 20px; }
.login__field label { font-size: 13px; font-weight: 600; color: var(--text); }
.login__field input {
  font: inherit; font-size: 15px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login__field input::placeholder { color: #b3bccb; }
.login__field input:focus {
  outline: 0; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, .15);
}

.login__row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; font-size: 13px; margin: 0 0 26px;
}
.login__row label {
  display: flex; align-items: center; gap: 8px; color: var(--text-2); cursor: pointer;
}
.login__row input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer;
}
.login__row a { color: var(--info); font-weight: 600; }
.login__row a:hover { text-decoration: underline; }

.login__submit {
  width: 100%; padding: 13px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 650; letter-spacing: -.005em;
  transition: background-color .15s ease;
}
.login__submit:hover { background: #f2571d; }
.login__submit:active { background: #e04f18; }

.login__divider {
  border: 0; border-top: 1px solid var(--line-2); margin: 28px 0 18px;
}
.login__help { font-size: 13px; color: var(--muted); text-align: center; margin: 0; }
.login__help a { color: var(--info); font-weight: 600; }
.login__help a:hover { text-decoration: underline; }

/* Deliberately quiet — visible to anyone who reads, invisible as decoration. */
.login__prototype {
  margin: 14px 0 0; text-align: center;
  font-size: 12px; color: #9aa4b5;
}

.login__legal {
  margin: 22px 0 0; text-align: center;
  font-size: 12px; line-height: 1.6; color: #6d7d9c;
}

.login__error {
  margin: 0 0 20px; padding: 11px 13px; border-radius: 8px;
  background: var(--bad-bg); border: 1px solid #f3c6c2;
  font-size: 13px; line-height: 1.5; color: var(--bad);
}
.login__error[hidden] { display: none; }

.login__submit:disabled { opacity: .65; cursor: default; }

/* Dev sign-in — rendered only when the API reports AUTH_DRIVER=dev, so it
   cannot appear in a deployed environment. */
.login__dev {
  margin-top: 22px; padding: 16px; border-radius: 8px;
  background: #f7f9fc; border: 1px solid var(--line);
}
.login__dev-title {
  margin: 0 0 4px; font-size: 12px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}
.login__dev-body { margin: 0 0 12px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.login__dev-users { display: grid; gap: 6px; }
.login__dev-user {
  display: grid; gap: 1px; text-align: left; cursor: pointer;
  padding: 8px 11px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card);
  transition: border-color .14s ease, background-color .14s ease;
}
.login__dev-user:hover { border-color: #c9d3e4; background: #fbfcfe; }
.login__dev-user b { font-size: 13px; font-weight: 600; color: var(--text); }
.login__dev-user span { font-size: 11.5px; color: var(--muted); }

/* Tenant data stays hidden until the session resolves, so nothing flashes
   before we know who is looking. */
body[data-requires-session] .main,
body[data-requires-session] .app { opacity: 0; transition: opacity .12s ease; }
body[data-requires-session].is-ready .main,
body[data-requires-session].is-ready .app { opacity: 1; }

@media (max-width: 480px) {
  .login { padding: 28px 16px; align-content: center; }
  .login__card { padding: 30px 24px 26px; }
}

/* ---------- Admin console -------------------------------------------------
   Visually distinct from the tenant portal on purpose: staff should always be
   able to tell at a glance that they are looking across customers rather than
   inside one.
   -------------------------------------------------------------------------- */
.rail--staff { background: #2a1206; border-right: 2px solid var(--accent); }
.rail--staff .rail__item.is-on { background: rgba(255, 107, 53, .22); }

.admin__drawer > td { background: #fbfcfe; border-bottom: 1px solid var(--line); }
.admin__drawer-inner { padding: 12px 16px 14px 44px; }
.admin__drawer-inner .tbl th { background: transparent; }
.admin__drawer-inner .tbl td,
.admin__drawer-inner .tbl th { padding-left: 0; }

body[data-requires-admin] .app { opacity: 0; transition: opacity .12s ease; }
body[data-requires-admin].is-ready .app { opacity: 1; }

/* ---------- Responsive ---------------------------------------------------- */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .search { display: none; }
}
@media (max-width: 640px) {
  .app { grid-template-columns: 56px 1fr; }
  .rail__item span { display: none; }
  .grid-4 { grid-template-columns: 1fr; }
  .page { padding: 14px 12px 30px; }
  .field--row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
