:root {
  --app-bg: #eef4fb;
  --app-panel: rgba(255, 255, 255, 0.9);
  --app-panel-alt: #f8fbff;
  --app-border: rgba(148, 163, 184, 0.18);
  --app-text: #172033;
  --app-muted: #64748b;
  --app-blue: #2563eb;
  --app-blue-soft: #eaf1ff;
  --app-green: #166534;
  --app-green-soft: #eefbf3;
  --app-amber: #b45309;
  --app-amber-soft: #fff7e8;
  --app-red: #be123c;
  --app-red-soft: #fff1f2;
  --app-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body.app-shell {
  margin: 0;
  min-height: 100vh;
  color: var(--app-text);
  font-family: "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.16), transparent 24rem),
    radial-gradient(circle at bottom left, rgba(20, 184, 166, 0.12), transparent 26rem),
    linear-gradient(180deg, #f7fbff 0%, var(--app-bg) 48%, #edf2f8 100%);
}

a {
  color: inherit;
}

.app-frame {
  max-width: 1640px;
  margin: 0 auto;
  padding: 0.8rem;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.78rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 1rem;
  background: rgba(255, 252, 249, 0.82);
  box-shadow: var(--app-shadow);
  backdrop-filter: blur(18px);
}

.app-topbar-start {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.app-brand {
  display: grid;
  gap: 0.12rem;
  flex: 0 0 auto;
}

.app-brand-mark {
  display: grid;
  gap: 0.18rem;
  text-decoration: none;
  color: inherit;
}

.app-brand-wordmark-text {
  display: inline-flex;
  align-items: baseline;
  font-family: "Sora", "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: clamp(1.32rem, 2.1vw, 1.72rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.075em;
}

.app-brand-act {
  color: #132238;
}

.app-brand-now {
  background: linear-gradient(90deg, #f97316 0%, #dc2626 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-brand-wordmark-line {
  display: block;
  width: clamp(5.2rem, 8vw, 6.9rem);
  height: 0.16rem;
  margin-left: 0.28rem;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(251, 146, 60, 0.92) 0%, rgba(220, 38, 38, 0.92) 100%);
  box-shadow: 0 6px 14px rgba(220, 38, 38, 0.12);
  transform: rotate(-4deg);
  transform-origin: left center;
}

.app-brand-copy {
  font-size: 0.68rem;
  line-height: 1.2;
  color: var(--app-muted);
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 0.18rem;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.app-nav-toggle,
.app-nav-backdrop,
.app-nav-button,
.app-mobile-nav-head,
.app-mobile-only {
  display: none;
}

.app-mobile-drawer {
  display: none;
}

.app-mobile-nav-list {
  display: grid;
  gap: 0.28rem;
}

.app-mobile-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 2.6rem;
  padding: 0.68rem 0.76rem;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: 0.8rem;
  color: #dbe7ff;
  background: rgba(255, 255, 255, 0.04);
}

.app-mobile-nav-link-active {
  color: #ffffff;
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(96, 165, 250, 0.24);
}

.app-nav-link,
.app-link-button,
.app-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.34rem 0.62rem;
  font-size: 0.74rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 0.72rem;
  background: rgba(255, 255, 255, 0.88);
  color: #33465f;
}

.app-nav-link-active {
  color: var(--app-blue);
  background: var(--app-blue-soft);
  border-color: rgba(36, 86, 211, 0.18);
}

.app-topbar-actions,
.page-actions,
.app-card-head,
.app-search,
.app-hero-actions,
.app-tabs,
.app-badge-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.app-user-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.58rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #526173;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

.app-link-button-primary {
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-color: transparent;
}

.app-link-button-danger {
  color: #ffffff;
  background: linear-gradient(135deg, #f97316 0%, #dc2626 100%);
  border-color: transparent;
}

.app-main {
  display: grid;
  gap: 0.72rem;
  padding-top: 0.72rem;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 0.2rem;
}

.page-head h1,
.app-card-title,
.app-hero-title {
  margin: 0;
  font-family: "Sora", "Trebuchet MS", "Segoe UI", sans-serif;
  letter-spacing: -0.04em;
}

.page-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #74839a;
}

.page-subtitle,
.app-card-subtitle {
  margin: 0.12rem 0 0;
  font-size: 0.82rem;
  color: var(--app-muted);
}

.app-alert {
  padding: 0.64rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 0.85rem;
}

.app-alert-success {
  color: var(--app-green);
  border-color: rgba(34, 197, 94, 0.14);
  background: var(--app-green-soft);
}

.app-alert-error {
  color: var(--app-red);
  border-color: rgba(239, 68, 68, 0.16);
  background: var(--app-red-soft);
}

.app-card {
  padding: 0.82rem;
  border: 1px solid var(--app-border);
  border-radius: 0.98rem;
  background: var(--app-panel);
  box-shadow: var(--app-shadow);
  backdrop-filter: blur(16px);
}

.app-card-head {
  justify-content: space-between;
  margin-bottom: 0.72rem;
}

.app-search {
  justify-content: flex-end;
}

.app-search input,
.app-input {
  width: 100%;
  min-width: 0;
  padding: 0.48rem 0.64rem;
  font-size: 0.84rem;
  color: var(--app-text);
  border: 1px solid #d7e0eb;
  border-radius: 0.72rem;
  background: rgba(255, 255, 255, 0.94);
}

.app-search input {
  width: 16rem;
}

.app-textarea {
  min-height: 5.6rem;
  resize: vertical;
}

.app-empty {
  padding: 0.82rem 0.2rem 0.3rem;
  color: var(--app-muted);
}

.app-table-wrap {
  overflow-x: auto;
}

.app-table {
  margin: 0;
  white-space: nowrap;
}

.app-table th {
  padding: 0.48rem 0.56rem;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a8799;
  border-bottom-color: #e7edf4;
}

.app-table td {
  padding: 0.5rem 0.56rem;
  font-size: 0.82rem;
  vertical-align: middle;
  border-bottom-color: #eef2f7;
  color: #243447;
}

.app-table-link {
  font-weight: 600;
  color: #153a8a;
  text-decoration: none;
}

.app-inline-link {
  color: var(--app-blue);
  text-decoration: none;
}

.app-table-actions {
  text-align: right;
}

.app-hero-card {
  display: grid;
  gap: 0.78rem;
}

.app-hero-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.app-hero-title {
  font-size: 1.18rem;
  line-height: 1.08;
}

.app-badge,
.app-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.16rem 0.44rem;
  font-size: 0.63rem;
  font-weight: 700;
  border-radius: 999px;
}

.app-badge-neutral,
.app-tab-count {
  color: #5f7086;
  background: #f4f7fa;
}

.app-badge-good {
  color: var(--app-green);
  background: var(--app-green-soft);
}

.app-badge-warn {
  color: var(--app-amber);
  background: var(--app-amber-soft);
}

.app-badge-danger {
  color: var(--app-red);
  background: var(--app-red-soft);
}

.app-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.app-detail-item {
  display: grid;
  gap: 0.18rem;
  padding: 0.58rem 0.62rem;
  border: 1px solid #ebf0f6;
  border-radius: 0.82rem;
  background: var(--app-panel-alt);
}

.app-detail-label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #7d8ca1;
}

