:root {
  color-scheme: light;
  --bg: #eff2ef;
  --panel: #fcfcfb;
  --panel-2: #f6f8f4;
  --soft: #e8eee4;
  --line: #dde5da;
  --text: #111512;
  --muted: #757c73;
  --muted-2: #9aa199;
  --accent: #39a900;
  --accent-2: #dff3d5;
  --accent-dark: #247400;
  --accent-ink: #0e3a12;
  --warning: #f3cb00;
  --danger: #c0392b;
  --shadow: 0 18px 42px rgba(25, 32, 28, 0.07);
  --radius: 8px;
  font-family: "Inter", "Aptos", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 260px),
    radial-gradient(circle at top left, rgba(57, 169, 0, 0.1), transparent 30%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  cursor: pointer;
  padding: 0 16px;
  font-weight: 800;
}

button:hover {
  background: #2b302c;
}

button.secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: var(--soft);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 168, 0, 0.12);
}

label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

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

.login-card {
  width: min(960px, 100%);
  min-height: 560px;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  padding: 26px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card::before {
  content: "";
  display: block;
  min-height: 100%;
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(57, 169, 0, 0.96), rgba(35, 116, 0, 0.9)),
    radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.24), transparent 34%);
}

.login-card .brand,
.login-card .login-copy,
.login-card .login-form {
  grid-column: 2;
}

.login-card .brand {
  align-self: end;
}

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

.brand h1 {
  font-size: 30px;
  line-height: 1;
}

.brand p,
.brand small,
.login-copy span,
.topbar p {
  color: var(--muted);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.28), transparent 28%),
    linear-gradient(145deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-weight: 950;
  letter-spacing: 0;
  box-shadow: 0 10px 24px rgba(57, 169, 0, 0.26);
}

.login-copy {
  display: grid;
  gap: 8px;
  align-self: center;
}

.login-copy strong {
  font-size: 36px;
  line-height: 1.05;
}

.login-copy span {
  max-width: 320px;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 14px;
  align-self: start;
}

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

.sidebar {
  min-height: 100vh;
  padding: 18px;
  background: rgba(252, 252, 251, 0.94);
  border-right: 1px solid rgba(223, 229, 220, 0.8);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
}

.brand.compact {
  justify-content: flex-start;
}

.brand.compact .brand-mark {
  width: 48px;
  height: 48px;
}

.brand.compact div {
  display: grid;
  gap: 3px;
}

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

.nav button {
  width: 100%;
  height: 48px;
  min-height: 48px;
  padding: 0 12px;
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: 0 8px 18px rgba(18, 22, 19, 0.035);
  position: relative;
  overflow: hidden;
  font-size: 14px;
  text-align: left;
}

.nav button strong {
  font-size: 14px;
}

.nav button:hover,
.nav button.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.nav button:hover .nav-icon,
.nav button.active .nav-icon {
  background: rgba(255, 255, 255, 0.15);
}

.nav-icon,
.stat-icon,
.alert-icon {
  position: relative;
  width: 30px;
  height: 30px;
  display: block;
  border-radius: 999px;
  background: var(--soft);
  color: currentColor;
  flex: 0 0 auto;
}

.nav-icon::before,
.nav-icon::after,
.stat-icon::before,
.stat-icon::after,
.alert-icon::before,
.alert-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}

.nav-dashboard::before {
  width: 5px;
  height: 5px;
  left: 8px;
  top: 8px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 9px 0 0 currentColor, 0 9px 0 currentColor, 9px 9px 0 currentColor;
}

