:root {
  --bg: #0b1117;
  --panel: #121a23;
  --panel-2: #17222d;
  --panel-3: #1d2935;
  --line: rgba(139, 169, 200, 0.18);
  --text: #edf4fb;
  --muted: #9eb1c5;
  --accent: #2ec5b6;
  --accent-2: #50d5c8;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  --bg: #edf3f8;
  --panel: #ffffff;
  --panel-2: #f6f9fc;
  --panel-3: #eef4f9;
  --line: rgba(36, 58, 84, 0.12);
  --text: #162230;
  --muted: #60758a;
  --accent: #0f9f93;
  --accent-2: #27b6aa;
  --shadow: 0 22px 50px rgba(18, 34, 48, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(46, 197, 182, 0.14), transparent 34%),
    linear-gradient(180deg, #0c141c 0%, var(--bg) 28%);
  color: var(--text);
}

body {
  min-height: 100vh;
  overflow: hidden;
}

.login-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.login-shell::before,
.app-shell-home::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(6, 12, 18, 0.18), rgba(6, 12, 18, 0.02) 48%, rgba(6, 12, 18, 0.38)),
    url("/assets/zbgl-field-ops-hero.png") center center / cover no-repeat;
}

.login-shell::after,
.app-shell-home::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 20%, rgba(46, 197, 182, 0.14), transparent 30%),
    linear-gradient(180deg, rgba(11, 17, 23, 0), rgba(11, 17, 23, 0.34));
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 34px;
  display: grid;
  gap: 18px;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.login-title {
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
  font-size: clamp(2rem, 8vw, 2.75rem) !important;
  letter-spacing: -0.03em !important;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.link-button {
  width: max-content;
  border: 0;
  background: transparent;
  color: var(--accent-2);
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
}

.form-message.error {
  color: #ff9f9f;
}

.form-message.warn {
  color: #f6c76d;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.app-shell-home {
  height: calc(100vh - var(--zb-shell-height, 0px));
  height: calc(100dvh - var(--zb-shell-height, 0px));
  min-height: 0;
  padding-top: 42px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.app-shell-home.settings-mode {
  overflow: auto;
  background: var(--bg);
}

.app-shell-home.settings-mode::before,
.app-shell-home.settings-mode::after {
  display: none;
}

.app-shell-home > * {
  position: relative;
  z-index: 1;
}

.app-shell-home .topbar {
  padding-top: 34px;
}

.app-shell-home > .topbar .topbar-actions {
  display: none;
}

.app-shell-home .topbar h1,
.home-title-card,
.landing-card h2,
.settings-grid h2,
.settings-grid h3 {
  margin: 0;
  letter-spacing: -0.04em;
}

.landing-card {
  display: inline-block;
  width: fit-content;
  max-width: min(980px, calc(100vw - 56px));
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(16px);
}

.landing-card h2 {
  font-size: clamp(2.2rem, 5vw, 4.7rem);
  line-height: 0.92;
  overflow-wrap: anywhere;
}

.home-title-card {
  display: inline-block;
  width: fit-content;
  max-width: min(760px, calc(100vw - 56px));
  padding: 12px 18px;
  border-radius: 18px;
  overflow-wrap: anywhere;
}

:root[data-theme="light"] .app-shell-home .topbar h1,
:root[data-theme="light"] .home-title-card {
  display: inline-block;
  width: fit-content;
  max-width: min(760px, calc(100vw - 56px));
  padding: 12px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

:root[data-theme="light"] .landing-card {
  background: rgba(255, 255, 255, 0.92);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(12, 18, 25, 0.92);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand-block h1,
.topbar h2,
.section-head h3,
.hero-card h3 {
  margin: 0;
  letter-spacing: -0.04em;
}

.brand-block p,
.muted {
  color: var(--muted);
}

.eyebrow,
.metric-label,
.label {
  color: var(--accent-2);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.nav-stack {
  display: grid;
  gap: 10px;
}

.nav-btn,
.btn,
.pill-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.nav-btn:hover,
.btn:hover,
.pill-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(46, 197, 182, 0.34);
}

.nav-btn.is-active,
.pill-btn.is-active,
.btn.btn-primary {
  background: linear-gradient(180deg, rgba(46, 197, 182, 0.28), rgba(46, 197, 182, 0.14));
  border-color: rgba(46, 197, 182, 0.45);
}

.btn.btn-ghost {
  background: transparent;
}

.sidebar-card,
.hero-card,
.hero-side,
.section-card,
.table-card,
.workspace-card,
.metric-card,
.mini-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.sidebar-card {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.input,
.textarea,
select {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
}

.password-control {
  position: relative;
  width: 100%;
}

.password-control .input {
  padding-right: 76px;
}

.password-control.compact .input {
  min-width: 180px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  border-radius: 10px;
  background: rgba(58, 208, 192, 0.14);
  color: var(--accent);
  font-weight: 800;
  font-size: 12px;
  padding: 7px 10px;
  cursor: pointer;
}

.password-toggle:hover {
  background: rgba(58, 208, 192, 0.24);
}

.toggle-row,
.topbar-actions,
.hero-actions,
.card-actions,
.workspace-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.main-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  padding: 26px 28px 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  font-size: 0.88rem;
}

.view-panel {
  padding: 22px 28px 28px;
  display: grid;
  gap: 22px;
}

.hidden {
  display: none !important;
}

body.auth-boot #loginShell,
body.auth-boot #appShell {
  display: none !important;
}

.password-rule {
  margin: -4px 0 2px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
  gap: 22px;
}

.hero-card,
.hero-side,
.section-card,
.table-card {
  padding: 22px;
}

.metric-grid,
.roadmap-grid,
.workspace-grid,
.settings-grid {
  display: grid;
  gap: 18px;
}

.metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric-card strong {
  font-size: 2rem;
  letter-spacing: -0.05em;
}

.roadmap-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-card {
  padding: 18px;
}

.workspace-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.workspace-card {
  padding: 20px;
  display: grid;
  gap: 14px;
}

.workspace-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  border: 1px solid var(--line);
  background: var(--panel-3);
}

.badge.teal { background: rgba(46, 197, 182, 0.16); }
.badge.blue { background: rgba(67, 140, 245, 0.16); }
.badge.amber { background: rgba(237, 173, 71, 0.18); }
.badge.violet { background: rgba(170, 109, 255, 0.18); }
.badge.green { background: rgba(85, 200, 118, 0.16); }

.module-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.settings-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}

.settings-card-wide {
  grid-column: span 8;
}

.settings-appearance-card {
  grid-column: span 6;
}

.settings-bethpage-card {
  grid-column: span 6;
}

.settings-summary-card {
  grid-column: 1 / -1;
  grid-row: 1;
}

.settings-oracle-card {
  grid-column: span 4;
}

.settings-card-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.settings-kicker {
  display: block;
  margin-bottom: 7px;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.settings-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--accent) 15%, var(--panel-2));
  color: var(--accent-2);
  font-weight: 900;
}

