:root {
  --primary: #0f766e;
  --secondary: #2563eb;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --danger: #b42318;
  --ok: #047857;
  --warn: #b45309;
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.login-screen {
  align-items: center;
  background: #edf4f2;
  display: flex;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.12);
  display: grid;
  gap: 24px;
  margin: 0 auto;
  max-width: 460px;
  padding: 28px;
  width: 100%;
}

.login-logo-area {
  align-items: center;
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.login-logo-area span {
  color: var(--muted);
  font-weight: 700;
}

.login-logo {
  height: auto;
  max-width: 320px;
  width: 100%;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-message {
  color: var(--muted);
  margin: 0;
  min-height: 20px;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--primary);
  padding: 4px;
  text-align: center;
}

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

body.public-page .app-shell {
  grid-template-columns: 1fr;
}

body.public-page .sidebar {
  display: none;
}

body.public-page .topbar {
  display: none;
}

.sidebar {
  background: #101828;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
}

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

.brand-mark {
  align-items: center;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  font-weight: 800;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.admin-logo {
  background: #fff;
  border-radius: 8px;
  height: 54px;
  object-fit: contain;
  padding: 6px;
  width: 54px;
}

.brand span, .tenant-switcher label {
  color: #cbd5e1;
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

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

.nav-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #e5e7eb;
  padding: 11px 12px;
  text-align: left;
}

.nav-item.active, .nav-item:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.14);
}

.tenant-switcher {
  margin-top: auto;
}

.tenant-switcher select {
  background: #1f2937;
  border: 1px solid #344054;
  border-radius: 8px;
  color: #fff;
  margin-top: 8px;
  padding: 10px;
  width: 100%;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 22px 28px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  font-size: 28px;
  margin-bottom: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

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

.primary-button, .secondary-button, .icon-button {
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  padding: 10px 14px;
  text-decoration: none;
}

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

.danger-button {
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: var(--danger);
  font-weight: 700;
  justify-content: center;
  margin-top: 20px;
  padding: 11px 14px;
  width: 100%;
}

.danger-button:disabled {
  background: #f2f4f7;
  border-color: var(--line);
  color: var(--muted);
  cursor: default;
}

.secondary-button, .icon-button {
  background: #eaf0f6;
  color: var(--text);
}

.view {
  display: none;
  padding: 28px;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.metric, .panel, .tracking-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

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

.metric strong {
  display: block;
  font-size: 32px;
  margin-top: 8px;
}

.content-grid, .workbench {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(260px, 360px) 1fr;
  margin-top: 18px;
}

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

.panel {
  padding: 18px;
}

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

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

.settings-panel {
  margin: 0 auto;
  max-width: 820px;
}

.logo-upload-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: 88px 1fr;
  padding: 12px;
}

.settings-logo-preview {
  align-items: center;
  background: #f2f4f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 700;
  height: 76px;
  justify-content: center;
  object-fit: contain;
  padding: 8px;
  width: 76px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 6px;
}

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

textarea {
  resize: vertical;
}

.checkbox-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.checkbox-row input {
  width: auto;
}

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

table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

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

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

.list-item {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.list-item[data-open-waitlist] {
  cursor: pointer;
}

.list-item[data-open-waitlist]:hover {
  border-color: var(--primary);
}

.list-item small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
}

.status.ok { background: #dcfce7; color: var(--ok); }
.status.warn { background: #fef3c7; color: var(--warn); }
.status.danger { background: #fee2e2; color: var(--danger); }
.status.neutral { background: #eaf0f6; color: var(--muted); }

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button, .row-actions a {
  background: #edf2f7;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  padding: 7px 9px;
  text-decoration: none;
}

.qr-panel {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-top: 18px;
}

.qr-panel img {
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 164px;
  width: 164px;
}

.invite-box {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
}

.invite-box p {
  white-space: pre-line;
}

.invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.public-tracking {
  padding: 28px;
}

.tracking-card {
  margin: 0 auto;
  max-width: 520px;
  padding: 28px;
  text-align: center;
}

.tracking-logo-wrap {
  align-items: center;
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.tracking-logo,
.tracking-logo-fallback {
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 210px;
  width: 210px;
}

.tracking-logo {
  object-fit: contain;
  padding: 8px;
}

.tracking-logo-fallback {
  align-items: center;
  background: #f2f4f7;
  color: var(--primary);
  display: flex;
  font-size: 56px;
  font-weight: 800;
  justify-content: center;
}

.tracking-title {
  color: var(--primary);
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.tracking-client {
  color: var(--muted);
  margin: 8px 0 0;
}

.public-signup-card {
  display: grid;
  gap: 12px;
  text-align: left;
}

.public-signup-card .tracking-logo-wrap,
.public-signup-card .tracking-title,
.public-signup-card h2 {
  text-align: center;
}

.public-signup-card .primary-button {
  margin-top: 8px;
}

.position-badge {
  align-items: center;
  background: var(--primary);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 44px;
  font-weight: 800;
  height: 112px;
  justify-content: center;
  margin: 18px 0;
  width: 112px;
}

.tracking-meta {
  color: var(--muted);
  display: grid;
  gap: 4px;
}

.hidden {
  display: none !important;
}

footer {
  color: var(--muted);
  margin-top: auto;
  padding: 20px 28px;
  text-align: center;
}

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

  .sidebar {
    position: static;
  }

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

  .metric-grid, .content-grid, .workbench {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .view, .public-tracking {
    padding: 16px;
  }

  .sidebar {
    padding: 18px;
  }

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