:root {
  /* Palette — pine & jade on sage porcelain */
  --bg: #F3F5F2;
  --surface: #FFFFFF;
  --surface-sunk: #F7F9F6;
  --ink: #16211C;
  --muted: #5E6B64;
  --faint: #8A968F;
  --line: #E2E7E2;
  --line-strong: #D3DAD3;
  --pine: #1F4E46;
  --pine-hover: #183E38;
  --jade: #2E7D6B;
  --jade-soft: #E7F1EC;

  /* Status */
  --ok: #3C8C6E;
  --attention: #C7883B;
  --urgent: #B4472F;
  --idle: #98A29B;

  /* Type */
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Menlo", monospace;

  /* Space + form */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(22, 33, 28, .04), 0 8px 24px rgba(22, 33, 28, .06);
  --shadow-sm: 0 1px 2px rgba(22, 33, 28, .06);
  --sidebar-w: 244px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 500; letter-spacing: -.01em; margin: 0; }
a { color: var(--jade); text-decoration: none; }
button { font-family: inherit; }

/* ---------- Focus + motion floor ---------- */
:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Auth screen ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #E9F1EC 0%, transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  animation: rise .5s ease both;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .mark { width: 34px; height: 34px; border-radius: 9px; }
.auth-brand b { font-family: var(--display); font-size: 18px; font-weight: 600; }
.auth h1 { font-size: 22px; margin-bottom: 4px; }
.auth p.sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--pine);
  color: #DCE8E2;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.sidebar .brand .mark { width: 32px; height: 32px; border-radius: 8px; }
