
:root {
  --bg-1: #f6f2e5;
  --bg-2: #e8e0c8;
  --bg-3: #d6ccb1;
  --surface: rgba(255, 251, 242, 0.9);
  --surface-strong: rgba(255, 252, 246, 0.97);
  --text: #16120b;
  --muted: #64583f;
  --border: rgba(118, 98, 42, 0.2);
  --shadow: 0 22px 52px rgba(24, 18, 8, 0.15);
  --gold: #d2af22;
  --gold-bright: #e6c53d;
  --gold-deep: #aa8611;
  --olive: #486a45;
  --olive-deep: #355033;
  --black: #17130d;
  --black-soft: #282117;
  --danger-bg: rgba(136, 41, 29, 0.08);
  --danger-border: rgba(136, 41, 29, 0.18);
  --danger-text: #7d3021;
  --ok-bg: linear-gradient(135deg, rgba(210, 175, 34, 0.16), rgba(72, 106, 69, 0.12));
  --ok-border: rgba(118, 98, 42, 0.26);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --row-height: 56px;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(210, 175, 34, 0.2), transparent 30%),
    radial-gradient(circle at right center, rgba(72, 106, 69, 0.12), transparent 28%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2) 60%, var(--bg-3));
  position: relative;
  overflow-x: hidden;
}
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(18px);
  z-index: 0;
  pointer-events: none;
}
body::before {
  width: 290px;
  height: 290px;
  top: -50px;
  left: -80px;
  background: rgba(210, 175, 34, 0.14);
}
body::after {
  width: 320px;
  height: 320px;
  right: -120px;
  bottom: -20px;
  background: rgba(72, 106, 69, 0.1);
}
.page {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.shell { width: min(1120px, 100%); }
.shell-narrow { width: min(520px, 100%); }
.shell-medium { width: min(860px, 100%); }
.shell-wide { width: min(1380px, 100%); }
.card {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--olive) 0%, var(--gold) 56%, var(--black-soft) 100%);
}
.panel { padding: 30px; }
.panel-centered { padding: 38px 34px; }
.panel-soft {
  background: var(--surface-strong);
  border: 1px solid rgba(118, 98, 42, 0.14);
  border-radius: 22px;
  padding: 28px;
}
.form-only-panel { margin-top: 18px; }
.brand,
.brand-centered {
  display: flex;
  justify-content: center;
}
.brand { justify-content: center; }
.brand img {
  display: block;
  width: min(100%, 250px);
  height: auto;
}
.brand-badge,
.status-chip,
.subtle-note {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(72, 106, 69, 0.18);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  background: rgba(255, 252, 245, 0.76);
}
.brand-badge { margin-top: 20px; }
.page-title {
  margin: 12px 0 10px;
  font-size: clamp(1.85rem, 2vw, 2.45rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--black);
}
.page-title-centered,
.top-note-centered { text-align: center; }
.top-note,
.field-help,
.subtle-note,
.table-sub {
  color: var(--muted);
  line-height: 1.6;
}
.subtle-note { margin-top: 18px; }
.section-eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--olive-deep);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.section-title {
  margin: 0 0 10px;
  font-size: 1.6rem;
  line-height: 1.15;
}
label {
  display: block;
  margin: 18px 0 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--black);
}
.input-wrap { position: relative; }
input,
select {
  width: 100%;
  padding: 14px 15px;
  border-radius: 18px;
  border: 1px solid rgba(118, 98, 42, 0.18);
  background: rgba(255, 252, 246, 0.98);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  outline: none;
}
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 44px;
  background-image: linear-gradient(45deg, transparent 50%, #8f815e 50%), linear-gradient(135deg, #8f815e 50%, transparent 50%);
  background-position: calc(100% - 22px) calc(50% - 3px), calc(100% - 16px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input:focus,
select:focus {
  border-color: rgba(210, 175, 34, 0.8);
  box-shadow: 0 0 0 4px rgba(210, 175, 34, 0.14);
  transform: translateY(-1px);
}
input::placeholder { color: #9d9277; }
.field-help {
  margin-top: 7px;
  font-size: 0.9rem;
}
button,
.button-link {
  border: 0;
  border-radius: 14px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease, background 0.18s ease;
  text-decoration: none;
}
button:hover,
.button-link:hover { transform: translateY(-1px); }
button:active,
.button-link:active { transform: translateY(0); }
.btn-primary {
  width: 100%;
  margin-top: 22px;
  padding: 14px 18px;
  color: var(--black);
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-bright) 48%, var(--gold-deep) 100%);
  box-shadow: 0 14px 28px rgba(82, 64, 10, 0.18);
}
.btn-primary:hover { box-shadow: 0 18px 32px rgba(82, 64, 10, 0.22); }
.btn-secondary,
.btn-tertiary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: rgba(23, 19, 13, 0.94);
  color: #fff7d8;
  border: 1px solid rgba(23, 19, 13, 0.18);
}
.btn-secondary:hover,
.btn-tertiary:hover { background: var(--black-soft); }
.btn-tertiary {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
}
.flash {
  margin: 16px 0;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
  font-weight: 600;
}
.header-row,
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.actions-row { margin-top: 12px; }
.result-card {
  margin-top: 24px;
  padding: 20px;
  border-radius: 22px;
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
}
.result-label {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
}
.result-key {
  margin-top: 10px;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: clamp(1.2rem, 2.8vw, 2rem);
  letter-spacing: 0.02em;
  word-break: break-word;
}
.mono {
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 1rem;
  letter-spacing: 0.01em;
  word-break: break-word;
}
.admin-grid {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 22px;
  margin-top: 18px;
}
.admin-section { min-width: 0; }
.admin-stack { display: grid; gap: 22px; }
.admin-nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(118, 98, 42, 0.18);
  border-radius: 18px;
  background: rgba(255, 252, 246, 0.75);
}
.admin-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.admin-nav-link:hover {
  background: rgba(255, 252, 245, 0.92);
  color: var(--text);
}
.admin-nav-link.is-active {
  background: linear-gradient(90deg, rgba(72, 106, 69, 0.16), rgba(210, 175, 34, 0.18));
  color: var(--black);
}
.audit-table td,
.audit-table th { font-size: 0.97rem; }
.audit-table th { font-size: 0.84rem; }
.mono-compact { font-size: 0.97rem; line-height: 1.45; }
.stack-form,
.action-stack { display: grid; gap: 12px; }
.two-col-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.checkbox-row input { width: auto; }
.table-wrap {
  margin-top: 20px;
  overflow: auto;
  border: 1px solid rgba(118, 98, 42, 0.16);
  border-radius: 20px;
  background: rgba(255, 252, 246, 0.78);
}
.audit-table-wrap { max-height: calc(var(--row-height) * 21); }
.compact-top { margin-top: 18px; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
th,
td {
  padding: 14px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(118, 98, 42, 0.1);
}
th {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(248, 243, 232, 0.98);
  position: sticky;
  top: 0;
}
tr:last-child td { border-bottom: 0; }
.table-main { font-weight: 700; }
.table-sub { font-size: 0.86rem; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(72, 106, 69, 0.12);
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
}
.pill-admin {
  background: rgba(210, 175, 34, 0.22);
  color: #7e5f00;
}
.pill-ok {
  background: rgba(72, 106, 69, 0.14);
  color: var(--olive-deep);
}
.pill-muted {
  background: rgba(100, 88, 63, 0.12);
  color: var(--muted);
}
.inline-password-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.inline-password-form input {
  min-width: 0;
  padding: 10px 12px;
  font-size: 0.92rem;
}
@media (max-width: 980px) {
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .admin-nav { width: 100%; }
  .admin-nav-link { flex: 1 1 180px; }
  .panel,
  .panel-soft,
  .panel-centered { padding: 22px; }
  .header-row-stack-mobile,
  .info-row,
  .two-col-form {
    grid-template-columns: 1fr;
    display: grid;
  }
  .header-actions { width: 100%; }
  .header-actions > * { flex: 1 1 auto; }
}
@media (max-width: 540px) {
  .page { padding: 18px 10px; }
  .panel,
  .panel-soft,
  .panel-centered { padding: 18px; }
  .brand img { width: min(100%, 220px); }
}

/* User management layout refresh */
.user-management-table {
  table-layout: fixed;
  min-width: 1180px;
}
.user-management-table .col-user { width: 24%; }
.user-management-table .col-role { width: 18%; }
.user-management-table .col-license { width: 14%; }
.user-management-table .col-supervisor { width: 18%; }
.user-management-table .col-actions { width: 26%; }

.user-cell,
.role-cell,
.license-cell,
.supervisor-cell,
.actions-cell {
  min-width: 0;
}

.user-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-role-form,
.inline-max-form,
.inline-parent-form {
  display: block;
}

.inline-role-form select,
.inline-max-form input,
.inline-parent-form select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  font-size: 0.92rem;
}

.supervisor-cell .table-main,
.role-cell .table-main,
.license-cell .table-main {
  word-break: break-word;
}

.supervisor-cell .inline-parent-form select {
  min-width: 180px;
}

.actions-cell {
  width: 330px;
  min-width: 330px;
}

.action-row-wide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.action-row-wide > * {
  min-width: 0;
}

.action-row-wide form,
.action-row-wide > button {
  width: 100%;
}

.action-row-wide .btn-compact,
.row-save-button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
}

.compact-password-form {
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 8px;
  align-items: center;
}

.temp-password-input {
  width: 100%;
  max-width: none;
}

.compact-password-form .btn-compact {
  width: 100%;
  min-width: 0;
  min-height: 42px;
}

.table-sub {
  word-break: break-word;
}

@media (max-width: 980px) {
  .user-management-table {
    min-width: 980px;
  }
  .actions-cell {
    width: 280px;
    min-width: 280px;
  }
}

@media (max-width: 780px) {
  .action-row-wide {
    grid-template-columns: 1fr;
  }
  .compact-password-form {
    grid-template-columns: 1fr;
  }
  .temp-password-input {
    max-width: none;
  }
}