.nav-condominiums::before {
  width: 15px;
  height: 18px;
  left: 8px;
  top: 6px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.nav-condominiums::after {
  width: 2px;
  height: 2px;
  left: 13px;
  top: 11px;
  background: currentColor;
  box-shadow: 5px 0 0 currentColor, 0 5px 0 currentColor, 5px 5px 0 currentColor;
}

.nav-units::before {
  width: 16px;
  height: 14px;
  left: 7px;
  top: 10px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.nav-units::after {
  width: 10px;
  height: 10px;
  left: 10px;
  top: 5px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
}

.nav-residents::before {
  width: 8px;
  height: 8px;
  left: 11px;
  top: 7px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.nav-residents::after {
  width: 16px;
  height: 8px;
  left: 7px;
  top: 18px;
  border: 2px solid currentColor;
  border-radius: 999px 999px 5px 5px;
}

.nav-devices::before {
  width: 16px;
  height: 20px;
  left: 7px;
  top: 5px;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.nav-devices::after {
  width: 4px;
  height: 4px;
  left: 13px;
  bottom: 7px;
  border-radius: 999px;
  background: currentColor;
}

.nav-logs::before {
  width: 16px;
  height: 2px;
  left: 7px;
  top: 9px;
  background: currentColor;
  box-shadow: 0 6px 0 currentColor, 0 12px 0 currentColor;
}

.nav-settings::before {
  width: 16px;
  height: 16px;
  left: 7px;
  top: 7px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.nav-settings::after {
  width: 6px;
  height: 6px;
  left: 12px;
  top: 12px;
  border-radius: 999px;
  background: currentColor;
}

.sidebar-status {
  margin-top: auto;
  min-height: 52px;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sidebar-status div {
  display: grid;
  gap: 2px;
}

.sidebar-status strong {
  font-size: 13px;
}

.sidebar-status small {
  color: var(--muted);
  font-size: 12px;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(56, 168, 0, 0.14);
}

.sidebar #logoutButton {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  font-size: 13px;
}

.sidebar #logoutButton::after {
  content: "";
}

.content {
  padding: 18px 22px 28px;
  min-width: 0;
}

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

.eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 34px;
  line-height: 1.05;
}

.topbar p {
  margin-top: 5px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  min-width: 210px;
  height: 42px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted-2);
  padding: 0 14px;
}

.message {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid #b7ddce;
  background: #e8f7ef;
  color: #13553b;
}

.error {
  min-height: 18px;
  color: var(--danger);
}

.grid {
  display: grid;
  gap: 14px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.72fr);
  align-items: start;
}

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

.stat,
.panel,
.hero-panel,
.alert-panel {
  background: var(--panel);
  border: 1px solid rgba(223, 229, 220, 0.9);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.stat::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -34px;
  width: 104px;
  height: 104px;
  border-radius: 999px;
  background: rgba(57, 169, 0, 0.08);
  z-index: -1;
}

.stat.featured,
.alert-panel {
  background:
    radial-gradient(circle at 80% 12%, rgba(255, 255, 255, 0.22), transparent 26%),
    linear-gradient(145deg, var(--accent), #2d8f00);
  color: #fff;
  border-color: transparent;
}

.stat-label {
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.stat.featured .stat-label,
.alert-panel p,
.alert-panel small {
  color: rgba(255, 255, 255, 0.78);
}

.stat-icon {
  background: var(--accent-2);
  color: var(--accent-dark);
}

.stat.featured .stat-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.stat-condominiums::before,
.stat-units::before {
  width: 15px;
  height: 16px;
  left: 8px;
  top: 7px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.stat-condominiums::after {
  width: 2px;
  height: 2px;
  left: 13px;
  top: 12px;
  background: currentColor;
  box-shadow: 5px 0 0 currentColor, 0 5px 0 currentColor, 5px 5px 0 currentColor;
}

.stat-units::after {
  width: 10px;
  height: 10px;
  left: 10px;
  top: 5px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
}

.stat-residents::before {
  width: 8px;
  height: 8px;
  left: 11px;
  top: 7px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.stat-residents::after {
  width: 16px;
  height: 8px;
  left: 7px;
  top: 18px;
  border: 2px solid currentColor;
  border-radius: 999px 999px 5px 5px;
}

.stat-devices::before {
  width: 16px;
  height: 20px;
  left: 7px;
  top: 5px;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.stat-devices::after {
  width: 4px;
  height: 4px;
  left: 13px;
  bottom: 7px;
  border-radius: 999px;
  background: currentColor;
}

.stat strong {
  display: block;
  font-size: 42px;
  line-height: 1;
}

.stat em {
  color: var(--muted-2);
  font-size: 12px;
  font-style: normal;
}

.stat.featured em {
  color: rgba(255, 255, 255, 0.72);
}

.hero-panel {
  min-height: 430px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0)),
    var(--panel);
}

.hero-art {
  min-height: 210px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 55% 35%, rgba(57, 169, 0, 0.92), transparent 8%),
    radial-gradient(circle at 50% 55%, #c9e7bd 0 18%, transparent 19%),
    radial-gradient(circle at 42% 60%, #8ccf78 0 10%, transparent 11%),
    radial-gradient(circle at 62% 64%, #6fb654 0 12%, transparent 13%),
    linear-gradient(145deg, #f8faf7, #edf4ea);
  position: relative;
}

.hero-art::before,
.hero-art::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(17, 21, 18, 0.18);
  transform: rotate(30deg) skew(-18deg);
}

.hero-art::before {
  width: 190px;
  height: 118px;
  left: calc(50% - 95px);
  top: 72px;
}

.hero-art::after {
  width: 130px;
  height: 78px;
  left: calc(50% - 65px);
  top: 92px;
}

.hero-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

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

.mini-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

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

.status-card {
  min-height: 150px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.status-card.online {
  border-color: rgba(56, 168, 0, 0.28);
}

.status-card.offline {
  border-color: rgba(192, 57, 43, 0.34);
}

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

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--danger);
}

.status-dot.online {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(56, 168, 0, 0.12);
}

.settings-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
}

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

.settings-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.alert-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.alert-icon {
  width: 38px;
  height: 38px;
  background: #fff;
  color: var(--accent-dark);
}

.alert-database::before {
  width: 18px;
  height: 8px;
  left: 10px;
  top: 9px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.alert-database::after {
  width: 18px;
  height: 12px;
  left: 10px;
  top: 13px;
  border-left: 2px solid currentColor;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-radius: 0 0 999px 999px;
}

.alert-devices::before {
  width: 18px;
  height: 22px;
  left: 10px;
  top: 8px;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.alert-devices::after {
  width: 4px;
  height: 4px;
  left: 17px;
  bottom: 10px;
  border-radius: 999px;
  background: currentColor;
}

.alert-gate::before {
  width: 18px;
  height: 16px;
  left: 10px;
  top: 13px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 3px;
}

.alert-gate::after {
  width: 12px;
  height: 10px;
  left: 13px;
  top: 7px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.alert-state {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 900;
}

.compact-panel {
  padding-bottom: 10px;
}

.compact-table table {
  min-width: 420px;
}

.compact-table th,
.compact-table td {
  padding: 10px 6px;
}

.two-column {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  align-items: start;
}

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

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

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

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

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

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.badge.active,
.badge.success,
.badge.answered,
.badge.online {
  background: #dff5d8;
  color: var(--accent-dark);
}

.badge.ringing {
  background: #fff5c2;
  color: #7a5d00;
}

.badge.inactive,
.badge.failed,
.badge.denied,
.badge.rejected,
.badge.missed,
.badge.offline {
  background: #ffe7e4;
  color: var(--danger);
}

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

@media (max-width: 1120px) {
  .dashboard-grid,
  .stats,
  .two-column,
  .status-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .login-card {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-card::before {
    min-height: 180px;
  }

  .login-card .brand,
  .login-card .login-copy,
  .login-card .login-form {
    grid-column: 1;
  }

  .app-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .nav {
    display: flex;
  }

  .sidebar-status {
    display: none;
  }

  .content {
    padding: 16px;
  }

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

  .topbar-actions,
  .search-box,
  .form-row,
  .hero-metrics {
    width: 100%;
    grid-template-columns: 1fr;
  }
}
