/* SG Residence app (agent workspace + admin). Same palette as the website. */
:root {
  --wall: #eef2ef; --paper: #ffffff; --ink: #1d2a2a; --muted: #566563;
  --green: #2c6a5c; --green-deep: #1f4f45; --plate: #f2c14e; --line: #d3dcd8;
  --soft: #f6f8f7; --warn-bg: #fff4d6; --warn-ink: #5a4300; --bad-bg: #fde8e4; --bad-ink: #8a2414;
  --ok-bg: #e2f2ec; --ok-ink: #1f4f45; --focus: #b8860b; --on-green: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --wall: #142120; --paper: #1b2a29; --ink: #e6eeeb; --muted: #a3b3b0; --green: #6fbfa9; --green-deep: #8fd3c0;
    --plate: #e9b949; --line: #2e4140; --soft: #172625; --warn-bg: #3b3115; --warn-ink: #f5d98b; --bad-bg: #3d1f1a;
    --bad-ink: #f3b0a3; --ok-bg: #1f3b34; --ok-ink: #a6e0cf; --focus: #f2c14e; --on-green: #0f1d1b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --wall: #142120; --paper: #1b2a29; --ink: #e6eeeb; --muted: #a3b3b0; --green: #6fbfa9; --green-deep: #8fd3c0;
  --plate: #e9b949; --line: #2e4140; --soft: #172625; --warn-bg: #3b3115; --warn-ink: #f5d98b; --bad-bg: #3d1f1a;
  --bad-ink: #f3b0a3; --ok-bg: #1f3b34; --ok-ink: #a6e0cf; --focus: #f2c14e; --on-green: #0f1d1b; color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--wall); color: var(--ink); font-family: "Archivo", system-ui, sans-serif; font-size: 1rem; line-height: 1.5; }
a { color: var(--green-deep); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--paper); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-stretch: 112%; font-size: 1.05rem; color: var(--ink); text-decoration: none; padding: 4px 8px 18px; }
.brand-plate { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; background: var(--plate); color: #1d2a2a; font-size: .85rem; font-weight: 800; }
.side a.nav { display: block; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
.side a.nav:hover { background: var(--soft); }
.side a.nav[aria-current="page"] { background: var(--ok-bg); color: var(--ok-ink); font-weight: 700; }
.side .nav-group { margin: 14px 10px 4px; font-size: .8rem; color: var(--muted); }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: .9rem; color: var(--muted); }
.side .me img { width: 28px; height: 28px; border-radius: 50%; vertical-align: middle; margin-right: 8px; }
.main { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1100px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
h1 { font-weight: 800; font-stretch: 112%; font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.1; margin: 0; }
h2 { font-size: 1.2rem; margin: 0 0 6px; }
h3 { font-size: 1.02rem; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }

/* Panels */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 22px; margin-bottom: 18px; }
.panel > .sub:first-child { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .legend { font-weight: 600; font-size: .95rem; }
.hint { color: var(--muted); font-size: .88rem; margin: 0; }
input[type=text], input[type=email], input[type=number], input[type=time], input[type=date], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; min-height: 320px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--green); }
.choices { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.err { color: var(--bad-ink); font-size: .9rem; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--green); color: var(--on-green); }
.btn-primary:hover { background: var(--green-deep); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { background: var(--soft); }
.btn-danger { background: transparent; color: var(--bad-ink); border-color: currentColor; }
.btn-small { min-height: 32px; padding: 0 12px; font-size: .88rem; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--green-deep); text-decoration: underline; cursor: pointer; }

/* Flash */
.flash { border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash.warn { background: var(--warn-bg); color: var(--warn-ink); }
.flash.bad { background: var(--bad-bg); color: var(--bad-ink); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.badge.pending { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.badge.approved, .badge.active, .badge.on { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.badge.rejected, .badge.suspended { background: var(--bad-bg); color: var(--bad-ink); border-color: transparent; }

/* Setup checklist (a real sequence, so it's numbered) */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 6px; background: var(--plate); color: #1d2a2a; font-weight: 800; }
.steps li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok-ink); }
.steps li.locked { opacity: .65; }
.steps p { margin: 0; color: var(--muted); font-size: .93rem; }

/* Live switch */
.live { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.live strong { font-size: 1.1rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-right: 8px; }
.dot.on { background: #2fa36b; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
td .muted { color: var(--muted); font-size: .9rem; }
.table-wrap { overflow-x: auto; }

/* Questions list */
.qlist { list-style: none; margin: 0; padding: 0; }
.qlist li { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.qlist form.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.qlist .flag { grid-column: 1 / -1; background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 8px 10px; font-size: .88rem; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .92rem; }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.locked-rules { background: var(--soft); border: 1px dashed var(--line); border-radius: 12px; padding: 16px 18px; }
.locked-rules ul { margin: 6px 0 0; padding-left: 1.1em; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* Login */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 32px; width: min(420px, 100%); }
.google-btn { width: 100%; min-height: 48px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.google-btn:hover { background: var(--soft); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; gap: 2px; }
  .brand { padding: 4px 8px; width: 100%; }
  .side .nav-group { display: none; }
  .side .me { margin: 0; border: 0; padding: 4px 8px; width: 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .steps li { grid-template-columns: 40px 1fr; }
  .steps li > :last-child { grid-column: 2; }
}
