:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef2f6;
  --text: #18202a;
  --muted: #637083;
  --line: #d9e0e8;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --secondary: #334155;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --success: #087443;
  --success-soft: #dcfae6;
  --warning-soft: #fff3cd;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary-strong);
}

.top-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.top-nav a {
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--secondary);
  font-weight: 650;
}

.top-nav a:hover {
  background: var(--surface-soft);
}

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

.session-box form {
  margin: 0;
}

.page {
  width: min(1180px, calc(100% - 36px));
  margin: 28px auto 56px;
}

.auth-shell {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
}

.auth-card,
.panel {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.auth-card h1,
.section-heading h1,
.empty-state h1,
.empty-state h2 {
  margin: 0;
  letter-spacing: 0;
}

.auth-card p,
.section-heading p,
.empty-state p {
  margin: 4px 0 0;
  color: var(--muted);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h1 {
  font-size: 26px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 13px;
  background: var(--surface);
  color: var(--secondary);
}

.flash.error {
  border-color: #fecdca;
  background: var(--danger-soft);
  color: #7a271a;
}

.flash.success {
  border-color: #a9efc5;
  background: var(--success-soft);
  color: #064e2f;
}

label {
  display: grid;
  gap: 7px;
  color: var(--secondary);
  font-weight: 650;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 750;
  white-space: nowrap;
}

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

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

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--secondary);
}

.button.secondary:hover,
.button.ghost:hover {
  background: var(--surface-soft);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--secondary);
}

.button.danger {
  background: var(--danger);
  color: #fff;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

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

th {
  background: #f9fafb;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.strong {
  font-weight: 750;
}

.actions-col {
  width: 190px;
}

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

.row-actions form {
  margin: 0;
}

.form-grid {
  width: min(100%, 760px);
  display: grid;
  gap: 18px;
  padding: 24px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

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

legend {
  padding: 0 6px;
  color: var(--secondary);
  font-weight: 750;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}

.inline-check {
  justify-content: flex-start;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-soft);
  color: var(--secondary);
  font-size: 12px;
  font-weight: 750;
}

.badge.ok {
  border-color: #a9efc5;
  background: var(--success-soft);
  color: var(--success);
}

.badge.muted {
  background: #f2f4f7;
  color: var(--muted);
}

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

.empty-state {
  display: grid;
  justify-items: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  .app-header {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 14px 18px;
  }

  .top-nav,
  .session-box,
  .section-heading {
    width: 100%;
    flex-wrap: wrap;
  }

  .session-box {
    justify-content: space-between;
  }

  .page {
    width: min(100% - 24px, 1180px);
    margin-top: 18px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .button {
    white-space: normal;
  }
}
