:root {
  color-scheme: light;
  --ink: #182026;
  --muted: #68727d;
  --line: #dfe5e8;
  --paper: #fbfcfa;
  --panel: rgba(255, 255, 255, .86);
  --shadow: 0 24px 70px rgba(24, 32, 38, .12);
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(47, 133, 90, .12), transparent 30%),
    linear-gradient(315deg, rgba(218, 119, 6, .12), transparent 34%),
    #eef3f1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell {
  display: block;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 280px;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 18px;
  border-right: 1px solid rgba(24, 32, 38, .08);
  background: rgba(251, 252, 250, .76);
  backdrop-filter: blur(24px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-close, .menu-toggle, .drawer-backdrop { display: none; }

.brand, .nav-item, .admin-chip, .icon-button, .primary-button, .secondary-button, .mobile-dock a {
  display: inline-flex;
  align-items: center;
}

.brand { gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  color: white;
  background: #1f7a53;
  box-shadow: 0 12px 28px rgba(31, 122, 83, .28);
  font-weight: 850;
}

.brand strong, .brand small { display: block; }
.brand small, .eyebrow, .panel-head span, .mini-row small { color: var(--muted); }

.nav-stack { display: grid; gap: 8px; }
.nav-item {
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: #52606b;
  transition: transform .2s ease, background .2s ease, color .2s ease;
}

.nav-item svg { width: 19px; height: 19px; }
.nav-item:hover, .nav-item.active {
  color: #123227;
  background: white;
  box-shadow: 0 12px 30px rgba(24, 32, 38, .08);
  transform: translateX(3px);
}

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(31, 122, 83, .16);
  border-radius: var(--radius);
  background: #e9f6ef;
}

