:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #eef2f5;
  --line: #d8dee5;
  --line-strong: #b8c2cc;
  --text: #16202a;
  --muted: #5e6a76;
  --accent: #00745f;
  --accent-dark: #005747;
  --danger: #b42318;
  --warn: #9a5b00;
  --focus: #1b6fd7;
  --shadow: 0 14px 40px rgba(14, 31, 53, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.session-label {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-layout {
  display: grid;
  min-height: calc(100vh - 130px);
  place-items: center;
}

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

.auth-panel {
  width: min(440px, 100%);
  padding: 24px;
}

.panel-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.panel-heading p,
.table-header p {
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(27, 111, 215, 0.18);
}

.button,
.icon-button,
.docs-link {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.button {
  padding: 0 14px;
}

.docs-link {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  text-decoration: none;
}

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

.button-primary:hover {
  background: var(--accent-dark);
}

.button-quiet {
  background: transparent;
}

.workspace {
  display: grid;
  gap: 16px;
  padding-top: 18px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  box-shadow: none;
}

.search-wrap {
  width: min(520px, 100%);
}

.toolbar-actions,
.form-actions,
.row-actions,
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.table-panel {
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 38px;
  padding: 0;
}

.icon-button span {
  display: block;
  transform: translateY(-1px);
  font-size: 24px;
  line-height: 1;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

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

tbody tr {
  background: #fff;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #f1f7f5;
}

.user-cell {
  display: grid;
  gap: 3px;
}

.user-name {
  font-weight: 800;
}

.user-email,
.muted {
  color: var(--muted);
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  padding: 0 9px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.badge-status-active {
  border-color: rgba(0, 116, 95, 0.35);
  background: rgba(0, 116, 95, 0.1);
  color: var(--accent-dark);
}

.badge-status-disabled,
.badge-status-locked {
  border-color: rgba(180, 35, 24, 0.28);
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.badge-status-invited {
  border-color: rgba(154, 91, 0, 0.3);
  background: rgba(154, 91, 0, 0.08);
  color: var(--warn);
}

.editor-panel {
  position: sticky;
  top: 16px;
  padding: 18px;
}

fieldset {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.role-choice,
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
}

.role-choice input,
.check-row input {
  width: 16px;
  min-height: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #0f1f2e;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

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

  .editor-panel {
    position: static;
  }
}

@media (max-width: 700px) {
  .shell {
    padding: 16px;
  }

  .topbar,
  .toolbar,
  .table-header {
    align-items: stretch;
    flex-direction: column;
  }

  .session-bar,
  .toolbar-actions {
    justify-content: space-between;
  }

  h1 {
    font-size: 24px;
  }
}
