:root {
  --primary: #c00000;
  --primary-dark: #8b0000;
  --secondary: rgba(255, 255, 255, 0.72);
  --dark: #1c1c1e;
  --muted: #8e8e93;
  --light: #f2f2f7;
  --white: #ffffff;
  --border: #e5e5ea;
  --fill: #e5e5ea;
  --text-muted: #636366;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.06);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.85);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Arial, sans-serif;
  color: var(--dark);
  background: var(--light);
  letter-spacing: -0.01em;
}

/* Mesh gradient background — matches DASH app */
.dash-mesh {
  background:
    radial-gradient(circle at 85% 5%, rgba(192, 0, 0, 0.1), transparent 35%),
    radial-gradient(circle at 10% 90%, rgba(99, 102, 241, 0.06), transparent 32%),
    linear-gradient(135deg, #f8fafc 0%, #f1f5f9 45%, #fef2f2 100%);
  min-height: 100vh;
}

.glass-panel,
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

.glass-card {
  border-radius: 28px;
}

.brand-logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--white);
  padding: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.brand-logo-img.lg {
  width: 72px;
  height: 72px;
  padding: 10px;
  border-radius: 18px;
}

.brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.dash-title {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #1c1c1e 0%, #475569 55%, var(--primary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.section-padding {
  padding: 88px 7%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 0 7%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-mark {
  display: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  color: #334155;
  font-weight: 600;
}

.nav-toggle {
  display: none;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 26px;
  height: 3px;
  margin: 5px 0;
  border-radius: 999px;
  background: var(--dark);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 8px 20px rgba(192, 0, 0, 0.22);
  border-radius: 12px;
}

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

.btn-secondary {
  background: var(--white);
  color: var(--primary);
  border-color: var(--border);
}

.btn-outline {
  border-color: var(--primary);
  color: var(--primary);
  background: transparent;
}

.btn-full {
  width: 100%;
  border-radius: 14px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 74px);
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--primary);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

.hero h1,
.login-copy h1 {
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.hero-text {
  max-width: 630px;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 28px;
}

.hero-card,
.login-card,
.info-card,
.workflow-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: 28px;
}

.hero-card {
  padding: 30px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--success);
  font-weight: 700;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 8px rgba(22, 163, 74, 0.12);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.metric-card {
  padding: 22px;
  border-radius: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
}

.metric-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
}

.metric-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.section-heading {
  max-width: 650px;
  margin-bottom: 34px;
}

.section-heading h2,
.workflow-panel h2,
.login-header h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.05em;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.info-card {
  padding: 28px;
}

.icon-circle {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(192, 0, 0, 0.08);
  color: var(--primary);
  font-weight: 900;
  margin-bottom: 18px;
}

.info-card p,
.workflow-panel p,
.login-header p,
.login-copy p {
  color: var(--muted);
  line-height: 1.7;
}

.workflow-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  padding: 38px;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 14px;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  background: var(--light);
  font-weight: 700;
}