.sidebar .brand b { font-family: var(--display); color: #fff; font-size: 17px; font-weight: 600; }
.sidebar .brand small { display: block; color: #9FBCB1; font-size: 11.5px; font-weight: 500; letter-spacing: .02em; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: #C3D6CD; font-weight: 500; font-size: 14.5px;
  cursor: pointer; transition: background .15s, color .15s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.soon { color: #7EA093; cursor: default; }
.nav-item.soon:hover { background: none; }
.nav-item .ico { width: 17px; height: 17px; flex: none; }
.nav-item .tag { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #7EA093; border: 1px solid #375E54; border-radius: 20px; padding: 1px 7px; }

.sidebar .spacer { flex: 1; }
.user-chip {
  border-top: 1px solid #2C5A50; padding-top: 14px; margin-top: 8px;
  display: flex; align-items: center; gap: 10px;
}
.user-chip .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--jade); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.user-chip .who { line-height: 1.25; min-width: 0; }
.user-chip .who b { color: #fff; font-family: var(--body); font-size: 13.5px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { color: #9FBCB1; font-size: 11.5px; }
.signout { margin-left: auto; background: none; border: none; color: #9FBCB1; cursor: pointer; padding: 6px; border-radius: 6px; }
.signout:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 22px 34px 18px; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.topbar .titles { min-width: 0; }
.topbar .eyebrow { color: var(--faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.topbar h1 { font-size: 24px; margin-top: 1px; }
.topbar .grow { flex: 1; }
.content { padding: 26px 34px 48px; animation: fade .3s ease both; }

.tenant-field { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.tenant-field input { width: 64px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--pine); color: #fff; }
.btn-primary:hover { background: var(--pine-hover); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--faint); }
.btn-quiet { background: none; color: var(--muted); padding: 7px 10px; }
.btn-quiet:hover { color: var(--ink); background: var(--surface-sunk); }
.btn-danger { background: none; color: var(--urgent); border-color: transparent; }
.btn-danger:hover { background: #FBEDE9; }
.btn .ico { width: 16px; height: 16px; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* ---------- Cards + panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.panel { padding: 20px 22px; }
.panel + .panel { border-top: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { font-size: 16.5px; }
.panel-head .grow { flex: 1; }
.panel-head .hint { color: var(--faint); font-size: 12.5px; }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Member list ---------- */
.list-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.search { flex: 1; max-width: 320px; }
.filter-tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 3px; }
.filter-tabs button { border: none; background: none; padding: 5px 13px; border-radius: 16px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.filter-tabs button.on { background: var(--jade-soft); color: var(--pine); }

.member-row {
  display: flex; align-items: center; gap: 15px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background .12s;
}
.member-row:last-child { border-bottom: none; }
.member-row:hover { background: var(--surface-sunk); }
.member-row .name { font-weight: 600; font-size: 15px; }
.member-row .meta { color: var(--muted); font-size: 13px; }
.member-row .phone { font-family: var(--mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.member-row .grow { flex: 1; min-width: 0; }
.chev { color: var(--faint); width: 18px; height: 18px; flex: none; }

/* ---------- Presence dot (signature) ---------- */
.presence { position: relative; width: 12px; height: 12px; flex: none; }
.presence i { position: absolute; inset: 0; border-radius: 50%; background: var(--idle); box-shadow: 0 0 0 4px color-mix(in srgb, var(--idle) 22%, transparent); }
.presence.active i { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.presence.paused i { background: var(--attention); box-shadow: 0 0 0 4px color-mix(in srgb, var(--attention) 20%, transparent); }
.presence.inactive i { background: var(--idle); box-shadow: 0 0 0 4px color-mix(in srgb, var(--idle) 18%, transparent); }
.presence.lg { width: 14px; height: 14px; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
label.field .req { color: var(--urgent); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=time], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--jade); box-shadow: 0 0 0 3px var(--jade-soft); }
textarea { resize: vertical; min-height: 66px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.check input { width: auto; }
.form-error { color: var(--urgent); font-size: 12.5px; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- Detail bits ---------- */
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.detail-head .avatar-lg { width: 46px; height: 46px; border-radius: 50%; background: var(--jade-soft); color: var(--pine); display: grid; place-items: center; font-family: var(--display); font-weight: 600; font-size: 19px; }
.detail-head h1 { font-size: 25px; }
.kv { display: flex; gap: 8px; font-size: 14px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); width: 116px; flex: none; }
.kv .v { color: var(--ink); font-weight: 500; }
.kv .v.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.contact-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.contact-row:last-child { border-bottom: none; }
.contact-row .grow { flex: 1; min-width: 0; }
.contact-row .cname { font-weight: 600; font-size: 14px; }
.contact-row .cmeta { color: var(--muted); font-size: 12.5px; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--jade-soft); color: var(--pine); margin-left: 6px; }

.slot-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.slot-row select { max-width: 150px; }
.slot-row input[type=time] { max-width: 130px; }

/* ---------- Empty + banners ---------- */
.empty { text-align: center; padding: 54px 24px; color: var(--muted); }
.empty .art { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--faint); }
.empty h3 { font-size: 18px; color: var(--ink); margin-bottom: 6px; }
.empty p { max-width: 340px; margin: 0 auto 18px; }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 15px; border-radius: var(--radius-sm); font-size: 13.5px; }
.banner.soon { background: #FBF4E7; color: #7A5A1E; border: 1px solid #EBDABc; }
.banner .ico { width: 17px; height: 17px; flex: none; margin-top: 1px; }

/* ---------- Modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(22,33,28,.34); display: grid; place-items: center; padding: 20px; z-index: 40; animation: fade .2s ease; }
.modal { width: 100%; max-width: 460px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); animation: rise .28s ease both; max-height: 90vh; overflow: auto; }
.modal header { padding: 20px 22px 0; }
.modal header h2 { font-size: 19px; }
.modal header p { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
.modal .body { padding: 18px 22px 22px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 11px 15px; border-radius: var(--radius-sm); font-size: 13.5px; box-shadow: var(--shadow); animation: rise .25s ease both; max-width: 320px; }
.toast.err { background: var(--urgent); }
.toast.ok { background: var(--ok); }

/* ---------- Utility ---------- */
.muted { color: var(--muted); }
.spin { width: 22px; height: 22px; border: 2.5px solid var(--line-strong); border-top-color: var(--pine); border-radius: 50%; animation: rot .7s linear infinite; margin: 40px auto; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; }
  .sidebar .brand { padding: 6px 8px; }
  .sidebar .spacer, .nav-item .tag { display: none; }
  .sidebar .nav-item { width: auto; }
  .user-chip { border: none; margin: 0 0 0 auto; padding: 0; }
  .user-chip .who { display: none; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .field-row { grid-template-columns: 1fr; }
}