.bethpage-add-row {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.bethpage-account-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  max-height: 314px;
  overflow: auto;
  padding-right: 4px;
}

.bethpage-account-row {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-2) 88%, transparent);
}

.bethpage-account-row.is-unavailable {
  border-color: rgba(237, 173, 71, 0.46);
}

.bethpage-account-mark,
.user-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 19%, var(--panel-3));
  color: var(--accent-2);
  font-weight: 800;
}

.bethpage-account-mark {
  width: 34px;
  height: 34px;
  font-size: 0.72rem;
}

.bethpage-account-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.bethpage-account-copy strong,
.bethpage-account-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bethpage-account-copy small {
  color: var(--muted);
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-3);
  color: var(--muted);
  font: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(255, 120, 120, 0.55);
  color: #ff9f9f;
}

.bethpage-empty,
.user-directory-empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.settings-save-strip {
  min-height: 32px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 0.82rem;
}

.save-state {
  color: var(--accent-2);
}

.save-state.is-saving {
  color: #f6c76d;
}

.save-state.is-error {
  color: #ff9f9f;
}

.table-card.flat {
  padding: 0;
  box-shadow: none;
  border: 0;
  overflow: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}

.user-table input[type="checkbox"] {
  width: 22px;
  height: 22px;
}

.user-table th,
.user-table td {
  border-bottom: 1px solid var(--line);
  padding: 14px 10px;
  text-align: left;
  vertical-align: top;
}

.user-directory-card {
  padding: 0;
  overflow: hidden;
}

.user-directory-card > .section-head,
.user-directory-toolbar,
.user-directory-meta,
.user-directory-actions {
  padding-left: 22px;
  padding-right: 22px;
}

.user-directory-card > .section-head {
  padding-top: 22px;
}

.user-directory-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, 0.75fr));
  gap: 10px;
  margin-top: 18px;
}