.steps span {
  color: var(--primary);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 7%;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.site-footer a {
  color: var(--primary);
  font-weight: 700;
}

.login-body {
  min-height: 100vh;
}

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

.login-logo-link {
  display: block;
  width: fit-content;
  margin: 0 auto 20px;
}

.login-subtitle {
  margin: 0 0 24px;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
}

.login-card {
  width: min(440px, 100%);
  padding: 36px 32px 28px;
}

.login-card .dash-title {
  text-align: center;
  margin-bottom: 8px;
}

.login-wrapper,
.login-visual {
  display: none;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: var(--fill);
  font: inherit;
  outline: none;
}

input:focus {
  border: 1.5px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(192, 0, 0, 0.1);
  background: var(--white);
}

.password-field {
  display: flex;
  gap: 8px;
}

.password-field button {
  min-width: 68px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--white);
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.form-options {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 0 22px;
  font-size: 0.92rem;
}

.form-options a,
.back-link a {
  color: var(--primary);
  font-weight: 700;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.error-message,
.form-status.error {
  color: var(--danger);
}

.form-status.success {
  color: var(--success);
}

.error-message {
  display: block;
  min-height: 18px;
  margin-top: 6px;
  font-size: 0.82rem;
}

.form-status {
  min-height: 22px;
  font-weight: 700;
  text-align: center;
}

.back-link {
  margin-bottom: 0;
  text-align: center;
}

@media (max-width: 850px) {
  .nav-toggle {
    display: block;
  }

  .nav-links {
    position: absolute;
    top: 74px;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 20px 7%;
    background: var(--white);
    border-bottom: 1px solid var(--border);
  }

  .nav-links.active {
    display: flex;
  }

  .hero,
  .workflow-panel,
  .login-wrapper {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

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

  .login-visual {
    min-height: 42vh;
  }

  .site-footer {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .section-padding {
    padding: 64px 5%;
  }

  .navbar {
    padding: 0 5%;
  }

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

  .form-options {
    flex-direction: column;
  }

  .login-visual {
    padding: 30px;
  }
}

/* Admin dashboard — iOS glass style */
.admin-body {
  background: transparent;
}

.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  gap: 0;
}

.admin-sidebar {
  margin: 16px;
  margin-right: 0;
  padding: 24px 18px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--dark);
}

.admin-sidebar .brand {
  color: var(--dark);
  gap: 12px;
}

.admin-user {
  margin: 0;
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  text-align: left;
  padding: 12px 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--dark);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(192, 0, 0, 0.08);
  color: var(--primary);
}

.admin-main {
  padding: 28px 32px 28px 16px;
}

.admin-header h1 {
  margin: 0 0 6px;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.page-status {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.page-status.error {
  color: var(--danger);
}

.admin-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.import-result {
  margin-bottom: 16px;
  padding: 16px 18px;
  background: rgba(22, 163, 74, 0.08);
  border: 1px solid rgba(22, 163, 74, 0.25);
  border-radius: 16px;
}

.import-result-error {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.25);
}

.import-result-stats {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.import-result-stats li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 12px;
}

.import-result-stats span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.import-result-warn {
  margin-top: 12px;
  color: var(--danger);
  font-size: 0.9rem;
}

.admin-header {
  margin-bottom: 22px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}

.inline-form.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.perm-list {
  display: grid;
  gap: 16px;
  margin: 12px 0 16px;
}

.perm-platform {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.perm-platform-web {
  border-color: #c7d2fe;
}

.perm-platform-app {
  border-color: #bbf7d0;
}

.perm-platform-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.perm-platform-icon {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
}

.perm-platform-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
}

.perm-platform-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.perm-platform-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.perm-app-card {
  padding: 14px 16px 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--dark);
}

.perm-app-card p {
  margin: 0 0 8px;
}

.perm-app-list {
  margin: 0 0 10px 1.1rem;
  padding: 0;
}

.perm-app-list li {
  margin: 4px 0;
}

.perm-app-foot {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.section-lead {
  margin: 0 0 14px;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.role-id-meta {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}

.role-name {
  font-weight: 600;
  margin-right: 6px;
}

.access-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  max-width: 280px;
  border: 1px solid transparent;
}

.access-full {
  background: #e0e7ff;
  color: #312e81;
  border-color: #c7d2fe;
}

.access-partial {
  background: #dbeafe;
  color: #1e3a8a;
  border-color: #93c5fd;
}

.access-none {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.access-app {
  background: #dcfce7;
  color: #14532d;
  border-color: #86efac;
}

#rolesTable td {
  vertical-align: middle;
}

#rolesTable td:nth-child(2),
#rolesTable td:nth-child(3) {
  min-width: 140px;
}

.perm-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 14px;
  margin: 0;
  background: #fff;
}

