:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-strong: #f0f4ef;
  --ink: #17211e;
  --muted: #66726d;
  --line: #dbe2dd;
  --brand: #0f5b4f;
  --brand-strong: #0a3d36;
  --accent: #cb5a3d;
  --warning: #9a6a00;
  --danger: #a73535;
  --ok: #22764f;
  --shadow: 0 20px 50px rgba(23, 33, 30, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.identity-row,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar {
  min-height: 72px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand img {
  width: 136px;
  max-width: 38vw;
  height: auto;
  flex: 0 0 auto;
}

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

h1 {
  font-size: 1.25rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.2;
}

h3 {
  font-size: 1.15rem;
  line-height: 1.2;
}

p {
  color: var(--muted);
  line-height: 1.45;
}

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

.pill,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.pill.online,
.chip.enabled {
  border-color: rgba(34, 118, 79, 0.24);
  background: rgba(34, 118, 79, 0.1);
  color: var(--ok);
}

.pill.error,
.chip.disabled {
  border-color: rgba(167, 53, 53, 0.24);
  background: rgba(167, 53, 53, 0.08);
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.login-card,
.notice,
.action-card,
.admin-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
  min-height: 180px;
  padding: 34px;
}

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

.google-button {
  min-width: 250px;
}

.notice {
  margin-bottom: 18px;
  padding: 18px 20px;
  color: var(--danger);
}

.identity-row {
  margin-bottom: 22px;
}

.identity-row > div:first-child {
  min-width: 0;
}

#user-email {
  overflow-wrap: anywhere;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.nav-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.nav-button.active {
  border-color: rgba(15, 91, 79, 0.28);
  background: rgba(15, 91, 79, 0.1);
  color: var(--brand);
}

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

.action-card {
  display: grid;
  gap: 26px;
  min-height: 260px;
  padding: 24px;
}

.action-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.action-heading p {
  min-height: 44px;
  margin-top: 6px;
}

.action-icon {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--brand);
  flex: 0 0 auto;
}

.action-icon svg,
.icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}

.primary-button {
  width: 100%;
  align-self: end;
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover:not(:disabled) {
  background: var(--brand-strong);
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.48;
}

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 650;
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--brand);
}

.compact {
  width: auto;
  min-height: 40px;
  padding: 0 14px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-height: 42px;
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.door-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-self: end;
}

.admin-section {
  margin-top: 26px;
  padding: 22px;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin: 22px 0;
}

.logs-filter {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(110px, 0.6fr) auto;
  align-items: end;
  gap: 12px;
  margin: 22px 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
}

input:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 91, 79, 0.25);
  outline-offset: 2px;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--surface);
}

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

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

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

.user-cell {
  display: grid;
  gap: 3px;
}

.user-cell strong,
.user-cell span {
  overflow-wrap: anywhere;
}

.logs-table {
  min-width: 900px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-badge.ok {
  background: rgba(34, 118, 79, 0.1);
  color: var(--ok);
}

.status-badge.error {
  background: rgba(167, 53, 53, 0.08);
  color: var(--danger);
}

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

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 46px;
  height: 26px;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #cfd8d2;
  transition: background 0.15s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(23, 33, 30, 0.28);
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(15, 91, 79, 0.24);
  border-radius: 8px;
  padding: 14px 16px;
  background: #112a26;
  color: #ffffff;
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast.error {
  border-color: rgba(167, 53, 53, 0.35);
  background: #3f1616;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 1120px);
    padding-top: 14px;
  }

  .topbar,
  .identity-row,
  .section-heading {
    align-items: flex-start;
  }

  .topbar,
  .identity-row {
    flex-direction: column;
  }

  .session-actions {
    width: 100%;
    justify-content: space-between;
  }

  .login-card,
  .actions-grid,
  .user-form,
  .logs-filter {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 24px;
  }

  .google-button {
    min-width: 0;
  }

  .chips {
    justify-content: flex-start;
  }

  .action-card {
    min-height: 235px;
  }

  .section-heading {
    flex-direction: column;
  }

  .section-heading .secondary-button {
    width: 100%;
  }
}
