:root {
  --ink: #17201b;
  --muted: #66736c;
  --line: #dce3de;
  --panel: #ffffff;
  --canvas: #f5f7f2;
  --green: #236c4a;
  --green-2: #dff1e5;
  --rust: #b85b3f;
  --amber: #f2b84b;
  --blue: #3b6f92;
  --violet: #7762a8;
  --shadow: 0 18px 50px rgba(29, 42, 35, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.74;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #f2b84b;
  outline-offset: 2px;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  padding: 22px;
}

.auth-brand {
  color: var(--ink);
  margin-bottom: 4px;
}

.auth-brand span {
  color: var(--muted);
}

.login-card .primary-button {
  width: 100%;
}

.login-status {
  min-height: 20px;
  margin: 0;
  color: var(--rust);
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #19231d;
  color: #f4f7f1;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--green-2);
  color: var(--green);
  border-radius: 8px;
  font-weight: 800;
  font-size: 24px;
}

.brand span {
  display: block;
  color: rgba(244, 247, 241, 0.66);
  font-size: 12px;
  margin-top: 2px;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.sidebar .field span {
  color: rgba(244, 247, 241, 0.66);
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field.compact {
  color: #f4f7f1;
}

.field.compact select {
  background: #253229;
  color: #f4f7f1;
  border-color: #3b4a40;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  min-height: 40px;
}

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

.nav {
  display: grid;
  gap: 5px;
}

.nav button {
  width: 100%;
  border: 0;
  background: transparent;
  color: rgba(244, 247, 241, 0.76);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 7px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: #2d3c32;
  color: #ffffff;
}

.nav .nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(244, 247, 241, 0.18);
  border-radius: 6px;
  font-size: 12px;
}

.workspace {
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 40px) 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1,
.modal-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-actions,
.inline-actions,
.table-actions,
.modal-actions,
.filterbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 38px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.danger-button {
  background: #fff2ed;
  color: #9b3d25;
  border-color: #f1c9bd;
}

.icon-button {
  width: 36px;
  padding: 0;
  background: #f7f8f5;
  border-color: var(--line);
  color: var(--ink);
  font-size: 22px;
}

.alerts {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.alert {
  border-left: 4px solid var(--rust);
  background: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border-radius: 6px;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-height: 112px;
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 28px;
  letter-spacing: 0;
}

.metric small {
  color: var(--green);
  font-weight: 800;
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.section-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.section-body {
  padding: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #edf1ee;
  color: #425149;
  white-space: nowrap;
}

.status.paid,
.status.occupied,
.status.closed,
.status.active {
  background: var(--green-2);
  color: var(--green);
}

.status.due,
.status.open {
  background: #fff1cf;
  color: #885d00;
}

.status.overdue,
.status.vacant,
.status.inactive {
  background: #ffe5dc;
  color: #9b3d25;
}

.status.progress {
  background: #e4eef5;
  color: var(--blue);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.unit-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 11px;
}

.unit-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.unit-card h3 {
  margin: 0;
  font-size: 18px;
}

.muted {
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 18px;
}

.progress-stack {
  display: grid;
  gap: 13px;
}

.progress-row {
  display: grid;
  gap: 7px;
}

.progress-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.bar {
  height: 10px;
  background: #e8ede9;
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.filterbar {
  margin-bottom: 12px;
}

.filterbar input,
.filterbar select {
  width: min(260px, 100%);
}

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

dialog::backdrop {
  background: rgba(16, 24, 20, 0.42);
}

#modalForm {
  margin: 0;
}

.modal-head,
.modal-actions {
  padding: 16px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.modal-fields {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  margin: 0;
}

.empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .summary-grid,
  .cards-grid,
  .split {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 20px 14px 34px;
  }

  .primary-button,
  .ghost-button,
  .danger-button,
  .icon-button,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  .icon-button {
    width: 44px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .inline-actions,
  .filterbar {
    width: 100%;
  }

  .topbar-actions button,
  .inline-actions button,
  .filterbar input,
  .filterbar select {
    flex: 1;
  }

  .summary-grid,
  .cards-grid,
  .split,
  .modal-fields {
    grid-template-columns: 1fr;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
