:root {
  color-scheme: light;
  --ink: #14211d;
  --muted: #62706a;
  --paper: #f4f5f1;
  --surface: #ffffff;
  --soft: #e9eee9;
  --line: #d6ddd7;
  --green: #173f35;
  --green-2: #245a4b;
  --mint: #bce4d7;
  --teal: #4bb6a4;
  --amber: #d5962f;
  --red: #b84b3d;
  --shadow: 0 18px 48px rgba(20, 33, 29, .12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
svg { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(30px, 4vw, 44px); line-height: 1.05; letter-spacing: 0; }
h2 { margin-bottom: 5px; font-size: 22px; letter-spacing: 0; }
h3 { margin-bottom: 4px; font-size: 17px; letter-spacing: 0; }
.muted { color: var(--muted); line-height: 1.55; }
.muted.compact { margin: 2px 0 14px; font-size: 13px; text-transform: capitalize; }
.eyebrow { margin-bottom: 10px; color: var(--green-2); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
[hidden] { display: none !important; }

.login-view { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: linear-gradient(115deg, #e7eee8 0 48%, #f8f7f2 48%); }
.login-panel { width: min(100%, 420px); padding: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.login-panel h1 { font-size: 34px; }
.brand-mark { display: grid; width: 54px; height: 54px; margin-bottom: 28px; place-items: center; border-radius: 6px; background: var(--green); color: white; font-family: Georgia, serif; font-size: 31px; }
.brand-mark.small { width: 38px; height: 38px; margin: 0; font-size: 22px; }

.form-stack { display: grid; gap: 18px; margin-top: 28px; }
.security-notice { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 30px; padding: 18px 20px; border: 1px solid #e3c489; background: #fff7e7; }
.security-notice p { margin: 5px 0 0; color: #77531d; }
label { display: grid; gap: 8px; color: #37443f; font-size: 13px; font-weight: 750; }
input, select { min-width: 0; min-height: 44px; padding: 0 13px; border: 1px solid #c9d1cb; border-radius: 5px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(75, 182, 164, .16); }
.form-error { margin: 0; padding: 10px 12px; border-left: 3px solid var(--red); background: #fbecea; color: #8b3025; font-size: 13px; line-height: 1.45; }
.form-divider { display: flex; align-items: baseline; gap: 10px; padding-top: 4px; border-top: 1px solid var(--line); }
.form-divider span, label small { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.45; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.button, .icon-button, .text-button, .nav-item { display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 0; }
.button { min-height: 42px; padding: 0 16px; border-radius: 5px; font-weight: 800; }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-2); }
.button.secondary { border: 1px solid #bdc7c0; background: white; color: var(--ink); }
.button.quiet { background: #e9eee9; color: var(--ink); }
.button.danger { border: 1px solid #e8b6ae; background: #fff7f5; color: #9d372b; }
.button.wide { width: 100%; }
.icon-button { width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--ink); }
.text-button { padding: 7px 0; background: transparent; color: var(--green-2); font-weight: 800; }

.app-shell { min-height: 100vh; padding-left: 244px; }
.sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; display: flex; width: 244px; flex-direction: column; padding: 28px 18px 20px; border-right: 1px solid var(--line); background: #eff2ee; }
.brand-lockup { display: flex; align-items: center; gap: 12px; margin: 0 8px 42px; font-size: 16px; line-height: 1.05; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { width: 100%; min-height: 46px; justify-content: flex-start; padding: 0 13px; border-radius: 5px; background: transparent; color: #53615b; font-weight: 750; }
.nav-item:hover, .nav-item.active { background: white; color: var(--green); box-shadow: 0 1px 0 rgba(20, 33, 29, .05); }
.sidebar-foot { margin-top: auto; padding: 18px 8px 0; border-top: 1px solid var(--line); }
.user-name { margin: 0; font-weight: 800; }
.mobile-header { display: none; }

.workspace { width: min(100%, 1500px); margin: 0 auto; padding: 48px clamp(24px, 5vw, 74px) 90px; }
.view { display: none; }
.view.active-view { display: block; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 36px; }
.page-header p:last-child { margin-bottom: 0; }
.stat-band { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 46px; border-block: 1px solid var(--line); }
.stat-band article { min-height: 124px; padding: 24px 26px; border-right: 1px solid var(--line); }
.stat-band article:first-child { padding-left: 0; }
.stat-band article:last-child { border-right: 0; }
.stat-band span { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 750; }
.stat-band strong { font-size: 32px; font-weight: 750; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-head p { margin-bottom: 0; }

.business-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.business-card { display: grid; min-height: 190px; padding: 20px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); text-align: left; }
.business-card:hover { border-color: #9cb3a8; box-shadow: 0 10px 24px rgba(20, 33, 29, .07); }
.business-card .card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.business-card .card-meta { align-self: end; display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 99px; background: #e4eae5; color: #526058; font-size: 11px; font-weight: 850; text-transform: uppercase; }
.status.active { background: #d9eee6; color: #1d6655; }
.status.provisioning { background: #fff0d4; color: #8f5b08; }
.status.suspended, .status.closed { background: #f8dfdc; color: #92382c; }
.empty-state { grid-column: 1 / -1; padding: 46px 20px; border-block: 1px solid var(--line); color: var(--muted); text-align: center; }

.toolbar { display: flex; gap: 12px; margin-bottom: 18px; }
.search-field { position: relative; flex: 1; display: block; }
.search-field svg { position: absolute; top: 13px; left: 14px; color: var(--muted); }
.search-field input { width: 100%; padding-left: 42px; }
.toolbar select { width: 190px; }
.data-list { border-top: 1px solid var(--line); }
.business-row { display: grid; grid-template-columns: minmax(240px, 2fr) 1fr .8fr .7fr 40px; gap: 18px; align-items: center; min-height: 82px; padding: 13px 8px; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.business-row:hover { background: rgba(255,255,255,.68); }
.business-row strong, .business-row small { display: block; }
.business-row small { margin-top: 5px; color: var(--muted); }
.row-label { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }

.activity-list { border-top: 1px solid var(--line); }
.activity-row { display: grid; grid-template-columns: 170px 1.2fr 1fr 2fr; gap: 18px; align-items: start; padding: 18px 6px; border-bottom: 1px solid var(--line); }
.activity-row code { color: var(--green-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.activity-row time, .activity-row small { color: var(--muted); font-size: 13px; }

.dialog { width: min(92vw, 680px); max-height: min(90vh, 860px); padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(20, 33, 29, .42); backdrop-filter: blur(3px); }
.dialog-header { position: sticky; z-index: 2; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px 26px 18px; border-bottom: 1px solid var(--line); background: white; }
.dialog-header h2 { margin-bottom: 0; }
.dialog-body { padding: 24px 26px; }
.dialog-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 16px 26px; border-top: 1px solid var(--line); background: white; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.span-2 { grid-column: span 2; }
.business-dialog { width: min(96vw, 1040px); }
.detail-summary { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 1px; border-block: 1px solid var(--line); background: var(--line); }
.detail-summary article { min-height: 88px; padding: 18px 24px; background: #f8faf7; }
.detail-summary span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.detail-section { padding: 25px 26px; border-bottom: 1px solid var(--line); }
.detail-section:last-child { border-bottom: 0; }
.module-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 17px; }
.module-row { display: grid; grid-template-columns: 1fr auto; gap: 15px; align-items: center; min-height: 90px; padding: 15px; border: 1px solid var(--line); border-radius: 6px; }
.module-row p { margin: 4px 0 0; font-size: 12px; }
.switch-stack { display: grid; gap: 7px; }
.switch { display: inline-grid; grid-template-columns: 38px auto; align-items: center; gap: 7px; font-size: 11px; font-weight: 750; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 38px; height: 22px; border-radius: 99px; background: #cbd3cd; transition: .15s ease; }
.switch-track::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; content: ""; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .15s ease; }
.switch input:checked + .switch-track { background: var(--green-2); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(75,182,164,.25); }
.location-list, .binding-list { display: grid; gap: 8px; margin-top: 15px; }
.user-list { display: grid; gap: 8px; margin-top: 15px; }
.business-user-row { display: grid; grid-template-columns: minmax(220px, 1fr) 130px 130px 40px; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; }
.business-user-row label { display: block; }
.business-user-row select { width: 100%; }
.user-identity strong, .user-identity small { display: block; }
.user-identity small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.business-user-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.compact-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 5px; }
.compact-row small { color: var(--muted); }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 9px; margin-top: 14px; }
.binding-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.binding-form .button, .binding-form .form-error { grid-column: span 2; }

.toast-region { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; width: min(380px, calc(100vw - 40px)); gap: 9px; }
.toast { padding: 13px 15px; border: 1px solid #b9d6cd; border-radius: 6px; background: #effaf6; color: #174c3f; box-shadow: var(--shadow); font-size: 13px; font-weight: 700; }
.toast.error { border-color: #e5b8b1; background: #fff2f0; color: #8d3025; }

@media (max-width: 1050px) {
  .business-grid { grid-template-columns: 1fr 1fr; }
  .module-list { grid-template-columns: 1fr; }
  .business-row { grid-template-columns: minmax(220px, 2fr) 1fr .8fr 40px; }
  .business-row .hide-tablet { display: none; }
}

@media (max-width: 760px) {
  .security-notice { align-items: stretch; flex-direction: column; }
  .login-view { padding: 0; background: white; }
  .login-panel { min-height: 100vh; padding: 38px 24px; border: 0; box-shadow: none; }
  .app-shell { padding: 68px 0 0; }
  .mobile-header { position: fixed; z-index: 20; inset: 0 0 auto; display: flex; height: 68px; align-items: center; justify-content: space-between; padding: 0 17px; border-bottom: 1px solid var(--line); background: #eff2ee; }
  .mobile-header .brand-lockup { margin: 0; }
  .sidebar { z-index: 30; width: min(82vw, 300px); transform: translateX(-105%); box-shadow: var(--shadow); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .workspace { padding: 28px 17px 70px; }
  .page-header { align-items: flex-start; margin-bottom: 26px; }
  .page-header .button span { display: none; }
  .page-header .button { width: 42px; padding: 0; }
  .stat-band { grid-template-columns: 1fr 1fr; }
  .stat-band article { min-height: 96px; padding: 18px; border-bottom: 1px solid var(--line); }
  .stat-band article:nth-child(2) { border-right: 0; }
  .stat-band article:nth-child(3), .stat-band article:nth-child(4) { border-bottom: 0; }
  .business-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar select { width: 100%; }
  .business-row { grid-template-columns: 1fr auto; gap: 10px; padding: 16px 5px; }
  .business-row .mobile-hide { display: none; }
  .activity-row { grid-template-columns: 1fr 1fr; gap: 8px 14px; }
  .activity-row .activity-detail { grid-column: span 2; }
  .form-grid, .binding-form { grid-template-columns: 1fr; }
  .span-2, .binding-form .button, .binding-form .form-error { grid-column: span 1; }
  .dialog { width: 100vw; max-width: none; max-height: 100dvh; margin: auto 0 0; border-radius: 8px 8px 0 0; }
  .business-dialog { height: calc(100dvh - 30px); }
  .dialog-header, .dialog-body, .detail-section { padding-inline: 18px; }
  .dialog-footer { padding-inline: 18px; }
  .detail-summary { grid-template-columns: 1fr 1fr; }
  .detail-summary article:first-child { grid-column: span 2; }
  .inline-form { grid-template-columns: 1fr; }
  .business-user-row { grid-template-columns: 1fr 1fr 40px; }
  .business-user-row .user-identity { grid-column: 1 / -1; }
  .business-user-form { grid-template-columns: 1fr; }
  .business-user-form .span-2 { grid-column: span 1; }
}

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