.app-detail-value {
  min-height: 1.2rem;
}

.app-tabs {
  margin-bottom: 0.72rem;
}

.app-tab-active {
  color: var(--app-blue);
  background: var(--app-blue-soft);
  border-color: rgba(36, 86, 211, 0.18);
}

.app-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.74rem 0.82rem;
}

.app-field {
  display: grid;
  gap: 0.24rem;
}

.app-field-wide,
.app-form-actions {
  grid-column: 1 / -1;
}

.app-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #32445e;
}

.app-required {
  color: var(--app-red);
}

.app-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.2rem;
  padding: 0.48rem 0.64rem;
  border: 1px solid #d7e0eb;
  border-radius: 0.72rem;
  background: rgba(255, 255, 255, 0.94);
}

.app-help,
.app-muted {
  margin: 0;
  color: var(--app-muted);
}

.app-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  padding-top: 0.1rem;
}

.app-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.72rem;
}

.app-stat-list {
  display: grid;
  gap: 0.45rem;
}

.app-stat-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.62rem 0.7rem;
  border: 1px solid #ecf1f6;
  border-radius: 0.82rem;
  background: linear-gradient(180deg, #fbfdff 0%, #ffffff 100%);
}

.app-stat-item strong {
  display: block;
  margin-bottom: 0.08rem;
  font-size: 0.78rem;
}

