/* ═══════════════════════════════════════════════════════════════════════════
   Wolf Realty Management — design system
   Shared by the staff app and the tenant / owner / vendor portals.
   Typography: Fraunces (display serif) + Inter (UI). Palette: deep navy,
   warm paper, muted brass. Loaded via <link> in each page head.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --navy: #16233d;
  --navy-2: #1e2f52;
  --navy-dark: #101a2e;
  --brass: #b8963c;
  --brass-soft: #d9c088;
  --paper: #f6f5f1;
  --card: #ffffff;
  --ink: #20293a;
  --muted: #6b7280;
  --line: #e5e2d9;
  --line-strong: #cfcabb;
  --green: #237a4b;
  --green-bg: #e5f2ea;
  --red: #a83a32;
  --red-bg: #f8e8e6;
  --amber: #9a6b0a;
  --amber-bg: #f8efd8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(22, 35, 61, .05), 0 4px 16px rgba(22, 35, 61, .05);
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--paper); color: var(--ink);
  font-size: 14.5px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-2); }
h1, h2, h3 { line-height: 1.25; }

/* ── Brand marks ───────────────────────────────────────── */
.wa-mark { display: inline-flex; align-items: center; gap: 11px; }
.wa-mark svg { flex-shrink: 0; }
.wa-wordmark { font-family: var(--font-display); font-weight: 600; letter-spacing: .01em; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: .01em; }
.brand-sub { font-size: 10.5px; color: var(--brass-soft); letter-spacing: .22em; text-transform: uppercase; margin-top: 3px; font-weight: 500; }

/* ── App shell (staff) ─────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px; flex-shrink: 0; color: #fff;
  background: linear-gradient(175deg, var(--navy) 0%, var(--navy-dark) 100%);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav .nav-sect { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: rgba(255,255,255,.38); padding: 16px 20px 5px; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; color: #c3cbdb;
  padding: 9.5px 20px; font: inherit; font-size: 13.5px; cursor: pointer;
  border-left: 3px solid transparent; transition: background .12s, color .12s;
}
.nav button:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav button.active { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--brass); font-weight: 600; }
.sidebar .foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12.5px; color: #9aa6ba; }
.sidebar .foot a { color: var(--brass-soft); cursor: pointer; text-decoration: underline; }

.main { flex: 1; padding: 30px 36px 70px; max-width: 1240px; }
.page-title { font-family: var(--font-display); font-weight: 600; font-size: 26px; margin: 0 0 4px; color: var(--navy); }
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 13.5px; }

/* ── Cards / grids ─────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) {
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .main { padding: 20px; }
  .sidebar { width: 200px; }
}

/* Phone layout: the sidebar becomes a top app bar with swipeable tabs, so the
   staff office works one-handed as an installed home-screen app. */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { position: sticky; top: 0; z-index: 20; width: 100%; height: auto; }
  .sidebar .brand { padding: 12px 16px 10px; display: flex; align-items: center; justify-content: space-between; border-bottom: none; }
  .sidebar .brand .wa-mark svg { width: 28px; height: 28px; }
  .sidebar .brand .brand-name { font-size: 14px; }
  .nav {
    display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 0 8px; border-top: 1px solid rgba(255,255,255,.1); flex: none;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav .nav-sect { display: none; }
  .nav button {
    width: auto; white-space: nowrap; padding: 11px 13px; font-size: 13px;
    border-left: none; border-bottom: 3px solid transparent;
  }
  .nav button.active { border-left: none; border-bottom-color: var(--brass); background: none; }
  .sidebar .foot { display: flex; align-items: center; gap: 12px; padding: 7px 16px; font-size: 11.5px; border-top: 1px solid rgba(255,255,255,.1); }
  .sidebar .foot div { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 16px 14px 50px; }
  .page-title { font-size: 21px; }
  .toolbar .btn { flex-shrink: 0; }
  .modal { padding: 18px 16px; }
  .detail-grid { grid-template-columns: 120px 1fr; }
  .tenant-main { padding: 20px 14px 50px; }
  .tabs button { padding: 8px 11px; font-size: 13px; }
}

.stat .num { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--navy); }
.stat .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-top: 2px; }
.stat.warn .num { color: var(--red); }
.stat.good .num { color: var(--green); }

/* ── Tables ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line-strong);
}
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #faf9f6; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--red); font-weight: 600; }
.neg { color: var(--green); }
.zero { color: var(--muted); }

/* ── Forms / buttons ───────────────────────────────────── */
label.f { display: block; margin-bottom: 13px; font-size: 13px; color: var(--muted); }
label.f span { display: block; margin-bottom: 5px; font-weight: 600; color: var(--ink); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=month], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 8.5px 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  font: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(30,47,82,.22); border-color: var(--navy-2); }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--ink); margin: 9px 0; }
.check input { width: auto; }

