:root {
  --bg: #f4efdf;
  --panel: #ffffff;
  --ink: #1f1d21;
  --muted: #5f665f;
  --green: #1a6b3b;
  --green-dark: #14522e;
  --gold: #d59a2f;
  --gold-soft: #f0d9a9;
  --danger: #b62020;
  --border: #e4decf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Montserrat", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f7f2e5 0%, #ece6d7 100%);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
}

code {
  background: #f3eddc;
  border-radius: 6px;
  padding: 2px 6px;
}

.portal-shell {
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(20, 40, 24, 0.08);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.error-text {
  color: var(--danger);
  min-height: 18px;
  font-size: 0.9rem;
}

.login-card {
  max-width: 520px;
  margin: 80px auto;
  padding: 24px;
  display: grid;
  gap: 16px;
}

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

.topbar h2 {
  color: var(--green);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.notice {
  margin-bottom: 14px;
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--gold-soft);
  background: #fff8ec;
  color: #6d5209;
}

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 14px;
}

.sidebar {
  padding: 12px;
  height: fit-content;
  display: grid;
  gap: 8px;
  position: sticky;
  top: 20px;
}

.nav-btn {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.nav-btn:hover {
  border-color: var(--gold);
}

.nav-btn.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.main-content {
  min-width: 0;
}

.section-panel {
  display: none;
  padding: 18px;
  gap: 16px;
}

.section-panel.active {
  display: grid;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(160deg, #ffffff 0%, #faf8f1 100%);
}

.stat-card h4 {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.stat-card p {
  color: var(--green);
  font-size: 1.6rem;
  font-weight: 700;
}

.stat-sub {
  margin-top: 4px;
  font-size: 0.82rem;
}

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

.inline-panel {
  margin-bottom: 14px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 28, 22, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1200;
}

.modal-card {
  width: min(620px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-header h4 {
  color: var(--green);
}

.login-support-actions {
  justify-content: flex-start;
}

.helper-text {
  min-height: 18px;
  font-size: 0.9rem;
}

.helper-text.error {
  color: var(--danger);
}

.helper-text.success {
  color: #155b32;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid #e8be67;
  border-color: var(--gold);
}

input[readonly] {
  background: #f5f2e8;
  color: var(--muted);
}

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

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

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

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

.btn-outline {
  border-color: var(--green);
  color: var(--green);
  background: #fff;
}

.btn-outline:hover {
  background: #f0f8f4;
}

.btn-danger {
  border-color: #e3aaaa;
  background: #fff;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fff2f2;
}

.search-box {
  max-width: 420px;
}

.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.audit-filter-field {
  min-width: 220px;
  max-width: 320px;
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  width: fit-content;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
}

progress {
  width: 100%;
  height: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.table-pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.page-info {
  min-width: 110px;
  text-align: center;
  font-size: 0.85rem;
}

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

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 0.92rem;
}

thead th {
  background: #f5f2ea;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #faf8f2;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 6px;
}

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

.pill-ok {
  color: #0f5f30;
  background: #e7f6ec;
}

.pill-off {
  color: #8a2020;
  background: #fdeeee;
}

.pill-pending {
  color: #6d5209;
  background: #fff3d8;
}

.usage-stats-grid {
  margin-bottom: 6px;
}

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

.usage-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(160deg, #ffffff 0%, #faf8f1 100%);
}

.usage-card h4 {
  margin-bottom: 10px;
}

.help-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
}

.help-toc {
  padding: 12px;
  height: fit-content;
  position: sticky;
  top: 16px;
  display: grid;
  gap: 8px;
}

.help-toc h4 {
  margin-bottom: 4px;
  color: var(--green);
}

.help-toc a {
  display: block;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-weight: 600;
  background: #fff;
}

.help-toc a:hover {
  border-color: var(--gold);
  background: #fffaf0;
}

.help-content {
  display: grid;
  gap: 12px;
}

.help-article {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: linear-gradient(160deg, #ffffff 0%, #faf8f1 100%);
  display: grid;
  gap: 10px;
}

.help-article h4 {
  color: var(--green);
}

.help-article details {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
}

.help-article details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.help-article details ol,
.help-article details ul {
  margin: 10px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.help-callout {
  border: 1px solid #d8e4d1;
  background: #f5faf2;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.help-callout-warning {
  border-color: #f0d9a9;
  background: #fff8ec;
}

.help-infographic {
  border: 1px dashed #cfd8bf;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.help-infographic h5 {
  margin: 0;
  color: var(--green);
}

.flow-diagram {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.flow-diagram-vertical {
  flex-direction: column;
  align-items: stretch;
}

.flow-step {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #faf8f1;
  padding: 8px 10px;
  min-width: 170px;
  max-width: 240px;
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
}

.flow-step-title {
  font-weight: 700;
  color: var(--green-dark);
}

.flow-arrow {
  color: #8b7b54;
  font-weight: 700;
}

.help-links {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  display: grid;
  gap: 6px;
}

.help-links h5 {
  margin: 0 0 2px;
}

.help-links a {
  color: #0d4f7a;
  text-decoration: none;
  width: fit-content;
}

.help-links a:hover {
  text-decoration: underline;
}

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

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .help-layout {
    grid-template-columns: 1fr;
  }

  .help-toc {
    position: static;
  }
}

@media (max-width: 640px) {
  .portal-shell {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-block {
    align-items: flex-start;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

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

  .section-panel {
    padding: 14px;
  }

  .audit-filters {
    align-items: stretch;
  }

  .audit-filter-field {
    min-width: 100%;
    max-width: none;
  }

  .modal-overlay {
    padding: 10px;
  }

  .modal-card {
    max-height: calc(100vh - 20px);
  }
}