.perm-group-title {
  margin: 0 0 10px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--dark);
  letter-spacing: 0.02em;
}

.perm-group-items {
  display: grid;
  gap: 6px;
}

.perm-check {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--dark);
  cursor: pointer;
  line-height: 1.35;
}

.perm-check:hover {
  background: #f8fafc;
}

.perm-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

#rolesTable td:first-child .badge {
  vertical-align: middle;
}

.perm-check input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.inline-form input,
.inline-form select {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
}

.form-title {
  width: 100%;
  font-weight: 700;
  color: var(--primary);
}

.panel-form {
  margin-bottom: 16px;
  padding: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.panel-form.hidden {
  display: none;
}

.panel-form-header {
  margin-bottom: 16px;
}

.panel-form-header h3 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

.panel-form-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

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

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field-wide {
  grid-column: 1 / -1;
}

.form-field-password-stack {
  gap: 12px;
}

.form-field-password-stack .form-field-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field-password-stack .field-hint {
  margin-top: 2px;
}

.form-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel-form input,
.panel-form select {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.panel-form input[readonly] {
  background: var(--light);
  color: var(--muted);
  cursor: default;
}

.panel-form input::placeholder {
  color: #aeaeb2;
}

.panel-form input:hover {
  border-color: #d1d1d6;
}

.panel-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192, 0, 0, 0.12);
}

.panel-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.panel-form .password-field {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.panel-form .password-field input {
  flex: 1;
  min-width: 0;
}

.panel-form .password-field button {
  flex-shrink: 0;
  min-width: 68px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.field-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.field-error {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--danger, #c00);
}

.field-error.hidden {
  display: none;
}

@media (max-width: 700px) {
  .panel-form-grid {
    grid-template-columns: 1fr;
  }

  .form-field-wide {
    grid-column: auto;
  }
}

.table-wrap {
  overflow: auto;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  background: rgba(255, 255, 255, 0.5);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.data-table th.sortable-th {
  cursor: pointer;
  user-select: none;
  padding-right: 22px;
  position: relative;
}

.data-table th.sortable-th:hover {
  color: var(--primary);
}

.data-table th.sortable-th::after {
  content: '↕';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  opacity: 0.35;
}

.data-table th.sortable-th.sort-asc::after {
  content: '↑';
  opacity: 1;
  color: var(--primary);
}

.data-table th.sortable-th.sort-desc::after {
  content: '↓';
  opacity: 1;
  color: var(--primary);
}

.data-table tbody tr:hover {
  background: rgba(192, 0, 0, 0.03);
}

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

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
}

/* Field options — drag to reorder */
.fo-sort-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.fo-sort-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  touch-action: none;
}

.fo-sort-label {
  flex: 1;
  font-weight: 600;
  color: var(--text);
}

.fo-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  cursor: grab;
  user-select: none;
  font-size: 1rem;
  letter-spacing: -2px;
  flex-shrink: 0;
  touch-action: none;
}

.fo-drag-handle:active {
  cursor: grabbing;
}

.fo-drag-handle:hover {
  background: rgba(192, 0, 0, 0.08);
  color: var(--primary);
}

.fo-sort-item.fo-row-dragging {
  opacity: 0.55;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 2;
}

