:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --page: #f4f6f8;
  --nav: #122033;
  --nav-ink: #eef4ff;
  --blue: #1677ff;
  --teal: #0f9f8f;
  --red: #d94848;
  --amber: #b7791f;
  --green: #27845c;
  --shadow: 0 18px 40px rgba(18, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

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

input[readonly] {
  background: #f7f9fc;
  color: #344054;
}

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

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

code {
  padding: 4px 7px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  background: var(--nav);
  color: var(--nav-ink);
}

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

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

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: #b9c6d8;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.nav-list a {
  padding: 10px 12px;
  border-radius: 6px;
  color: #dbe7f8;
  text-decoration: none;
}

.nav-list a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  color: #c7d2e3;
}

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

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

.page-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.status-pill,
.notice {
  border: 1px solid #b7e4d7;
  border-radius: 999px;
  padding: 7px 12px;
  background: #eafaf4;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.notice {
  width: fit-content;
  margin-bottom: 18px;
  border-radius: 6px;
}

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

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

.metric {
  display: grid;
  gap: 10px;
  padding: 16px;
}

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

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.metric.accent {
  border-color: #a9d8d1;
}

.metric.accent strong {
  color: var(--teal);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel.wide {
  min-width: 0;
}

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

.panel h2,
.panel-title h2 {
  margin: 0;
  font-size: 18px;
}

.panel-title a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.tenant-board,
.company-list,
.user-list,
.table-list,
.list-stack,
.event-list {
  display: grid;
  gap: 12px;
}

.tenant-card,
.company-row,
.user-row,
.table-row {
  border: 1px solid #e3e8f0;
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.tenant-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.channel-card {
  min-height: 128px;
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  padding: 12px;
  background: white;
}

.channel-card .top-line,
.presence-row,
.event-row,
.key-line,
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.channel-card strong {
  overflow-wrap: anywhere;
}

.dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 999px;
  background: #94a3b8;
}

.dot.on {
  background: var(--green);
}

.dot.tx {
  background: var(--red);
}

.small-meta,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.presence-row,
.event-row {
  border-bottom: 1px solid #edf1f6;
  padding: 9px 0;
}

.presence-row:last-child,
.event-row:last-child {
  border-bottom: 0;
}

.event-type {
  min-width: 108px;
  color: var(--muted);
  font-size: 13px;
}

.event-main {
  flex: 1;
  min-width: 0;
}

.event-main strong,
.event-main span {
  display: block;
  overflow-wrap: anywhere;
}

.event-time {
  color: var(--muted);
  font-size: 12px;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

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

.inline-form,
.table-row,
.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.channel-row {
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 2fr) 90px 110px auto;
}

.user-form {
  grid-template-columns: minmax(150px, 1fr) 110px 130px minmax(220px, 2fr) 100px auto;
}

.key-line,
.admin-list {
  margin-top: 12px;
}

.admin-list {
  display: grid;
  gap: 8px;
  border-top: 1px solid #e3e8f0;
  padding-top: 12px;
}

.admin-row {
  justify-content: start;
}

.admin-row input {
  max-width: 220px;
}

.password-row {
  padding-left: 24px;
}

.tenant-switch {
  max-width: 360px;
  margin-bottom: 16px;
}

.compact-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: start;
  gap: 8px 14px;
}

.compact-summary span {
  color: var(--muted);
}

.channel-checks {
  display: grid;
  gap: 8px;
}

.inline-checks {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check-line input {
  width: 16px;
  min-height: 16px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

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

.secondary-button {
  border-color: #bad0f3;
  background: #eaf2ff;
  color: #1059bd;
}

.ghost-button {
  border-color: #d7deea;
  background: transparent;
  color: inherit;
}

.form-error {
  margin: 0;
  color: var(--red);
}

.form-info {
  margin: 0;
  color: var(--accent);
}

.form-divider {
  height: 1px;
  background: var(--line);
  margin: 2px 0;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(22, 119, 255, 0.08), rgba(15, 159, 143, 0.08)),
    var(--page);
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: white;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 24px;
}

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

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

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

  .dashboard-grid,
  .split-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .table-row,
  .channel-row,
  .user-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 18px;
  }

  .page-header {
    display: grid;
  }

  .nav-list {
    grid-template-columns: 1fr 1fr;
  }

  .key-line,
  .admin-row,
  .presence-row,
  .event-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