.app-stat-item p {
  margin: 0;
  font-size: 0.68rem;
  color: var(--app-muted);
}

.app-stat-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.24rem 0.56rem;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: 0.7rem;
  color: #274160;
  background: #f4f7fb;
}

.app-stat-value-good {
  color: var(--app-green);
  background: var(--app-green-soft);
}

.app-stat-value-warn {
  color: var(--app-amber);
  background: var(--app-amber-soft);
}

.app-two-column {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 0.72rem;
}

.app-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.app-chip-card {
  display: grid;
  gap: 0.18rem;
  padding: 0.75rem 0.82rem;
  border: 1px solid #ebf0f6;
  border-radius: 0.9rem;
  background: var(--app-panel-alt);
}

.app-chip-label {
  font-size: 0.7rem;
  color: var(--app-muted);
}

.app-chip-card strong {
  font-size: 1.05rem;
}

.help-grid,
.help-object-grid,
.help-kpi-grid {
  display: grid;
  gap: 0.85rem;
}

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

.help-object-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.help-kpi-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.help-callout {
  display: grid;
  gap: 0.18rem;
  padding: 0.82rem 0.9rem;
  margin-bottom: 0.8rem;
  border: 1px solid rgba(36, 86, 211, 0.14);
  border-radius: 0.95rem;
  background: linear-gradient(180deg, #f3f7ff 0%, #ffffff 100%);
}

.help-callout strong,
.help-step strong,
.help-object-card strong,
.help-kpi-item strong {
  font-size: 0.84rem;
}

.help-callout p,
.help-step p,
.help-object-card p,
.help-object-card span,
.help-kpi-item p {
  margin: 0;
  color: var(--app-muted);
}

.help-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.45rem;
}

.help-list li {
  color: #32445e;
}

.help-step-grid {
  display: grid;
  gap: 0.6rem;
}

.help-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.72rem 0.8rem;
  border: 1px solid #ebf0f6;
  border-radius: 0.95rem;
  background: #fbfdff;
}

.help-step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--app-blue);
  border-radius: 999px;
  background: var(--app-blue-soft);
}

.help-object-card,
.help-kpi-item {
  display: grid;
  gap: 0.2rem;
  padding: 0.82rem 0.9rem;
  border: 1px solid #ebf0f6;
  border-radius: 0.95rem;
  background: var(--app-panel-alt);
}

.app-quick-toggle {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

.app-quick-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.34);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  z-index: 40;
}

.app-quick-sheet {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(29rem, calc(100vw - 1.4rem));
  padding: 0.84rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 55px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(18px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(1rem);
  transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s ease;
  z-index: 50;
}

.app-quick-toggle:checked ~ .app-quick-backdrop {
  opacity: 1;
  visibility: visible;
}

.app-quick-toggle:checked ~ .app-quick-sheet {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.app-quick-head,
.app-quick-actions,
.app-quick-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.app-quick-head {
  margin-bottom: 0.72rem;
}

.app-quick-title {
  margin: 0;
  font-family: "Sora", "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 1.06rem;
  letter-spacing: -0.03em;
}

.app-quick-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: 1.15rem;
  line-height: 1;
  color: #516174;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0.72rem;
  background: rgba(255, 255, 255, 0.86);
}

.app-quick-form {
  display: grid;
  gap: 0.7rem;
}

.app-quick-textarea {
  min-height: 4.8rem;
}

.app-quick-context {
  justify-content: flex-start;
}

.app-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  font-size: 2rem;
  line-height: 1;
  color: #ffffff;
  cursor: pointer;
  border-radius: 999px;
  background: linear-gradient(135deg, #f97316 0%, #dc2626 100%);
  box-shadow: 0 20px 34px rgba(220, 38, 38, 0.24);
  z-index: 45;
  user-select: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.app-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 38px rgba(220, 38, 38, 0.28);
}

.auth-shell {
  display: grid;
  min-height: 100vh;
}

.auth-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  width: min(28rem, 100%);
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 1.1rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 26px 60px rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(20px);
}