.user-directory-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.82rem;
}

.user-directory-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 2px 22px 16px;
  max-height: min(620px, 62vh);
  overflow: auto;
}

.user-directory-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(0, 2.5fr);
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel-2) 90%, transparent);
}

.user-directory-identity {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-content: start;
  align-items: center;
}

.user-avatar {
  width: 40px;
  height: 40px;
  grid-row: span 2;
}

.user-directory-identity > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.user-directory-identity strong,
.user-directory-identity span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-directory-identity > div span {
  color: var(--muted);
  font-size: 0.82rem;
}

.user-status-dot {
  grid-column: 2;
  width: max-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(85, 200, 118, 0.14);
  color: #8ee7a4;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.user-status-dot.is-inactive {
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  color: var(--muted);
}

.user-directory-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.user-directory-fields .field > span,
.user-security-fields .field > span {
  font-size: 0.75rem;
  color: var(--muted);
}

.user-dashboard-permissions {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.user-dashboard-permissions summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0 12px;
}

.user-permission-save {
  grid-column: 1 / -1;
  justify-self: end;
  align-self: start;
  min-width: 160px;
  max-width: 260px;
}

.user-permission-message {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.user-security-panel {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.user-notification-setting {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  gap: 14px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 64%, transparent);
}

.user-notification-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.user-notification-copy strong {
  font-size: 0.8rem;
}

.user-notification-copy small {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.user-notification-setting .input {
  min-width: 0;
  width: 100%;
}

.user-security-panel summary {
  width: max-content;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
}

.user-security-fields {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.checkbox-field {
  min-height: 42px;
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.checkbox-field input {
  width: 20px;
  height: 20px;
}

.user-directory-actions {
  position: sticky;
  bottom: 0;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  padding-bottom: 18px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(14px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.role-note {
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .hero-grid,
  .roadmap-grid,
  .settings-grid,
  .metric-grid.compact {
    grid-template-columns: 1fr;
  }

  .settings-card-wide,
  .settings-appearance-card,
  .settings-bethpage-card,
  .settings-summary-card,
  .settings-oracle-card {
    grid-column: 1 / -1;
  }

  .user-directory-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .view-panel {
    padding-left: 16px;
    padding-right: 16px;
  }

  .field-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .bethpage-add-row,
  .user-directory-toolbar,
  .user-directory-row,
  .user-directory-fields,
  .user-security-fields {
    grid-template-columns: 1fr;
  }

  .user-directory-identity,
  .user-security-panel {
    grid-column: 1;
  }

  .settings-card-heading,
  .user-directory-card > .section-head,
  .user-directory-meta,
  .user-directory-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

:root[data-theme="light"] html,
:root[data-theme="light"] body {
  background:
    radial-gradient(circle at top left, rgba(15, 159, 147, 0.14), transparent 34%),
    linear-gradient(180deg, #f8fbfd 0%, var(--bg) 32%);
}

:root[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.9);
}

:root[data-theme="light"] .input,
:root[data-theme="light"] .textarea,
:root[data-theme="light"] select {
  background: #ffffff;
  border-color: rgba(36, 58, 84, 0.16);
  color: var(--text);
}

:root[data-theme="light"] .input::placeholder,
:root[data-theme="light"] .textarea::placeholder {
  color: #7a8da1;
}

:root[data-theme="light"] .btn.btn-ghost {
  background: #eef3f7;
  color: #31465b;
}

:root[data-theme="light"] .nav-btn.is-active,
:root[data-theme="light"] .pill-btn.is-active,
:root[data-theme="light"] .btn.btn-primary {
  background: rgba(15, 159, 147, 0.14);
  border-color: rgba(15, 159, 147, 0.35);
  color: #0f625a;
}

:root[data-theme="light"] .status-pill,
:root[data-theme="light"] .badge {
  color: #31465b;
}

:root[data-theme="light"] .form-message.error {
  color: #b34747;
}

:root[data-theme="light"] .form-message.warn {
  color: #8a5a00;
}

/* Keep the welcome card clear of the delivery scene. */
body.zb-dashboard-system .app-shell-home .landing-card {
  width: fit-content; max-width: min(90%, 640px); padding: 14px 22px;
}
body.zb-dashboard-system .app-shell-home .landing-card #welcomeTitle {
  margin: 0; font-size: clamp(1.5rem, 2.4vw, 2.5rem); line-height: 1.2;
}
