:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --surface: #fff;
  --surface-alt: #edf4f1;
  --ink: #172321;
  --muted: #66736f;
  --line: #d8e2de;
  --primary: #176b5f;
  --primary-dark: #0f4f47;
  --danger: #b42318;
  --warning: #9a5b13;
  --ok: #287a3e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--primary);
}

.page-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.page-header-inner,
.page-main {
  width: min(100% - 32px, 1440px);
  margin: 0 auto;
}

.page-header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-title h1 {
  margin: 0;
  font-size: 24px;
}

.page-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions,
.form-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-main {
  padding: 24px 0 48px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}

.stat {
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
}

.stat:last-child {
  border-right: 0;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
}

.section {
  margin-top: 22px;
  border-top: 3px solid var(--primary);
  background: var(--surface);
}

.section-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-top: 0;
}

.section-header h2 {
  margin: 0;
  font-size: 17px;
}

.section-body {
  border: 1px solid var(--line);
  border-top: 0;
  padding: 16px;
}

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

.form-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: #34443f;
  font-size: 12px;
  font-weight: 700;
}

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

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 95, 0.13);
}

button,
.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--primary);
  border-radius: 6px;
  padding: 8px 13px;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

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

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

.button.danger,
button.danger {
  border-color: #f0c4c0;
  color: var(--danger);
  background: #fff3f2;
}

button.small,
.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #475651;
  background: #f6f9f8;
  font-size: 11px;
  text-transform: uppercase;
}

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

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: #edf1f0;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.active {
  color: var(--ok);
  background: #e9f6ec;
}

.badge.passive {
  color: var(--danger);
  background: #fff0ef;
}

.badge.master {
  color: #84450f;
  background: #fff1df;
}

.badge.warning,
.badge.trial {
  color: #8a4f08;
  background: #fff3dc;
}

.badge.licensed {
  color: #176b5f;
  background: #e4f4f0;
}

.badge.expired {
  color: var(--danger);
  background: #fff0ef;
}

.flash {
  margin: 0 0 18px;
  border-left: 4px solid var(--ok);
  padding: 12px 14px;
  color: #205e31;
  background: #edf8ef;
}

.flash.error {
  border-left-color: var(--danger);
  color: var(--danger);
  background: #fff1f0;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.assignment-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto;
  gap: 7px;
}

.password-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 7px;
}

.account-form {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 0.8fr) auto;
  gap: 7px;
}

.role-form {
  margin-top: 7px;
}

.member-actions {
  min-width: 142px;
}

.bulk-assignment-bar {
  margin: -16px -16px 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  background: #f6f9f8;
}

.bulk-assignment-form {
  display: grid;
  grid-template-columns: minmax(210px, 320px) auto 1fr;
  align-items: end;
  gap: 10px;
}

.selection-count {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.selection-column {
  width: 44px;
  padding-right: 4px;
  padding-left: 8px;
  text-align: center;
}

input.selection-checkbox {
  width: 19px;
  min-height: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.reject-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 7px;
}

.subsection {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.license-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}

.license-summary strong {
  color: var(--ink);
}

.license-actions {
  margin-top: 12px;
}

.license-banner {
  margin: 0 0 18px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  background: var(--surface);
}

.stat .stat-text {
  font-size: 19px;
}

.disclosure > summary {
  cursor: pointer;
  list-style: none;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary::after {
  color: var(--primary);
  content: "+";
  font-size: 24px;
  font-weight: 700;
}

.disclosure[open] > summary::after {
  content: "−";
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-shell {
  width: min(100%, 720px);
  border: 1px solid var(--line);
  border-top: 4px solid var(--primary);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(24, 50, 44, 0.12);
}

.auth-heading {
  margin-bottom: 22px;
}

.auth-heading > a {
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.auth-heading h1 {
  margin: 10px 0 6px;
  font-size: 26px;
}

.auth-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 15px;
}

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

.auth-form button,
.auth-button {
  width: 100%;
}

.auth-back {
  display: block;
  margin-top: 18px;
  text-align: center;
}

.honeypot {
  position: fixed;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (max-width: 900px) {
  .stats,
  .form-grid,
  .form-grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat:nth-child(2) {
    border-right: 0;
  }

  .stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .page-header-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 0;
  }

  .page-main {
    padding-top: 16px;
  }

  .stats,
  .form-grid,
  .form-grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .stat {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stat:last-child {
    border-bottom: 0;
  }

  .section-body {
    padding: 12px;
  }

  .assignment-form,
  .password-form,
  .account-form,
  .bulk-assignment-form,
  .reject-form,
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .bulk-assignment-form {
    align-items: stretch;
  }

  .auth-shell {
    padding: 20px;
  }
}