.sidebar-card span, .sidebar-card p { color: #527064; }
.sidebar-card strong { display: block; margin: 5px 0; }
.sidebar-card p { margin: 0; font-size: 13px; line-height: 1.5; }

.workspace {
  min-width: 0;
  margin-left: 280px;
  padding: 26px clamp(18px, 4vw, 44px) 96px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h1 { margin: 4px 0 0; font-size: clamp(28px, 4vw, 44px); letter-spacing: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 800; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.icon-button {
  justify-content: center;
  width: auto;
  padding: 7px;
  border: 1px solid rgba(24, 32, 38, .1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .78);
  color: var(--ink);
  cursor: pointer;
}

.icon-button.compact { padding: 5px; }
.icon-button.danger { color: #b4233d; background: #fff1f3; }
.menu-toggle, .drawer-close { display: none; }
.admin-chip {
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius);
  background: #20262b;
  color: white;
}

.page-flow { display: grid; gap: 22px; }
.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-card {
  display: grid;
  gap: 18px;
  width: min(100%, 560px);
  padding: clamp(20px, 5vw, 34px);
  border: 1px solid rgba(255, 255, 255, .74);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.auth-card h1 {
  margin: 8px 0 8px;
  font-size: clamp(34px, 6vw, 54px);
  line-height: .95;
}

.auth-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.demo-accounts {
  display: grid;
  gap: 8px;
}

.demo-accounts div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.demo-accounts strong, .demo-accounts small { display: block; }
.demo-accounts small { color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }

.hero-panel, .module-hero, .panel, .stat-card, .module-card, .toast {
  border: 1px solid rgba(255, 255, 255, .74);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 24px;
  align-items: center;
  min-height: 280px;
  padding: clamp(22px, 4vw, 42px);
  overflow: hidden;
}

.hero-panel h2, .module-hero h2 {
  max-width: 780px;
  margin: 8px 0 12px;
  font-size: clamp(34px, 7vw, 72px);
  line-height: .94;
  letter-spacing: 0;
}

.hero-panel p, .module-hero p { max-width: 680px; color: var(--muted); line-height: 1.7; }
.hero-signal {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(from 180deg, #1f7a53, #e0a326, #c44569, #2d7dd2, #1f7a53);
  color: white;
  animation: floaty 5s ease-in-out infinite;
}

.hero-signal strong { font-size: 56px; line-height: 1; }
.hero-signal span, .hero-signal small { font-weight: 800; text-transform: uppercase; letter-spacing: .12em; font-size: 11px; }

.stats-grid, .module-grid, .split-grid, .manager-grid {
  display: grid;
  gap: 16px;
}

.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split-grid, .manager-grid { grid-template-columns: minmax(0, 1fr) minmax(320px, .45fr); }
.settings-grid, .member-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .72fr);
  gap: 16px;
}

.stat-card, .module-card, .panel, .module-hero { padding: 18px; }
.stat-card { display: grid; gap: 9px; }
.stat-card p, .stat-card small { margin: 0; color: var(--muted); }
.stat-card strong { font-size: clamp(24px, 3vw, 34px); }
.stat-icon, .module-card span, .module-hero > span {
  display: grid;
  place-items: center;
  width: 44px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: #eef5ef;
  color: #1f7a53;
}

.module-card {
  display: grid;
  gap: 12px;
  min-height: 190px;
  transition: transform .22s ease, box-shadow .22s ease;
}

.module-card:hover { transform: translateY(-5px); box-shadow: 0 30px 80px rgba(24, 32, 38, .16); }
.module-card h3 { margin: 4px 0 0; font-size: 21px; }
.module-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.muted-copy { margin: 0; color: var(--muted); line-height: 1.7; }

.accent-amber span, .accent-amber > span { background: #fff5d9; color: #a86103; }
.accent-blue span, .accent-blue > span { background: #e5f1ff; color: #2064ad; }
.accent-rose span, .accent-rose > span { background: #ffe8ee; color: #b52f55; }
.accent-violet span, .accent-violet > span { background: #f0e9ff; color: #6642b8; }
.accent-slate span, .accent-slate > span { background: #e7ecef; color: #33414a; }

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

.panel-head h3 { margin: 0; font-size: 18px; }
.panel-head a { color: #1f7a53; font-weight: 800; }

.mini-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.mini-row > span {
  display: grid;
  place-items: center;
  width: 38px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: #f1f4f3;
  font-weight: 850;
}

.mini-row strong, .mini-row small { display: block; overflow-wrap: anywhere; }
.module-hero { display: flex; align-items: center; gap: 18px; }
.module-hero h2 { font-size: clamp(32px, 5vw, 58px); }
.toast { display: flex; gap: 10px; align-items: center; padding: 14px 16px; color: #145338; background: #e8f8ee; }

.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 13px 12px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }

.table-tools {
  display: grid;
  gap: 12px;
  min-width: 680px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .72);
}

.table-tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

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

.table-tool-field {
  display: grid;
  gap: 6px;
  min-width: 150px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.table-search-field { flex: 1 1 260px; }

.table-tool-field input,
.table-tool-field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 7px 10px;
  line-height: 1.35;
  outline: none;
}

.table-tool-field input:focus,
.table-tool-field select:focus {
  border-color: #1f7a53;
  box-shadow: 0 0 0 3px rgba(31, 122, 83, .12);
}

.table-pagination {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.table-pagination button,
.table-reset-button,
.table-sort-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.table-pagination button,
.table-reset-button {
  padding: 7px 10px;
  line-height: 1.2;
}

.table-reset-button {
  align-self: end;
  background: #20262b;
  color: white;
}

.table-pagination button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.table-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  line-height: 1.2;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.table-sort-button small {
  color: #1f7a53;
  font-size: 10px;
  letter-spacing: 0;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.row-actions form { margin: 0; }

.stack-form { display: grid; gap: 12px; }
.stack-form label { display: grid; gap: 6px; color: var(--muted); font-weight: 800; font-size: 12px; }
.stack-form input, .stack-form select, .stack-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  background: white;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.stack-form textarea {
  padding: 9px 10px;
  resize: vertical;
}

.primary-button {
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  background: #1f7a53;
  color: white;
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 850;
  cursor: pointer;
}

.secondary-button {
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 850;
}

.secondary-button.compact {
  padding: 6px 9px;
  font-size: 12px;
}

.secondary-button.danger {
  border-color: #ffd7dd;
  background: #fff1f3;
  color: #b4233d;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.wrap-actions {
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius);
  background: #eef7f2;
  color: #145338;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 850;
}

.toggle-list, .upload-grid, .permission-grid, .profile-list {
  display: grid;
  gap: 12px;
}

.toggle-row, .permission-card, .upload-card, .profile-list p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.toggle-row strong, .toggle-row small, .permission-card strong, .permission-card small,
.profile-list span, .profile-list strong {
  display: block;
}

.toggle-row small, .permission-card small, .upload-card small, .profile-list span {
  color: var(--muted);
  font-size: 12px;
}

.profile-upload-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.profile-upload-row img {
  width: 72px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  object-fit: cover;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  aspect-ratio: 54 / 30;
  border: 0;
  border-radius: 999px;
  background: #d7dde0;
  cursor: pointer;
}

.switch span {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  aspect-ratio: 1;
  border-radius: 999px;
  background: white;
  transition: transform .2s ease;
}

.switch.on { background: #1f7a53; }
.switch.on span { transform: translateX(24px); }

.upload-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.upload-card {
  align-items: flex-start;
  flex-direction: column;
}
.upload-card svg { color: #1f7a53; }
.upload-card input { width: 100%; max-width: 100%; }

.permission-grid { grid-template-columns: minmax(0, 1fr); }
.permission-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
}

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

.permission-actions form { margin: 0; }
.permission-pill, .status-chip {
  min-width: 74px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4f6f5;
  color: #52606b;
  font-size: 12px;
  font-weight: 850;
  padding: 6px 9px;
  cursor: pointer;
}

.permission-pill.on, .status-chip.on {
  border-color: rgba(31, 122, 83, .22);
  background: #e8f8ee;
  color: #145338;
}

.mini-modules .module-card { min-height: 160px; }

.mobile-dock { display: none; }
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .55s ease, transform .55s ease; }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(4deg); }
}

@media (max-width: 1120px) {
  .stats-grid, .module-grid, .split-grid, .manager-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid, .member-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    display: flex;
    width: min(86vw, 330px);
    height: 100dvh;
    overflow-y: auto;
    transform: translateX(-104%);
    transition: transform .24s ease;
    background: rgba(251, 252, 250, .96);
    box-shadow: 28px 0 80px rgba(24, 32, 38, .22);
  }
  body.menu-open .sidebar { transform: translateX(0); }
  .drawer-close, .menu-toggle { display: inline-flex; }
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    pointer-events: none;
    opacity: 0;
    background: rgba(24, 32, 38, .36);
    backdrop-filter: blur(5px);
    transition: opacity .22s ease;
  }
  body.menu-open .drawer-backdrop {
    pointer-events: auto;
    opacity: 1;
  }
  .workspace {
    width: 100%;
    max-width: 100vw;
    margin-left: 0;
    padding: 16px 12px 96px;
  }
  .topbar { align-items: flex-start; }
  .admin-chip { display: none; }
  .hero-panel { grid-template-columns: 1fr; min-height: auto; }
  .hero-signal { width: 140px; }
  .stats-grid, .module-grid, .split-grid, .manager-grid, .settings-grid, .member-grid,
  .upload-grid, .permission-grid { grid-template-columns: minmax(0, 1fr); }
  .panel, .module-hero, .hero-panel, .stat-card, .module-card { min-width: 0; }
  .module-hero { align-items: flex-start; }
  .responsive-table { overflow: visible; }
  .table-tools {
    min-width: 0;
    padding: 12px;
  }
  .table-tool-row,
  .table-pagination-row {
    display: grid;
    align-items: stretch;
    justify-content: stretch;
  }
  .table-filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .table-tool-field {
    min-width: 0;
  }
  .table-pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    width: 100%;
  }
  .table-pagination button {
    width: 100%;
  }
  table {
    display: block;
    min-width: 0;
    width: 100%;
  }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tr {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: white;
  }
  td {
    display: grid;
    grid-template-columns: minmax(96px, .42fr) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 0;
    border: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .08em;
  }
  .row-actions { justify-content: flex-start; }
  .stack-form input, .stack-form select, .stack-form textarea { min-width: 0; }
  .mobile-dock {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid rgba(24, 32, 38, .1);
    border-radius: 8px;
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 18px 60px rgba(24, 32, 38, .18);
    backdrop-filter: blur(20px);
  }
  .mobile-dock a {
    justify-content: center;
    min-width: 0;
    padding: 10px 0;
    border-radius: 8px;
    color: #55616b;
  }
  .mobile-dock a.active { color: white; background: #20262b; }
  .permission-card { grid-template-columns: minmax(0, 1fr); }
  .permission-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
  }
  .toggle-row, .profile-list p { align-items: flex-start; }
}

@media (max-width: 520px) {
  .topbar { gap: 12px; }
  .topbar h1 { font-size: 29px; line-height: 1.04; }
  .top-actions { gap: 6px; }
  .icon-button { padding: 7px; }
  .hero-panel h2 { font-size: 38px; }
  .module-hero h2 { font-size: 34px; }
  .module-hero { display: grid; }
  .panel, .module-hero, .hero-panel, .stat-card, .module-card { padding: 14px; }
  td { grid-template-columns: 1fr; }
  .permission-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .permission-pill { width: 100%; }
}
