:root {
  --bg: #f3f6f8;
  --card: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #d7dee8;
  --blue: #155eef;
  --blue-dark: #113f9f;
  --green: #168a5b;
  --red: #b42318;
  --amber: #b76e00;
  --soft: #eef3f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", Tahoma, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 64px;
}

body[data-auth="authenticated"] #login-panel {
  display: none;
}

body[data-auth="anonymous"] .topbar,
body[data-auth="anonymous"] .tabs,
body[data-auth="anonymous"] .view {
  display: none;
}

.login-panel,
.topbar,
.tabs,
.card,
.metrics article {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
}

.login-panel {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  align-items: center;
  margin-top: 40px;
  padding: 22px;
  border-radius: 12px;
}

.login-panel h1 {
  margin: 4px 0 6px;
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.04em;
}

.login-panel p {
  margin: 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 10px;
}

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

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21, 94, 239, 0.12);
}

.login-form button,
.topbar-actions button,
.editor-actions button {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.secondary {
  color: var(--ink) !important;
  background: var(--soft) !important;
}

.compact {
  min-height: 32px !important;
  padding: 6px 10px !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border-radius: 10px;
}

.topbar strong {
  display: block;
  font-size: 18px;
}

.topbar span,
.muted,
small {
  color: var(--muted);
}

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

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 6px;
  border-radius: 10px;
}

.tab {
  padding: 8px 11px;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.tab.is-active {
  color: #fff;
  background: #13243b;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 12px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metrics article {
  padding: 14px;
  border-radius: 10px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 34px;
  line-height: 1;
}

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card {
  padding: 14px;
  border-radius: 10px;
}

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

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

h2 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 15px;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill,
.state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--soft);
  color: #243b53;
  font-size: 12px;
  font-weight: 700;
}

.state.ok {
  color: var(--green);
  background: #eaf7ef;
}

.state.warn {
  color: var(--amber);
  background: #fff5df;
}

.state.bad {
  color: var(--red);
  background: #fff0ef;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 170px;
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar:has(select:nth-child(2):last-child) {
  grid-template-columns: minmax(220px, 1fr) 170px;
}

.table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) 120px 100px 90px minmax(210px, 1fr) 90px 110px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-head {
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

.table-row strong,
.table-row small {
  display: block;
}

.row-action {
  width: 100%;
  min-height: 32px;
  border-radius: 7px;
  color: #fff;
  background: var(--blue-dark);
  font-weight: 700;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--soft);
  color: #344054;
  font-size: 12px;
  font-weight: 650;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
  background: #fff;
}

.mini-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mini-card p {
  color: var(--muted);
  font-size: 13px;
}

dl {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

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

.list-item,
.event {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

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

.event {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 180px;
  gap: 10px;
  align-items: start;
}

.event code {
  color: var(--muted);
  word-break: break-all;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.permission-option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.permission-option input {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

.permission-option span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  max-width: min(520px, calc(100vw - 28px));
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: #fff;
  background: #172033;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.18);
  z-index: 20;
}

.empty {
  color: var(--muted);
  padding: 18px;
  text-align: center;
  background: #fff;
}

@media (max-width: 960px) {
  .login-panel,
  .grid.two,
  .metrics,
  .cards {
    grid-template-columns: 1fr;
  }

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

  .table {
    overflow-x: auto;
  }

  .table-row {
    min-width: 940px;
  }

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