:root {
  color-scheme: light;
  --bg: #f4f7f7;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --ink: #102526;
  --muted: #6b7c7b;
  --line: #dfe8e6;
  --green: #079d80;
  --green-dark: #067761;
  --green-soft: #e6f7f2;
  --nav: #102d2c;
  --shadow: 0 18px 54px rgba(22, 55, 51, 0.075);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--bg); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.is-loading .app-shell { visibility: hidden; }
.loading-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
body:not(.is-loading) .loading-screen { display: none; }
.loader-mark, .brand-mark { display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #10b895, #05765f); box-shadow: 0 10px 24px rgba(5, 139, 111, .25); font-weight: 850; }
.loader-mark { width: 48px; height: 48px; border-radius: 15px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateY(-4px); } }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 250px; display: flex; flex-direction: column; justify-content: space-between; padding: 28px 18px 22px; color: #fff; background: radial-gradient(circle at 18% 5%, rgba(18, 184, 148, .17), transparent 29%), linear-gradient(180deg, #123433, #0b2525); }
.brand { display: inline-flex; align-items: center; gap: 11px; padding: 0 9px; color: #fff; text-decoration: none; font-size: 21px; font-weight: 800; letter-spacing: -.04em; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; font-size: 17px; letter-spacing: 0; }
.workspace-label { margin: 14px 10px 0; color: #668b87; font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.side-nav { display: grid; gap: 5px; margin-top: 40px; }
.nav-item { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border: 1px solid transparent; border-radius: 12px; color: #91aaa7; background: transparent; text-align: left; font-size: 13px; font-weight: 650; cursor: pointer; transition: 160ms ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-item.is-active { color: #fff; border-color: rgba(23,214,172,.14); background: rgba(19,184,148,.13); }
.sidebar-footer { padding: 17px 11px 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer a { display: flex; align-items: center; gap: 8px; color: #9cb2af; text-decoration: none; font-size: 11px; font-weight: 700; }
.sidebar-footer p { margin: 15px 0 0; color: #6f8e8a; font-size: 10px; }
.sidebar-footer p span { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #25d19b; box-shadow: 0 0 0 4px rgba(37,209,155,.08); }

svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.main-column { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid rgba(209,222,219,.82); background: rgba(255,255,255,.88); backdrop-filter: blur(18px); }
.breadcrumb { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.breadcrumb span::after { content: "/"; margin-left: 10px; color: #bac6c4; }
.breadcrumb strong { color: var(--ink); }
.user-menu { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: linear-gradient(145deg, #20b998, #087c65); font-size: 11px; font-weight: 800; }
.user-copy { min-width: 140px; display: grid; }
.user-copy strong, .user-copy small { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { font-size: 12px; }
.user-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.text-button { padding: 8px 10px; border: 0; color: var(--green-dark); background: transparent; font-size: 11px; font-weight: 750; cursor: pointer; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 12px; color: #607270; background: #fff; cursor: pointer; }
.menu-button { display: none; }

main { width: min(1380px, 100%); margin: 0 auto; padding: 40px 36px 64px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 9px; font-weight: 850; letter-spacing: .15em; }
.page-heading h1 { margin: 0; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.045em; }
.page-heading > div > p:last-child { max-width: 650px; margin: 11px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.primary-button, .secondary-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border-radius: 11px; font-size: 11px; font-weight: 800; cursor: pointer; }
.primary-button { border: 1px solid #07866e; color: #fff; background: linear-gradient(145deg, #0aaa88, #087560); box-shadow: 0 10px 24px rgba(7,139,111,.17); }
.primary-button:hover { filter: brightness(1.03); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button svg { width: 15px; height: 15px; }
.secondary-button { border: 1px solid var(--line); color: #526765; background: #fff; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 32px; }
.stats-grid article { min-height: 108px; display: flex; align-items: center; gap: 15px; padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.83); box-shadow: 0 8px 28px rgba(30,66,62,.035); }
.stat-icon { width: 43px; height: 43px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 13px; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon--green { color: #07846c; background: #e4f5f0; }
.stat-icon--blue { color: #397abf; background: #eaf2fb; }
.stat-icon--purple { color: #7359bd; background: #f0ecfb; }
.stat-icon--orange { color: #ba7528; background: #fbf0df; }
.stats-grid article div { display: grid; gap: 5px; }
.stats-grid strong { font-size: 25px; line-height: 1; letter-spacing: -.04em; }
.stats-grid article div span { color: var(--muted); font-size: 10px; font-weight: 650; }

.view-panel { margin-top: 34px; }
.content-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); box-shadow: var(--shadow); }
.panel-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-heading { padding: 21px 22px; border-bottom: 1px solid #e9efee; }
.panel-heading h2, .section-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.panel-heading p, .section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.search-box { width: min(260px, 100%); height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; color: #879795; background: var(--surface-soft); }
.search-box svg { width: 15px; height: 15px; flex: 0 0 auto; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; }
.search-box input::placeholder { color: #9ba8a6; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 20px; color: #82908e; background: #fafcfc; text-align: left; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
td { padding: 16px 20px; border-top: 1px solid #edf1f0; font-size: 11px; vertical-align: middle; }
tbody tr { transition: background 140ms ease; }
tbody tr:hover { background: #fbfdfc; }
.member-cell { min-width: 230px; display: flex; align-items: center; gap: 11px; }
.member-avatar { width: 37px; height: 37px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: #08745f; background: #e4f5f0; font-size: 10px; font-weight: 850; }
.member-copy { display: grid; gap: 3px; }
.member-copy strong { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.member-copy span { max-width: 260px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.role-chips { min-width: 180px; display: flex; flex-wrap: wrap; gap: 5px; }
.role-chip, .status-badge, .module-state { display: inline-flex; align-items: center; border-radius: 999px; font-size: 8px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
.role-chip { padding: 5px 8px; color: #536765; background: #eef3f2; }
.role-chip--owner { color: #7a5725; background: #f8eedc; }
.status-badge { gap: 6px; padding: 6px 9px; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.status-badge--active { color: #08705c; background: #e7f6f1; }
.status-badge--active::before { background: #10ac82; }
.status-badge--suspended { color: #a04d4d; background: #faeaea; }
.status-badge--suspended::before { background: #d45d5d; }
.status-badge--invited { color: #87641e; background: #fbf1db; }
.status-badge--invited::before { background: #d69a29; }
.status-badge--failed { color: #a04d4d; background: #faeaea; }
.status-badge--failed::before { background: #d45d5d; }
.date-cell { color: var(--muted); white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.row-button { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; color: #526765; background: #fff; font-size: 9px; font-weight: 750; cursor: pointer; white-space: nowrap; }
.row-button:hover { border-color: #badbd3; color: var(--green-dark); }
.row-button--danger:hover { border-color: #e6bcbc; color: #a14444; }
.empty-state { padding: 40px; color: var(--muted); text-align: center; font-size: 12px; }

.section-heading { margin-bottom: 17px; }
.role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.role-card { min-height: 220px; padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); }
.role-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.role-card__icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; color: var(--green-dark); background: var(--green-soft); }
.role-card h3 { margin: 15px 0 6px; font-size: 15px; }
.role-card > p { min-height: 34px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.permission-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 17px; padding-top: 15px; border-top: 1px solid #edf1f0; }
.permission-list span { padding: 5px 7px; border-radius: 7px; color: #667a78; background: #f2f6f5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; }
.permission-count { color: #758683; font-size: 9px; font-weight: 750; }

.module-list { display: grid; gap: 10px; }
.module-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto; align-items: center; gap: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.module-row strong { display: block; font-size: 12px; }
.module-row small { display: block; margin-top: 4px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.module-permission { color: #7c8d8b; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.module-state { padding: 6px 9px; color: #8c6a31; background: #faf0de; }
.module-state--enabled { color: #08705c; background: #e7f6f1; }

.dialog { width: min(540px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 19px; color: var(--ink); background: var(--surface); box-shadow: 0 30px 100px rgba(8,36,34,.25); }
.dialog::backdrop { background: rgba(9,30,29,.5); backdrop-filter: blur(5px); }
.dialog form { padding: 24px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dialog-heading h2 { margin: 0; font-size: 20px; }
.dialog-heading > div > p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.role-options { display: grid; gap: 9px; margin-top: 22px; }
.role-option { display: flex; align-items: flex-start; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.role-option:has(input:checked) { border-color: #9bd5c7; background: #f2fbf8; }
.role-option input { margin-top: 3px; accent-color: var(--green); }
.role-option strong { display: block; font-size: 11px; }
.role-option span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.dialog-note { margin-top: 16px; padding: 11px 13px; border-radius: 10px; color: #85642e; background: #fcf4e6; font-size: 9px; line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.invite-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.form-field { display: grid; gap: 7px; color: #536765; font-size: 10px; font-weight: 750; }
.form-field span strong, .invite-role-fieldset legend strong { color: #bb5e54; }
.form-field input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; outline: none; color: var(--ink); background: var(--surface-soft); font-size: 11px; transition: 150ms ease; }
.form-field input:focus { border-color: #7bcab7; box-shadow: 0 0 0 3px rgba(10,170,136,.08); background: #fff; }
.invite-role-fieldset { min-width: 0; margin: 19px 0 0; padding: 0; border: 0; }
.invite-role-fieldset legend { color: #536765; font-size: 10px; font-weight: 750; }
.invite-role-fieldset .role-options { grid-template-columns: 1fr 1fr; margin-top: 9px; }
.role-option:has(input:disabled) { opacity: .48; cursor: not-allowed; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: min(390px, calc(100vw - 32px)); padding: 13px 16px; border-radius: 12px; color: #fff; background: #122f2e; box-shadow: 0 18px 45px rgba(6,31,29,.24); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 180ms ease; font-size: 11px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: #743b3b; }

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

@media (max-width: 820px) {
  .app-shell { display: block; }
  .main-column { min-width: 0; }
  .sidebar { transform: translateX(-100%); box-shadow: 25px 0 70px rgba(6,29,28,.24); transition: transform 190ms ease; }
  .sidebar.is-open { transform: translateX(0); }
  .menu-button { display: grid; }
  .breadcrumb { display: none; }
  .topbar { padding: 0 18px; }
  main { padding: 30px 18px 48px; }
  .user-copy { display: none; }
  .module-row { grid-template-columns: 1fr auto; }
  .module-permission { display: none; }
}

@media (max-width: 620px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading .primary-button { width: 100%; }
  .stats-grid, .role-grid { grid-template-columns: 1fr; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .search-box { width: 100%; }
  .topbar .text-button { padding-right: 0; }
  th:nth-child(4), td:nth-child(4) { display: none; }
  td { padding: 14px 13px; }
  th { padding: 11px 13px; }
  .row-actions { flex-direction: column; }
  .invite-fields, .invite-role-fieldset .role-options { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