.auth-brand {
  display: grid;
  gap: 0.2rem;
}

.auth-info {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.auth-form {
  grid-template-columns: 1fr;
}

.auth-actions {
  justify-content: stretch;
}

.auth-actions .app-link-button {
  flex: 1 1 12rem;
}

.auth-help {
  font-size: 0.76rem;
}

@media (display-mode: standalone) {
  .app-frame {
    padding-top: max(0.8rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

@media (max-width: 1180px) {
  .app-topbar {
    flex-wrap: wrap;
  }

  .app-topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .app-detail-grid,
  .app-metric-grid,
  .app-two-column,
  .app-chip-grid,
  .help-grid,
  .help-object-grid,
  .help-kpi-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  body.app-shell {
    background:
      radial-gradient(circle at top right, rgba(37, 99, 235, 0.18), transparent 18rem),
      linear-gradient(180deg, #f7fbff 0%, var(--app-bg) 40%, #edf2f8 100%);
  }

  .app-frame {
    padding: 0.75rem;
  }

  .app-topbar {
    position: sticky;
    top: max(0.35rem, env(safe-area-inset-top));
    z-index: 30;
    gap: 0.5rem;
  }

  .app-topbar-start {
    flex: 1 1 auto;
  }

  .app-nav-button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    width: 2.2rem;
    height: 2.2rem;
    cursor: pointer;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 0.8rem;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  }

  .app-nav-button span {
    display: block;
    width: 0.9rem;
    height: 0.12rem;
    border-radius: 999px;
    background: #33465f;
  }

  .app-nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.34);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    z-index: 40;
  }

  .app-nav {
    display: none;
  }

  .app-mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(18rem, calc(100vw - 2.8rem));
    padding: 0.95rem 0.8rem;
    display: grid;
    align-content: start;
    gap: 0.28rem;
    background:
      linear-gradient(180deg, rgba(37, 99, 235, 0.22), transparent 12rem),
      #0f172a;
    box-shadow: 18px 0 40px rgba(15, 23, 42, 0.3);
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    z-index: 50;
    overflow-y: auto;
  }

  .app-mobile-nav-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.8rem;
    color: #dbe7ff;
  }

  .app-mobile-nav-head strong {
    font-size: 0.92rem;
  }

  .app-mobile-nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    font-size: 1.15rem;
    line-height: 1;
    color: #ffffff;
    cursor: pointer;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 0.72rem;
    background: rgba(255, 255, 255, 0.08);
  }

  .app-mobile-only {
    display: inline-flex;
  }

  .app-nav-toggle:checked ~ .app-nav-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .app-nav-toggle:checked ~ .app-mobile-drawer {
    transform: translateX(0);
  }

  .page-head,
  .app-card-head,
  .app-hero-main {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-actions,
  .app-topbar-actions {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.1rem;
  }

  .app-user-chip,
  .app-topbar-optional {
    display: none;
  }

  .page-actions .app-link-button,
  .app-topbar-actions .app-link-button {
    flex: 0 0 auto;
    min-height: 2.45rem;
    padding-inline: 0.8rem;
    font-size: 0.82rem;
  }

  .app-search {
    width: 100%;
  }

  .app-search input {
    width: 100%;
  }

  .app-form-grid {
    grid-template-columns: 1fr;
  }

  .app-stat-item {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .app-quick-sheet,
  .app-fab {
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .app-quick-sheet {
    width: calc(100vw - 1.5rem);
    max-height: calc(100vh - 1.5rem);
    overflow-y: auto;
  }

  .app-main {
    padding-bottom: 5.5rem;
  }

  .auth-wrap {
    padding: max(0.9rem, env(safe-area-inset-top)) 0.9rem max(1rem, env(safe-area-inset-bottom));
  }

  .auth-card {
    padding: 0.9rem;
  }
}
