:root {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #0f172a;
  background: #f1f5f9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.auth-page {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #e2e8f0 0%, #f8fafc 45%, #dbeafe 100%);
}

.card {
  width: min(420px, 92vw);
  background: #ffffff;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.12);
}

h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

p {
  margin: 0 0 20px;
  color: #334155;
}

form,
.stack {
  display: grid;
  gap: 10px;
}

label {
  font-weight: 600;
  margin-top: 4px;
}

input,
select {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 11px;
  font-size: 0.96rem;
  background: #ffffff;
}

button {
  border: none;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  background: #0f172a;
  color: #ffffff;
}

button:hover {
  background: #1e293b;
}

.error {
  min-height: 1.4rem;
  margin-top: 12px;
  color: #b91c1c;
}

.dashboard-page {
  background: #f8fafc;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px 22px;
  background: #0f172a;
  color: #ffffff;
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
}

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

.topnav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.topnav a.active,
.topnav a:hover {
  color: #ffffff;
  background: #334155;
}

.topbar button {
  background: #334155;
}

.dashboard-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  padding: 18px;
}

.panel {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.08);
  padding: 16px;
}

.panel.wide {
  grid-column: 1 / -1;
}

.kv-list {
  display: grid;
  gap: 8px;
}

.hint {
  margin-top: 8px;
  margin-bottom: 0;
  font-size: 0.88rem;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-size: 0.9rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  padding: 8px;
  vertical-align: top;
}

th {
  color: #334155;
}

.list-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.list-controls input[type='search'] {
  flex: 1 1 200px;
  min-width: 160px;
}

.list-controls select {
  width: auto;
}

.list-controls .pager-btn {
  background: #334155;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.list-controls .pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.list-controls .pager-info {
  font-size: 0.88rem;
  color: #475569;
  white-space: nowrap;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.page-message {
  margin: 0 18px 18px;
  font-weight: 600;
  min-height: 1.25rem;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .topbar button {
    width: fit-content;
  }
}

/* Viewer role: hide all write affordances (forms marked data-write and
   dynamically rendered row action buttons). Server still enforces RBAC. */
body.role-viewer [data-write],
body.role-viewer button[data-action] {
  display: none !important;
}
