:root {
  color-scheme: light;
  --ink: #15221d;
  --muted: #65716c;
  --line: #dce3df;
  --paper: #ffffff;
  --canvas: #f4f6f4;
  --accent: #245f47;
  --accent-soft: #e7f0eb;
  --danger: #973d3d;
  --warning: #8a5a13;
  --shadow: 0 10px 30px rgba(24, 45, 36, 0.07);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button, .button { min-height: 42px; border: 0; border-radius: 9px; padding: 10px 15px; color: white; background: var(--accent); cursor: pointer; font-weight: 650; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
button.secondary, .button.secondary { color: var(--ink); background: #edf1ee; border: 1px solid var(--line); }
button.ghost { color: var(--accent); background: transparent; border: 1px solid var(--line); }
button.danger { background: var(--danger); }
button:disabled { opacity: .52; cursor: not-allowed; }
a { color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.55rem, 4vw, 2.1rem); letter-spacing: -.03em; margin-bottom: 5px; }
h2 { font-size: 1.15rem; letter-spacing: -.015em; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .09em; font-size: .73rem; font-weight: 800; margin-bottom: 6px; }
.centered { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 440px) minmax(340px, 1fr); }
.auth-panel { display: flex; align-items: center; padding: clamp(28px, 7vw, 80px); background: var(--paper); }
.auth-copy { padding: clamp(30px, 7vw, 90px); display: flex; flex-direction: column; justify-content: flex-end; background: #1d4d3a; color: white; }
.auth-copy .muted { color: #c9dbd1; }
.auth-form { width: 100%; max-width: 390px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--accent); color: white; font-weight: 900; margin-bottom: 26px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { background: #173e30; color: white; padding: 22px 16px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.sidebar .logo { display: flex; align-items: center; gap: 11px; font-weight: 800; padding: 0 8px 22px; }
.sidebar .brand-mark { width: 34px; height: 34px; margin: 0; background: #f3f6f4; color: #173e30; border-radius: 9px; }
.nav { display: grid; gap: 3px; }
.nav a { color: #d8e5de; text-decoration: none; padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.nav a:hover, .nav a.active { color: white; background: rgba(255,255,255,.11); }
.sidebar-foot { margin-top: auto; padding: 18px 8px 0; border-top: 1px solid rgba(255,255,255,.13); }
.sidebar-foot button { width: 100%; color: white; border-color: rgba(255,255,255,.2); margin-top: 10px; }
.workspace { min-width: 0; }
.topbar { min-height: 68px; padding: 14px clamp(18px, 4vw, 46px); background: rgba(255,255,255,.88); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 15px; position: sticky; top: 0; z-index: 4; backdrop-filter: blur(10px); }
.maintenance-banner { padding: 12px clamp(18px, 4vw, 46px); background: #fff1d8; border-bottom: 1px solid #e8c788; color: #6d4308; position: sticky; top: 68px; z-index: 3; }
.mobile-menu { display: none; }
.role-chip, .status { border-radius: 999px; padding: 4px 9px; font-weight: 700; font-size: .75rem; background: var(--accent-soft); color: var(--accent); display: inline-block; }
.status.sold { background: #ecebea; color: #565c59; }
.status.ambiguous { background: #fff1d8; color: var(--warning); }
.content { padding: clamp(22px, 4vw, 46px); max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 26px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.grid { display: grid; gap: 18px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.two-col { grid-template-columns: minmax(0, 1.5fr) minmax(280px, .75fr); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 13px; padding: 19px; box-shadow: var(--shadow); min-width: 0; }
.metric .label { color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.metric .value { font-size: 1.65rem; font-weight: 800; letter-spacing: -.03em; margin-top: 9px; }
.metric .detail { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.card-head { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); }
table { width: 100%; border-collapse: collapse; min-width: 670px; }
th, td { text-align: left; padding: 12px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; background: #f8faf8; }
tbody tr:last-child td { border-bottom: 0; }
td.actions { display: flex; gap: 6px; }
td.actions button { min-height: 34px; padding: 6px 10px; font-size: .82rem; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

.filters { display: grid; grid-template-columns: minmax(180px, 1fr) 180px 180px auto; gap: 10px; margin-bottom: 16px; }
label { display: grid; gap: 6px; color: #425049; font-weight: 650; font-size: .85rem; }
input, select, textarea { width: 100%; border: 1px solid #cdd7d1; border-radius: 8px; min-height: 42px; padding: 9px 11px; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(36,95,71,.13); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 19px; }
.notice { border-left: 4px solid var(--accent); padding: 12px 14px; background: var(--accent-soft); border-radius: 0 8px 8px 0; margin-bottom: 17px; }
.notice.warning { border-color: #c17a18; background: #fff6e6; }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.inline-form label { flex: 1 1 180px; }
.stack { display: grid; gap: 14px; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.detail-list div { padding: 11px 0; border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--muted); font-size: .78rem; }
.detail-list dd { margin: 3px 0 0; font-weight: 700; }
.toast { position: fixed; right: 22px; bottom: 22px; padding: 12px 16px; background: #193d30; color: white; border-radius: 9px; box-shadow: var(--shadow); transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s ease; z-index: 20; max-width: 360px; }
.toast.show { transform: none; opacity: 1; }
.toast.error { background: var(--danger); }

@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-copy { display: none; }
  .shell { display: block; }
  .sidebar { display: none; position: fixed; inset: 0 auto 0 0; z-index: 10; width: 250px; }
  .shell.menu-open .sidebar { display: flex; }
  .mobile-menu { display: inline-flex; min-height: 38px; padding: 7px 11px; }
  .topbar { padding: 12px 16px; }
  .topbar .user-name { display: none; }
  .content { padding: 22px 15px 40px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-actions > * { flex: 1; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 15px; }
  .metric .value { font-size: 1.35rem; }
  .form-grid, .detail-list { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .filters { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .metrics { grid-template-columns: 1fr; }
}
