:root {
  color-scheme: light;
  --ink: #17201a;
  --muted: #65706b;
  --line: #dfe5df;
  --paper: #f7f6f0;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0b4f49;
  --warn: #a15c00;
  --bad: #a33a2c;
  --good: #287a45;
  --blue: #305c92;
  --shadow: 0 18px 45px rgba(28, 43, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell-nav {
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: #fbfbf7;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.eyebrow,
.muted,
.field-hint {
  color: var(--muted);
}

nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 11px 12px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-button.active {
  background: #e8f3ef;
  color: var(--accent-dark);
  font-weight: 700;
}

.workspace {
  padding: 26px min(4vw, 46px) 56px;
  min-width: 0;
}

.topbar,
.dialog-head,
.section-head,
.detail-head,
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.topbar h1,
.dialog-head h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0;
  font-weight: 800;
}

.top-actions,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 38px;
  padding: 9px 13px;
  background: var(--panel);
  color: var(--ink);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.secondary-button {
  background: #eef2ed;
}

.ghost-button {
  width: 100%;
}

.nav-link {
  display: grid;
  place-items: center;
  text-decoration: none;
  margin-top: auto;
}

.danger-button {
  border-color: #f1c1bb;
  color: var(--bad);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-weight: 800;
}

.content {
  display: grid;
  gap: 18px;
}

.metric-grid,
.unit-grid,
.tenant-grid,
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.units-filter-panel {
  display: grid;
  gap: 14px;
}

.property-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf7;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.filter-chip strong {
  min-width: 22px;
  min-height: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #edf1ec;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.filter-chip.active {
  border-color: #8ab7ad;
  background: #e8f3ef;
  color: var(--accent-dark);
}

.filter-chip.active strong {
  background: white;
  color: var(--accent-dark);
}

.metric,
.card,
.panel,
.unit-card,
.tenant-card,
.doc-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1.45rem;
}

.panel {
  padding: 18px;
}

.panel h2,
.section-head h2,
.unit-card h3,
.tenant-card h3,
.doc-card h3 {
  margin: 0;
}

.section-head {
  margin-bottom: 14px;
}

.info-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.info-item {
  padding: 12px;
  background: #f7f9f6;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.info-item span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.unit-card,
.tenant-card,
.doc-card {
  padding: 15px;
  display: grid;
  gap: 12px;
}

.unit-card {
  text-align: left;
}

.unit-card button {
  text-align: left;
}

.badge-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #edf0ed;
  color: #405047;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.good {
  color: var(--good);
  background: #e7f3ea;
}

.badge.warn {
  color: var(--warn);
  background: #fff3dd;
}

.badge.bad {
  color: var(--bad);
  background: #fdecea;
}

.badge.blue {
  color: var(--blue);
  background: #e9f0fa;
}

.detail {
  display: grid;
  gap: 16px;
}

.detail-head {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.detail-title h2 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #46534c;
  background: #f4f6f1;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.status-select {
  min-width: 120px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(13, 20, 16, 0.34);
}

#recordForm {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-top: 16px;
}

.upload-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin: 14px 0 18px;
}

.upload-form .primary-button {
  justify-self: start;
}

label {
  display: grid;
  gap: 6px;
  color: #324039;
  font-weight: 700;
  font-size: 0.88rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8d1;
  border-radius: 7px;
  min-height: 38px;
  padding: 9px 10px;
  background: white;
  color: var(--ink);
}

.property-picker {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(220px, 1.1fr);
  gap: 10px;
  align-items: center;
}

.property-picker input[hidden] {
  display: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.dialog-actions {
  padding: 0;
  margin: 18px 0 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.empty-state {
  padding: 28px;
  border: 1px dashed #bac7bf;
  border-radius: 8px;
  background: #fbfbf7;
  color: var(--muted);
}

@media (max-width: 900px) {
  body {
    display: block;
  }

  .shell-nav {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .ghost-button {
    width: auto;
  }

  .nav-link {
    margin-top: 0;
  }

  .topbar,
  .detail-head,
  .split-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions,
  .button-row {
    justify-content: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .upload-form {
    grid-template-columns: 1fr;
  }

  .property-picker {
    grid-template-columns: 1fr;
  }
}

.login-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(247, 246, 240, 0.9), rgba(247, 246, 240, 0.9)),
    url("https://images.unsplash.com/photo-1583422409516-2895a77efded?auto=format&fit=crop&w=1600&q=80");
  background-size: cover;
  background-position: center;
}

.login-panel {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 16px;
}

.login-brand {
  margin-bottom: 4px;
}

.login-panel h1 {
  margin: 0;
  font-size: 1.8rem;
}

.google-button {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #cfd8d1;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  font-weight: 800;
}

.google-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #1a73e8;
  border: 1px solid #dfe5df;
  font-weight: 900;
}

.login-error {
  padding: 11px 12px;
  border: 1px solid #f1c1bb;
  background: #fdecea;
  color: var(--bad);
  border-radius: 7px;
  font-weight: 700;
}
