:root {
  color-scheme: light;
  font-family: Inter, "Roboto", "Helvetica Neue", Arial, sans-serif;
  background: #f4f6f8;
  color: #071321;
  --navy: #071724;
  --navy-2: #102637;
  --line: #d6dce2;
  --muted: #6b7280;
  --red: #c5222c;
  --red-dark: #a71922;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f6f8;
  color: #071321;
}

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

body:not(.is-authenticated) .app-shell {
  display: block;
}

body:not(.is-authenticated) .sidebar,
body:not(.is-authenticated) .topbar {
  display: none;
}

body:not(.is-authenticated) .main-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

body:not(.is-authenticated) .workspace-section {
  display: none;
}

body:not(.is-authenticated) #auth-section {
  display: block;
  width: min(100%, 520px);
}

body:not(.is-authenticated) #logout-button {
  display: none;
}

body.is-auth-checking #auth-section {
  display: none;
}

body.is-auth-checking::before {
  content: "Checking admin access...";
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #071321;
  font-weight: 800;
  padding: 18px 22px;
  box-shadow: 0 14px 40px rgba(7, 19, 33, 0.12);
  z-index: 10;
}

.sidebar {
  background: var(--navy);
  color: #eef4f7;
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 100vh;
}

.brand-card {
  background: #ffffff;
  border-radius: 4px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  height: 56px;
}

.brand-card img {
  display: block;
  width: 100%;
  max-height: 40px;
  object-fit: contain;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item,
.nav-footer-button {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #d7e0e7;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover:not(:disabled),
.nav-footer-button:hover:not(:disabled),
.nav-item.is-active {
  background: var(--navy-2);
  color: #ffffff;
}

.nav-item:disabled,
.nav-footer-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.nav-icon {
  width: 20px;
  text-align: center;
  color: #aab8c3;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 18px;
}

.sidebar-footer p {
  margin: 0 0 10px;
  color: #aab8c3;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.main-panel {
  min-width: 0;
  padding: 0 28px 36px;
}

.topbar {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}

.topbar h1,
.section-heading h2,
.card h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 1.75rem;
}

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

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

.search-shell {
  height: 36px;
  width: min(360px, 32vw);
  border: 1px solid #c8ced6;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
}

.search-shell input {
  border: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  outline: none;
}

.session-pill {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.workspace-section {
  display: none;
}

.workspace-section.is-active {
  display: block;
}

.section-heading,
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  font-size: 1.75rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 18px;
  margin-bottom: 18px;
}

.auth-card {
  max-width: 520px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card {
  min-height: 122px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 4px;
  padding: 18px;
}

.metric-card p,
.metric-card span {
  margin: 0;
  color: var(--muted);
}

.metric-card p {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  font-size: 2rem;
  margin: 10px 0 4px;
}

.metric-card span {
  font-size: 0.88rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 180px;
}

.compact-field {
  max-width: 120px;
}

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

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #c8ced6;
  color: #071321;
  padding: 9px 10px;
  border-radius: 3px;
  font: inherit;
}

textarea {
  resize: vertical;
}

.row,
.filter-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-row {
  margin-bottom: 12px;
}

.actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  background: var(--red);
  border: 1px solid var(--red);
  padding: 8px 14px;
  border-radius: 3px;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

button.secondary,
.link-button {
  background: #ffffff;
  border-color: #b8c0c8;
  color: #071321;
}

button.danger {
  background: #ffffff;
  border-color: var(--red);
  color: var(--red);
}

button.danger:hover:not(:disabled) {
  background: var(--red);
  color: #ffffff;
}

.link-button {
  border: 0;
  color: var(--red);
  padding: 4px 0;
}

button.secondary:hover:not(:disabled),
.link-button:hover:not(:disabled) {
  background: var(--panel-soft);
  color: var(--red-dark);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrapper {
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
}

.compact-table {
  border: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1px solid #e5e9ee;
  font-size: 0.88rem;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--panel-soft);
}

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

td button {
  padding: 5px 9px;
  font-size: 0.78rem;
  margin-right: 6px;
}

.message-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-panel {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.detail-header {
  align-items: center;
  justify-content: space-between;
}

.compact-actions {
  margin-top: 0;
}

pre {
  background: #071724;
  color: #eef4f7;
  border: 1px solid #0f2a3c;
  border-radius: 4px;
  padding: 12px;
  overflow: auto;
  max-height: 520px;
  white-space: pre-wrap;
}

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

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

.settings-list span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

code {
  color: #071321;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px 10px;
  overflow-wrap: anywhere;
}

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

  .sidebar {
    min-height: auto;
    padding: 14px;
    gap: 14px;
  }

  .side-nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .main-panel {
    padding: 0 16px 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 0;
  }

  .topbar-actions,
  .search-shell {
    width: 100%;
  }

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