:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --panel-soft: #eef4f1;
  --text: #17211d;
  --muted: #66736d;
  --line: #d9e1dd;
  --primary: #0d7c66;
  --primary-strong: #095d50;
  --primary-tint: rgba(13, 124, 102, 0.12);
  --primary-tint-strong: rgba(13, 124, 102, 0.16);
  --accent: #b9872f;
  --danger: #b33b31;
  --blue: #2f6690;
  --shadow: 0 16px 48px rgba(31, 45, 40, 0.1);
  --radius: 8px;
  --sidebar: 280px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101614;
  --panel: #18201d;
  --panel-soft: #202c28;
  --text: #edf4f1;
  --muted: #a5b3ad;
  --line: #2e3c37;
  --primary: #38b494;
  --primary-strong: #72d2b8;
  --primary-tint: rgba(56, 180, 148, 0.16);
  --primary-tint-strong: rgba(56, 180, 148, 0.22);
  --accent: #d5a84d;
  --danger: #e06a61;
  --blue: #73a7d1;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: var(--panel);
  border-inline-end: 1px solid var(--line);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

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

.brand-block strong,
.brand-block span {
  display: block;
}

.brand-block span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.module-nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  text-align: start;
}

.nav-button:hover,
.nav-button.active {
  background: var(--panel-soft);
  color: var(--text);
}

.nav-button.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

[dir="rtl"] .nav-button.active {
  box-shadow: inset -3px 0 0 var(--primary);
}

.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--primary-tint);
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 700;
}

.nav-count {
  font-size: 12px;
  color: var(--muted);
}

.role-panel {
  margin-top: auto;
  background: var(--panel-soft);
  border-radius: var(--radius);
  padding: 12px;
}

.role-panel label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px 11px;
}

.main {
  padding: 24px;
  min-width: 0;
}

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

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.top-actions,
.inline-actions,
.card-actions,
.segmented {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button,
.ghost-button,
.primary-button,
.danger-button {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-weight: 700;
}

.primary-button {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.danger-button {
  color: var(--danger);
}

.button-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--primary-tint-strong);
  font-size: 12px;
}

.hero-band {
  min-height: 218px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  align-items: stretch;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.hero-copy span {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.hero-copy h2 {
  margin: 10px 0;
  max-width: 820px;
  font-size: 44px;
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-copy p {
  color: var(--muted);
  max-width: 720px;
  line-height: 1.6;
  margin: 0;
}

.property-visual {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), transparent 42%),
    linear-gradient(135deg, #8fb5c8, #e6c878 58%, #6c8d70);
  border: 1px solid var(--line);
  min-height: 218px;
}

.sun {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #f5c451;
  top: 22px;
  inset-inline-end: 32px;
}

.tower,
.gate {
  position: absolute;
  bottom: 0;
  border: 1px solid rgba(45, 61, 55, 0.18);
  background: rgba(245, 249, 246, 0.9);
}

.tower::before,
.tower::after {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  height: 10px;
  top: 20px;
  background: repeating-linear-gradient(90deg, #6d928c 0 13px, transparent 13px 23px);
  opacity: 0.8;
  box-shadow: 0 28px 0 #6d928c, 0 56px 0 #6d928c, 0 84px 0 #6d928c;
}

.tower-a {
  width: 88px;
  height: 156px;
  inset-inline-start: 34px;
}

.tower-b {
  width: 118px;
  height: 184px;
  inset-inline-start: 112px;
}

.tower-c {
  width: 90px;
  height: 132px;
  inset-inline-start: 218px;
}

.gate {
  width: 190px;
  height: 52px;
  inset-inline-end: 28px;
  background: rgba(20, 45, 40, 0.85);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card,
.panel,
.list-card,
.timeline-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-card {
  padding: 16px;
}

.stat-card strong {
  display: block;
  font-size: 28px;
  margin-top: 8px;
}

.stat-card span,
.muted {
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel + .panel {
  margin-top: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel-title {
  margin: 0;
  font-size: 20px;
}

.panel-subtitle {
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.45;
}

.list {
  display: grid;
  gap: 10px;
}

.list-card {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-start {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar,
.status-dot {
  flex: 0 0 auto;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--panel-soft);
  color: var(--primary-strong);
  font-weight: 800;
}

.title-line {
  margin: 0;
  font-weight: 750;
}

.meta-line {
  color: var(--muted);
  font-size: 13px;
  margin: 3px 0 0;
}

.pill-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
  background: var(--panel-soft);
}

.pill.success {
  color: var(--primary-strong);
}

.pill.warning {
  color: var(--accent);
}

.pill.danger {
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.workflow-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.step {
  border-top: 3px solid var(--line);
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.step.done {
  border-color: var(--primary);
  color: var(--text);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 15, 0.42);
  z-index: 20;
}

.drawer {
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  bottom: 0;
  width: min(560px, 100vw);
  background: var(--panel);
  border-inline-start: 1px solid var(--line);
  z-index: 30;
  padding: 20px;
  overflow-y: auto;
  transform: translateX(105%);
  transition: transform 0.22s ease;
}

[dir="rtl"] .drawer {
  transform: translateX(-105%);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field label {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
  font-size: 13px;
}

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

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  padding: 12px;
}

.toast-stack {
  position: fixed;
  inset-inline-end: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 10px;
}

.toast {
  background: var(--text);
  color: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  max-width: 340px;
}

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

.kanban-column {
  background: var(--panel-soft);
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid var(--line);
  min-height: 220px;
}

.mini-ledger {
  display: grid;
  gap: 8px;
}

.ledger-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

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

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .content-grid,
  .hero-band {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .main,
  .sidebar {
    padding: 14px;
  }

  .topbar,
  .panel-header,
  .row {
    align-items: stretch;
    flex-direction: column;
  }

  .module-nav,
  .stats-grid,
  .kanban,
  .catalog-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .hero-copy h2 {
    font-size: 30px;
  }

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