.fo-sort-item.fo-row-drop-target {
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
  border: none;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.pending {
  background: #fef3c7;
  color: #92400e;
}

.badge.approved {
  background: #dcfce7;
  color: #166534;
}

.badge.rejected {
  background: #fee2e2;
  color: #991b1b;
}

.badge.whitelisted {
  background: #e0e7ff;
  color: #3730a3;
}

.badge.log-action {
  background: var(--light);
  color: var(--dark);
  text-transform: capitalize;
}

.badge.log-cat {
  text-transform: capitalize;
}

.badge.log-cat-approval { background: #fef3c7; color: #92400e; }
.badge.log-cat-flange { background: #dbeafe; color: #1e40af; }
.badge.log-cat-nfc { background: #e0e7ff; color: #4338ca; }
.badge.log-cat-user { background: #f3e8ff; color: #6b21a8; }
.badge.log-cat-auth { background: #dcfce7; color: #166534; }

.panel-textarea {
  width: 100%;
  min-height: 160px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  resize: vertical;
  background: var(--white);
}

.panel-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192, 0, 0, 0.12);
}

.segmented {
  display: inline-flex;
  padding: 4px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  gap: 4px;
}

.segment {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.segment.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.toolbar-sub {
  margin-top: 0;
}

.filter-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.9rem;
}

.filter-select {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: var(--white);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.pager-btn {
  min-width: 36px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
}

.pager-btn.disabled,
.pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pager-btn.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.pager-gap {
  padding: 0 4px;
  color: var(--muted);
}

.pager-info {
  margin-left: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.table-hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#flangesTable {
  min-width: 900px;
}

.admin-sidebar .btn-outline {
  border-color: var(--border);
  color: var(--muted);
  border-radius: 12px;
}

.admin-sidebar .btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  border-radius: 20px;
}

.modal-panel-wide {
  width: min(920px, 100%);
}

.detail-sections {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 8px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 58px;
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-value {
  font-size: 0.92rem;
  word-break: break-word;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.modal-meta {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Approval view popup — clearer title spacing (#12) */
.modal-panel-approval {
  padding-top: 26px;
}

.approval-modal-header {
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 18px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.approval-modal-titles {
  flex: 1;
  min-width: 0;
  padding-right: 8px;
}

.approval-modal-eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.approval-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.approval-modal-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 0 22px;
  margin: 0;
}

.approval-remark-block {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
}

.approval-remark-label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.approval-remark-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}

.approval-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
}

.approval-meta-label {
  min-width: 5.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.approval-modal-table {
  margin-top: 4px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.change-old {
  color: var(--muted);
  text-decoration: line-through;
}

.change-new {
  font-weight: 700;
  color: var(--primary);
}

@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    margin: 12px;
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .admin-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.flange-detail-form.panel-form {
  display: block;
  padding: 24px;
  border-radius: var(--radius-lg);
}

.flange-detail-form .form-section {
  margin-bottom: 24px;
}

.flange-detail-form .form-section:last-of-type {
  margin-bottom: 0;
}

.form-page-actions {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.panel-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: rgba(255, 255, 255, 0.9);
  resize: vertical;
}

.panel-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(196, 30, 58, 0.15);
}

.toolbar a.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.actions a.btn {
  text-decoration: none;
  margin-left: 6px;
}

#adminNav a.nav-item {
  display: block;
  text-decoration: none;
}

.admin-form-panel {
  padding: 24px 28px;
  border-radius: var(--radius-lg);
}

.app-download-card {
  padding: 28px 32px;
  max-width: 640px;
}

.app-download-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.app-download-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.app-download-title {
  margin: 0 0 4px;
  font-size: 1.35rem;
  font-weight: 700;
}

.app-download-version {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.app-download-btn {
  margin-bottom: 10px;
  text-align: center;
  text-decoration: none;
}

.app-download-meta {
  margin: 0 0 20px;
  font-size: 0.88rem;
  color: var(--muted);
}

.app-download-missing {
  margin-bottom: 20px;
  padding: 16px 18px;
  border-radius: 12px;
  background: rgba(255, 193, 7, 0.12);
  border: 1px solid rgba(255, 193, 7, 0.35);
}

.app-download-missing p {
  margin: 0 0 8px;
}

.app-download-missing p:last-child {
  margin-bottom: 0;
}

.app-download-steps {
  margin: 0 0 18px;
  padding-left: 1.25rem;
  line-height: 1.55;
  color: var(--text);
}

.app-download-steps li + li {
  margin-top: 8px;
}

.app-download-note {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