.btn {
  display: inline-block; background: var(--navy); color: #fff; border: none; border-radius: 8px;
  padding: 9px 17px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  text-decoration: none; letter-spacing: .01em; transition: background .12s;
}
.btn:hover { background: var(--navy-2); }
.btn.gold { background: var(--brass); color: #fff; }
.btn.gold:hover { background: #a5852f; }
.btn.ghost { background: none; color: var(--navy); border: 1px solid var(--line-strong); font-weight: 500; }
.btn.ghost:hover { border-color: var(--navy); background: #fff; }
.btn.danger { background: var(--red); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row-actions { white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 4px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ── Badges ────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2.5px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.gray { background: #ece9e0; color: var(--muted); }
.badge.navy { background: #e5eaf4; color: var(--navy-2); }
.badge.brass { background: #f3ead3; color: #7d651f; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; background: rgba(16,26,46,.6); display: flex;
  align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 40; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 640px;
  padding: 24px 26px; box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.modal h2 { margin: 0 0 18px; font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--navy); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.hidden { display: none !important; }

/* ── Toast ─────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy-dark); color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: 13.5px; box-shadow: 0 8px 30px rgba(0,0,0,.35); z-index: 60; max-width: 90vw;
}
#toast.err { background: var(--red); }

/* ── Login pages (split panel) ─────────────────────────── */
.login-body {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-split {
  display: flex; width: 100%; max-width: 880px; min-height: 520px;
  border-radius: 18px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.login-brand {
  flex: 1; background: linear-gradient(200deg, var(--navy-2), var(--navy-dark));
  color: #fff; padding: 48px 44px; display: flex; flex-direction: column; justify-content: space-between;
  border-right: 1px solid rgba(255,255,255,.06);
}
.login-brand .tagline { font-family: var(--font-display); font-size: 24px; font-weight: 500; line-height: 1.35; color: #e8e4d8; }
.login-brand .fine { font-size: 12.5px; color: #93a0b6; line-height: 1.6; }
.login-form-panel { flex: 1; background: #fff; padding: 48px 44px; display: flex; flex-direction: column; justify-content: center; }
.login-form-panel h1 { font-family: var(--font-display); font-size: 21px; font-weight: 600; color: var(--navy); margin: 0 0 22px; }
.login-err { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0; }
@media (max-width: 760px) { .login-brand { display: none; } .login-split { max-width: 420px; min-height: 0; } }

/* Legacy single-card login (kept for compatibility) */
.login-card { background: #fff; border-radius: 16px; padding: 36px 38px; width: 100%; max-width: 410px; box-shadow: 0 24px 70px rgba(0,0,0,.4); }
.login-card .brand-name { color: var(--navy); font-size: 19px; }
.login-card .brand-sub { color: var(--brass); }
.login-card h1 { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin: 22px 0 16px; color: var(--navy); }

/* ── Portal header (tenant / owner / vendor) ───────────── */
.tenant-head {
  background: linear-gradient(170deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff; padding: 18px 0; border-bottom: 3px solid var(--brass);
}
.tenant-head .inner { max-width: 960px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 14px; }
.tenant-head .spacer { flex: 1; }
.tenant-head a { color: var(--brass-soft); cursor: pointer; font-size: 13.5px; text-decoration: none; }
.tenant-head a:hover { text-decoration: underline; }
.tenant-main { max-width: 960px; margin: 0 auto; padding: 28px 20px 70px; }

/* Portal tab bar */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line-strong); margin-bottom: 20px; flex-wrap: wrap; }
.tabs button {
  background: none; border: none; font: inherit; font-size: 14px; padding: 9px 16px; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; font-weight: 500;
}
.tabs button:hover { color: var(--navy); }
.tabs button.active { color: var(--navy); border-bottom-color: var(--brass); font-weight: 600; }

/* ── Misc ──────────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.detail-grid { display: grid; grid-template-columns: 158px 1fr; gap: 5px 14px; font-size: 13.5px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; }
.clickable { cursor: pointer; }
.notice-type-desc { font-size: 12.5px; color: var(--muted); margin: 4px 0 12px; }
pre.log-body { white-space: pre-wrap; font: 12px/1.5 ui-monospace, monospace; background: #f8f7f3; border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 200px; overflow-y: auto; }

/* Document list rows */
.doc-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.doc-row:last-child { border-bottom: none; }
.doc-row .doc-ico { width: 34px; height: 34px; border-radius: 8px; background: #eef0f5; color: var(--navy-2); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.doc-row .doc-name { font-weight: 600; }
.doc-row .doc-meta { color: var(--muted); font-size: 12px; }
.doc-row .spacer { flex: 1; }

/* Announcement rows */
.ann-row { border-bottom: 1px solid var(--line); padding: 12px 0; }
.ann-row:last-child { border-bottom: none; }

/* Timeline dots for work-order status */
.wo-status { display: inline-flex; align-items: center; gap: 6px; }
.wo-status::before { content: ''; width: 8px; height: 8px; border-radius: 99px; background: var(--muted); }
.wo-status.open::before { background: var(--amber); }
.wo-status.bidding::before { background: var(--brass); }
.wo-status.assigned::before, .wo-status.in_progress::before { background: var(--navy-2); }
.wo-status.completed::before, .wo-status.closed::before { background: var(--green); }
.wo-status.cancelled::before { background: var(--red); }
