:root {
  color-scheme: light;
  --bg: #f2f6f8;
  --surface: #ffffff;
  --surface-alt: #f7fafb;
  --surface-strong: #e9f1f4;
  --text: #172033;
  --muted: #667085;
  --border: #d5e0e5;
  --border-strong: #bdcdd5;
  --primary: #007a9f;
  --primary-hover: #006482;
  --primary-soft: #dff3f8;
  --navy: #202a44;
  --navy-strong: #151d31;
  --blue: #315fb8;
  --blue-soft: #e8eefb;
  --amber: #a96000;
  --amber-soft: #fff1d7;
  --rose: #b4233f;
  --rose-soft: #fde7ec;
  --green: #13795b;
  --green-soft: #ddf4eb;
  --shadow-sm: 0 1px 2px rgba(23, 32, 51, 0.05);
  --shadow-md: 0 10px 28px rgba(23, 32, 51, 0.08);
  --shadow-lg: 0 22px 56px rgba(12, 22, 39, 0.18);
  --radius: 10px;
  --radius-sm: 8px;
  --sidebar-width: 252px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1421;
  --surface: #151f30;
  --surface-alt: #192537;
  --surface-strong: #223044;
  --text: #f2f5f8;
  --muted: #a8b3c4;
  --border: #2c3b50;
  --border-strong: #42536b;
  --primary: #45c4e9;
  --primary-hover: #70d4ef;
  --primary-soft: rgba(69, 196, 233, 0.14);
  --navy: #111a2a;
  --navy-strong: #0a101b;
  --blue: #87a9f2;
  --blue-soft: rgba(86, 125, 211, 0.16);
  --amber: #f4b04f;
  --amber-soft: rgba(244, 176, 79, 0.14);
  --rose: #f17891;
  --rose-soft: rgba(241, 120, 145, 0.14);
  --green: #5bd1a9;
  --green-soft: rgba(91, 209, 169, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.has-menu-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: inherit;
}

svg {
  display: block;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
strong {
  text-wrap: balance;
}

h1 {
  margin-bottom: 5px;
  font-size: clamp(1.65rem, 2.2vw, 2.2rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 5px;
  font-size: 1.08rem;
  line-height: 1.3;
  letter-spacing: -0.012em;
}

.is-auth-hidden,
.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  border-radius: var(--radius-sm);
  background: var(--navy-strong);
  color: #ffffff;
  font-weight: 800;
  padding: 10px 14px;
  text-decoration: none;
  transition: transform 160ms ease;
}

body:not(.is-dashboard-visible) .skip-link {
  display: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow.light {
  color: #76daf3;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.45;
}

.danger-text {
  color: var(--rose);
}

/* Login */

.login-screen {
  position: relative;
  display: grid;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-padding-bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px));
  padding:
    max(26px, calc(env(safe-area-inset-top) + 20px))
    max(22px, calc(env(safe-area-inset-right) + 14px))
    max(26px, calc(env(safe-area-inset-bottom) + 20px))
    max(22px, calc(env(safe-area-inset-left) + 14px));
  background:
    radial-gradient(circle at 14% 12%, rgba(57, 188, 225, 0.22), transparent 28%),
    radial-gradient(circle at 86% 84%, rgba(49, 95, 184, 0.2), transparent 30%),
    linear-gradient(135deg, var(--navy-strong), #1f304f 62%, #163750);
}

.login-screen::before,
.login-screen::after {
  position: absolute;
  width: 320px;
  height: 320px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.login-screen::before {
  top: -180px;
  right: 8%;
}

.login-screen::after {
  bottom: -220px;
  left: 3%;
  width: 440px;
  height: 440px;
}

.login-layout {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(1180px, 100%);
  max-height: 100%;
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, 0.72fr);
  align-items: center;
  gap: clamp(42px, 8vw, 110px);
}

.login-intro {
  color: #ffffff;
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-bottom: clamp(42px, 8vh, 84px);
}

.login-intro-logo {
  width: 82px;
  height: 58px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.96);
  object-fit: contain;
  object-position: center;
  padding: 3px;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.18));
}

.login-brand span {
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  padding-left: 14px;
  text-transform: uppercase;
}

.login-intro-copy {
  max-width: 650px;
}

.login-intro-copy h1 {
  max-width: 620px;
  margin-bottom: 20px;
  color: #ffffff;
  font-size: clamp(2.45rem, 5vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.login-intro-copy > p:last-child {
  max-width: 600px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 1.05rem;
  line-height: 1.65;
}

.login-benefits {
  display: grid;
  gap: 14px;
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
}

.login-benefits li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.9rem;
  font-weight: 650;
}

.benefit-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(118, 218, 243, 0.3);
  border-radius: var(--radius-sm);
  background: rgba(118, 218, 243, 0.1);
  color: #76daf3;
}

.benefit-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.login-intro-footer {
  margin: clamp(40px, 8vh, 72px) 0 0;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.login-card {
  display: grid;
  gap: 18px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-lg);
  color: #172033;
  padding: clamp(24px, 4vw, 38px);
}

.login-card[data-step="connection"] {
  gap: 14px;
  padding-block: 24px;
}

.login-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.login-logo {
  width: 112px;
  height: 72px;
  object-fit: contain;
  object-position: left center;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border-radius: 999px;
  background: #eef2f5;
  color: #667085;
  font-size: 0.72rem;
  font-weight: 750;
  padding: 6px 10px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #98a2b3;
  box-shadow: 0 0 0 3px rgba(152, 162, 179, 0.14);
}

[data-status="online"] .status-dot {
  background: #16a06f;
  box-shadow: 0 0 0 3px rgba(22, 160, 111, 0.14);
}

[data-status="offline"] .status-dot {
  background: #d04458;
  box-shadow: 0 0 0 3px rgba(208, 68, 88, 0.14);
}

[data-status="checking"] .status-dot {
  animation: pulse 1.3s ease-in-out infinite;
}

.login-heading {
  margin-top: 4px;
}

.login-heading h2 {
  margin-bottom: 8px;
  color: #172033;
  font-size: 1.7rem;
  letter-spacing: -0.035em;
}

.login-heading > p:last-child {
  margin-bottom: 0;
  color: #667085;
  font-size: 0.9rem;
  line-height: 1.5;
}

.connection-profile-panel {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  border: 1px solid #d9e2e7;
  border-radius: 12px;
  background: #f7fafb;
  padding: 8px 9px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.connection-profile-panel:focus-within {
  border-color: #58a9bf;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 122, 159, 0.1);
}

.new-connection-panel {
  display: flex;
  min-width: 0;
  min-height: 54px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(0, 122, 159, 0.2);
  border-radius: 12px;
  background: rgba(0, 122, 159, 0.06);
  padding: 8px 9px;
}

.new-connection-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: rgba(0, 122, 159, 0.12);
  color: #007a9f;
}

.new-connection-icon svg,
.new-connection-cancel svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.new-connection-copy {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  gap: 1px;
}

.new-connection-copy strong,
.new-connection-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-connection-copy strong {
  color: #172033;
  font-size: 0.78rem;
}

.new-connection-copy small {
  color: #667085;
  font-size: 0.66rem;
}

.new-connection-cancel {
  display: inline-flex;
  min-height: 44px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid #b9c8cf;
  border-radius: 9px;
  background: #ffffff;
  color: #344054;
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0 8px 0 5px;
}

.new-connection-cancel:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.connection-profile-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: rgba(0, 122, 159, 0.1);
  color: #007a9f;
}

.connection-profile-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.connection-profile-select {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  gap: 1px;
  color: #344054;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.connection-profile-select select {
  width: 100%;
  height: 25px;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #172033;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 750;
  letter-spacing: normal;
  padding: 0 24px 0 0;
}

.connection-profile-select select:focus {
  box-shadow: none;
}

.connection-profile-actions {
  display: flex;
  position: relative;
  flex: 0 0 auto;
  gap: 6px;
  border-left: 1px solid #d9e2e7;
  padding-left: 8px;
}

.connection-actions-toggle {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid #ccd6dc;
  border-radius: 9px;
  background: #ffffff;
  color: #344054;
  cursor: pointer;
}

.connection-actions-toggle:hover:not(:disabled),
.connection-actions-toggle[aria-expanded="true"] {
  border-color: #007a9f;
  background: rgba(0, 122, 159, 0.06);
  color: #007a9f;
}

.connection-actions-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.connection-actions-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.connection-actions-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: 196px;
  gap: 3px;
  border: 1px solid #d4dee3;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(17, 32, 51, 0.18);
  padding: 6px;
}

.connection-actions-menu::before {
  position: absolute;
  top: -5px;
  right: 13px;
  width: 9px;
  height: 9px;
  border-top: 1px solid #d4dee3;
  border-left: 1px solid #d4dee3;
  background: #ffffff;
  content: "";
  transform: rotate(45deg);
}

.profile-action-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid #ccd6dc;
  border-radius: 9px;
  background: #ffffff;
  color: #344054;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0 8px;
}

.connection-actions-menu .profile-action-button {
  width: 100%;
  min-height: 44px;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  padding: 0 10px;
}

.connection-actions-menu .profile-action-button:hover:not(:disabled) {
  background: #f2f7f9;
}

.connection-actions-menu .profile-action-button.danger {
  color: #a51d37;
}

.connection-actions-menu .profile-action-button.danger:hover:not(:disabled) {
  background: #fff1f3;
}

.profile-return-button {
  padding-inline: 7px 9px;
}

.profile-action-button:hover:not(:disabled) {
  border-color: #007a9f;
  color: #007a9f;
}

.profile-action-button.danger:hover:not(:disabled) {
  border-color: #b4233f;
  color: #b4233f;
}

.profile-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.profile-action-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.login-progress {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef1;
}

.login-progress span {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #007a9f, #23afd2);
  transition: width 220ms ease;
}

.login-card[data-step="credentials"] .login-progress span {
  width: 100%;
}

.login-step-label {
  margin: -10px 0 0;
  color: #667085;
  font-size: 0.72rem;
  font-weight: 750;
}

.login-field {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 0.8rem;
  font-weight: 800;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.input-shell > svg,
.search-field > svg {
  position: absolute;
  z-index: 1;
  left: 13px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #7c8998;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  pointer-events: none;
}

.login-field input {
  width: 100%;
  height: 48px;
  border: 1px solid #ccd6dc;
  border-radius: var(--radius-sm);
  outline: none;
  background: #ffffff;
  color: #172033;
  font-size: 0.94rem;
  padding: 0 44px 0 42px;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.login-field input::placeholder {
  color: #98a2b3;
}

.login-field input:focus {
  border-color: #007a9f;
  box-shadow: 0 0 0 3px rgba(0, 122, 159, 0.13);
}

.login-field input:read-only {
  background: #f4f7f8;
  color: #667085;
}

.credential-fields {
  display: grid;
  gap: 15px;
}

.remember-login-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #d7e0e5;
  border-radius: var(--radius-sm);
  background: #f7fafb;
  color: #344054;
  cursor: pointer;
  padding: 10px 12px;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.remember-login-option:hover {
  border-color: rgba(0, 122, 159, 0.4);
  background: rgba(0, 122, 159, 0.05);
}

.remember-login-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.remember-login-box {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  border: 1.5px solid #98a2b3;
  border-radius: 6px;
  background: #ffffff;
  color: #ffffff;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.remember-login-box svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
  opacity: 0;
  transform: scale(0.75);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.remember-login-option input:checked + .remember-login-box {
  border-color: #007a9f;
  background: #007a9f;
}

.remember-login-option input:checked + .remember-login-box svg {
  opacity: 1;
  transform: scale(1);
}

.remember-login-option input:focus-visible + .remember-login-box {
  box-shadow: 0 0 0 3px rgba(0, 122, 159, 0.18);
}

.remember-login-option:has(input:disabled),
.remember-login-option.is-disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.remember-login-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.remember-login-copy strong {
  font-size: 0.78rem;
}

.remember-login-copy small {
  color: #667085;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.35;
}

.connection-fields {
  display: grid;
  gap: 12px;
}

.connection-address-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 12px;
}

.login-card[data-step="connection"] .login-field input {
  height: 44px;
}

#dbPortInput {
  padding-right: 12px;
}

.password-toggle {
  position: absolute;
  z-index: 2;
  right: 5px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: #667085;
  cursor: pointer;
}

.password-toggle:hover {
  background: #eef3f5;
  color: #172033;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.login-error {
  min-height: 20px;
  margin: -2px 0;
  color: #a91f38;
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.4;
  opacity: 0;
}

.login-error.is-visible {
  opacity: 1;
}

.connection-test-result {
  display: none;
  align-items: flex-start;
  gap: 7px;
  margin: -2px 0;
  color: #087452;
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.4;
}

.connection-test-result::before {
  flex: 0 0 auto;
  content: "\2713";
  font-weight: 900;
}

.connection-test-result.is-visible {
  display: flex;
}

.connection-diagnostics {
  border: 1px solid #d6e0e5;
  border-radius: 8px;
  background: #f8fbfc;
  color: #344054;
  font-size: 0.72rem;
}

.connection-diagnostics > summary {
  min-height: 44px;
  cursor: pointer;
  font-weight: 800;
  line-height: 44px;
  padding: 0 12px;
}

.connection-diagnostics dl {
  display: grid;
  gap: 7px;
  border-top: 1px solid #d6e0e5;
  margin: 0;
  padding: 10px 12px 12px;
}

.connection-diagnostics dl > div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
}

.connection-diagnostics dt {
  color: #667085;
  font-weight: 700;
}

.connection-diagnostics dd {
  overflow-wrap: anywhere;
  margin: 0;
  font-weight: 750;
}

.login-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.login-actions:has(.secondary:not(.is-hidden)),
.login-actions.has-secondary {
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
}

.login-submit {
  width: 100%;
}

.login-card .tool-button.secondary {
  border-color: #ccd6dc;
  background: #ffffff;
  color: #344054;
}

.button-spinner {
  display: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.login-card.is-loading .button-spinner {
  display: block;
}

.login-card.is-testing .test-connection-spinner {
  display: block;
  border-color: rgba(0, 122, 159, 0.25);
  border-top-color: #007a9f;
}

.login-card.is-testing .test-connection-icon {
  display: none;
}

.login-card.is-loading .button-arrow {
  display: none;
}

.button-arrow {
  margin-left: auto;
}

.login-security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  color: #7c8998;
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: center;
}

.login-security-note svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

/* Shared controls */

.tool-button,
.icon-button,
.range-button,
.sidebar-logout {
  touch-action: manipulation;
}

.tool-button {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
  padding: 0 15px;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

.tool-button:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(0, 122, 159, 0.18);
  transform: translateY(-1px);
}

.tool-button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.tool-button.secondary:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: none;
}

.tool-button svg,
.icon-button svg,
.sidebar-logout svg,
.nav-link svg,
.metric-icon svg,
.error-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.tool-button:disabled,
.icon-button:disabled,
.range-button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.tool-button:focus-visible,
.icon-button:focus-visible,
.range-button:focus-visible,
.nav-link:focus-visible,
.sidebar-logout:focus-visible,
.history-row:focus-visible,
.password-toggle:focus-visible,
.connection-actions-toggle:focus-visible,
.profile-action-button:focus-visible,
.new-connection-cancel:focus-visible,
.cancellation-card-summary:focus-visible,
.chart-data-details > summary:focus-visible,
.toggle-chip input:focus-visible + span,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(0, 122, 159, 0.32);
  outline: 3px solid color-mix(in srgb, var(--primary) 32%, transparent);
  outline-offset: 2px;
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--rose) !important;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

/* Dashboard shell */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.sidebar {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  overflow-y: auto;
  background:
    radial-gradient(circle at 20% 0%, rgba(69, 196, 233, 0.09), transparent 26%),
    var(--navy-strong);
  color: #ffffff;
  padding:
    max(20px, calc(env(safe-area-inset-top) + 14px))
    max(16px, calc(env(safe-area-inset-right) + 10px))
    max(18px, calc(env(safe-area-inset-bottom) + 14px))
    max(16px, calc(env(safe-area-inset-left) + 10px));
}

.sidebar-brand {
  display: flex;
  min-height: 68px;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  margin: 0 2px 22px;
  padding: 0 4px 18px;
  text-decoration: none;
}

.sidebar-brand img {
  width: 72px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.96);
  object-fit: contain;
  padding: 3px;
}

.sidebar-brand span {
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding-left: 11px;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 5px;
}

.nav-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 11px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0 12px;
  text-decoration: none;
  transition:
    background 150ms ease,
    color 150ms ease;
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(69, 196, 233, 0.11);
  color: #ffffff;
}

.nav-link.is-active {
  box-shadow: inset 3px 0 0 #45c4e9;
}

.nav-link svg {
  width: 19px;
  height: 19px;
  color: #6ed3ef;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: 26px;
}

.connection-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.045);
  padding: 11px;
}

.connection-card .status-dot {
  margin-top: 4px;
}

.connection-card > div,
.user-card > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.connection-card strong,
.user-card strong {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-card span:last-child,
.user-card span:last-child {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.47);
  font-size: 0.66rem;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  padding: 14px 5px 2px;
}

.user-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #007a9f, #45c4e9);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
}

.sidebar-logout {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0 10px;
  text-align: left;
}

.sidebar-logout:hover {
  background: rgba(241, 120, 145, 0.1);
  color: #ff9aad;
}

.sidebar-backdrop {
  display: none;
}

.workspace {
  min-width: 0;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  padding:
    max(14px, env(safe-area-inset-top))
    max(clamp(18px, 3vw, 36px), calc(env(safe-area-inset-right) + 12px))
    14px
    max(clamp(18px, 3vw, 36px), calc(env(safe-area-inset-left) + 12px));
}

.topbar-title-group {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.topbar-title-group > div {
  min-width: 0;
}

.topbar .eyebrow {
  overflow: hidden;
  max-width: min(58vw, 720px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-label {
  overflow: hidden;
  max-width: min(58vw, 720px);
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-data-status {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 2px 9px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 650;
  line-height: 1.3;
}

.topbar-data-status span {
  overflow: hidden;
  max-width: min(46vw, 520px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#topbarLastUpdated::before {
  content: "· ";
}

.dashboard-company-name {
  overflow: hidden;
  max-width: min(58vw, 720px);
  margin: 1px 0 2px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 850;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
}

.mobile-menu-button {
  display: none;
}

.theme-moon {
  display: none;
}

:root[data-theme="dark"] .theme-sun {
  display: none;
}

:root[data-theme="dark"] .theme-moon {
  display: block;
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding:
    22px
    max(clamp(14px, 2.8vw, 36px), calc(env(safe-area-inset-right) + 10px))
    max(34px, calc(env(safe-area-inset-bottom) + 24px))
    max(clamp(14px, 2.8vw, 36px), calc(env(safe-area-inset-left) + 10px));
}

.loading-banner,
.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  padding: 12px 14px;
}

.loading-banner {
  border: 1px solid var(--border-strong);
  border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border));
  background: var(--primary-soft);
  color: var(--text);
}

.error-banner {
  border: 1px solid var(--border-strong);
  border: 1px solid color-mix(in srgb, var(--rose) 38%, var(--border));
  background: var(--rose-soft);
  color: var(--text);
}

.loading-banner > div,
.error-banner > div {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

.loading-banner strong,
.error-banner strong {
  font-size: 0.86rem;
}

.loading-banner span,
.error-banner span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.loading-spinner {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 3px solid var(--border);
  border: 3px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.error-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--rose-soft);
  background: color-mix(in srgb, var(--rose) 14%, transparent);
  color: var(--rose);
}

.query-progress {
  display: block;
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  margin-top: 7px;
  background: var(--surface-strong);
}

.query-progress > span {
  display: block;
  width: 4%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 220ms ease;
}

.cancel-query-button {
  flex: 0 0 auto;
}

.refresh-button.is-spinning svg {
  animation: spin 800ms linear infinite;
}

/* Filters */

.filter-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  padding: 16px;
}

.filter-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.filter-panel-heading h2 {
  margin-bottom: 2px;
}

.filter-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 650;
}

.applied-filter-summary {
  color: var(--text);
  font-weight: 750;
}

.filter-toggle {
  display: none;
}

.filter-content {
  display: grid;
  gap: 13px;
  border-top: 1px solid var(--border);
  margin-top: 15px;
  padding-top: 15px;
}

.quick-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.range-button {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 750;
  padding: 0 12px;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease;
}

.range-button:hover,
.range-button.is-active,
.range-button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.filter-controls {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(260px, 1.25fr);
  align-items: end;
  gap: 10px;
}

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

.filter-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.filter-actions .tool-button {
  flex: 0 0 auto;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.field input,
.search-field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface-alt);
  color: var(--text);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.field input {
  min-width: 0;
  padding: 0 11px;
}

.field input:focus,
.search-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 159, 0.14);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.document-filter {
  display: grid;
  min-width: 0;
  gap: 6px;
  border: 0;
  margin: 0;
  padding: 0;
}

.document-filter legend {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
  padding: 0;
}

.document-options {
  display: grid;
  min-height: 44px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.toggle-chip {
  position: relative;
  display: block;
  min-width: 0;
}

.toggle-chip input {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.toggle-chip span {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0 9px;
  pointer-events: none;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease;
}

.toggle-chip input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

/* Metrics and panels */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  scroll-margin-top: 108px;
}

.metric-card,
.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card {
  position: relative;
  display: grid;
  min-height: 145px;
  align-content: space-between;
  gap: 11px;
  overflow: hidden;
  padding: 17px;
}

.metric-card::after {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--metric-color, var(--primary));
  content: "";
}

.metric-revenue {
  --metric-color: var(--primary);
  --metric-soft: var(--primary-soft);
}

.metric-sales {
  --metric-color: var(--blue);
  --metric-soft: var(--blue-soft);
}

.metric-items {
  --metric-color: var(--amber);
  --metric-soft: var(--amber-soft);
}

.metric-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.metric-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--metric-soft);
  color: var(--metric-color);
}

.metric-icon svg {
  width: 17px;
  height: 17px;
}

.metric-card > strong {
  overflow-wrap: anywhere;
  font-size: clamp(1.5rem, 2vw, 2rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.045em;
  white-space: nowrap;
}

.metric-card > small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 12px;
  margin-top: 12px;
  scroll-margin-top: 108px;
}

.panel {
  min-height: 280px;
  padding: 18px;
}

.panel-wide {
  grid-column: span 2;
}

#productsPanel {
  scroll-margin-top: 108px;
}

.panel-load-more {
  width: 100%;
  margin-top: 14px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 17px;
}

.panel-heading > div {
  min-width: 0;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  flex: 0 0 auto;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 800;
  padding: 4px 10px;
  white-space: nowrap;
}

.bar-list {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 190px) minmax(150px, 1fr) minmax(118px, auto);
  align-items: center;
  gap: 12px;
}

.bar-label {
  overflow: hidden;
  min-width: 0;
  font-size: 0.83rem;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.bar-fill {
  min-width: 4px;
  height: 100%;
  border-radius: inherit;
  transition: width 360ms ease;
}

.bar-value {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  text-align: right;
  white-space: nowrap;
}

.seller-row .bar-value {
  display: grid;
  gap: 2px;
}

.seller-row .bar-value strong {
  color: var(--text);
  font-size: 0.82rem;
}

.seller-row .bar-value span {
  font-size: 0.68rem;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.donut {
  position: relative;
  display: grid;
  width: 148px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0deg, var(--primary) 360deg);
  box-shadow: inset 0 0 0 1px var(--border);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 64%, transparent);
}

.donut-center {
  position: absolute;
  display: grid;
  width: 98px;
  aspect-ratio: 1;
  place-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  text-align: center;
}

.donut-center span {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
}

.donut-center strong {
  display: block;
  max-width: 88px;
  margin-top: 2px;
  font-size: clamp(0.64rem, 1.1vw, 0.76rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.legend-list,
.alert-stack,
.user-sales-list {
  display: grid;
  gap: 9px;
}

.legend-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  align-items: center;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 0.72rem;
}

.legend-color {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  grid-row: span 2;
}

.legend-item strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-item > span:last-child {
  font-size: 0.68rem;
}

.user-sales-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 7px 1px 11px;
}

.user-sales-row:last-child {
  border-bottom: 0;
}

.user-sales-row > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.user-sales-row > div:last-child {
  text-align: right;
}

.user-sales-row strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-sales-row span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
}

.line-chart {
  min-height: 190px;
}

.line-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--border);
  stroke-dasharray: 4 6;
  stroke-width: 1;
}

.chart-area {
  fill: var(--primary-soft);
  fill: color-mix(in srgb, var(--primary) 12%, transparent);
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-point circle {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-width: 3;
}

.chart-point.is-empty circle {
  fill: var(--surface-strong);
  stroke: var(--border-strong);
  stroke-width: 2;
}

.chart-point:focus circle,
.chart-point:hover circle {
  fill: var(--primary);
  outline: none;
}

.chart-point {
  cursor: pointer;
  outline: none;
}

.chart-point[aria-pressed="true"] circle {
  fill: var(--primary);
  stroke-width: 4;
}

.chart-touch-tooltip {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
  padding: 10px 12px;
}

.chart-data-details {
  margin-top: 9px;
}

.chart-data-details > summary {
  min-height: 44px;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 44px;
}

.hour-chart-table {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 7px;
  padding-top: 4px;
}

.hour-chart-value {
  display: grid;
  min-height: 58px;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  padding: 8px 10px;
}

.hour-chart-value strong {
  font-size: 0.75rem;
}

.hour-chart-value span {
  color: var(--muted);
  font-size: 0.68rem;
}

.axis-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.spark-bars {
  display: grid;
  min-height: 172px;
  align-content: start;
  gap: 7px;
}

.history-row {
  display: grid;
  width: 100%;
  min-height: 44px;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 7px 8px;
  text-align: left;
  transition:
    border-color 150ms ease,
    background 150ms ease;
}

.history-row:hover {
  background: var(--surface-alt);
}

.history-row.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.history-date {
  color: var(--text);
  font-size: 0.73rem;
  font-weight: 800;
  white-space: nowrap;
}

.history-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.history-fill {
  display: block;
  min-width: 4px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--blue));
}

.history-value {
  display: grid;
  gap: 1px;
  text-align: right;
  white-space: nowrap;
}

.history-value strong {
  font-size: 0.7rem;
}

.history-value small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
}

.alert-item {
  position: relative;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 11px;
}

.alert-dot {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--green-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 18%, transparent);
}

.alert-item.warn .alert-dot {
  background: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--amber) 18%, transparent);
}

.alert-item.danger .alert-dot {
  background: var(--rose);
  box-shadow: 0 0 0 2px var(--rose-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--rose) 18%, transparent);
}

.alert-item strong {
  color: var(--text);
  font-size: 0.77rem;
}

.alert-item .muted {
  margin-top: 3px;
  font-size: 0.7rem;
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 18px;
  text-align: center;
}

/* Tables */

.details-section {
  margin-top: 28px;
  scroll-margin-top: 108px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 0 2px;
}

.section-heading h2 {
  margin-bottom: 4px;
  font-size: 1.3rem;
}

.sales-panel {
  min-height: auto;
  margin-top: 12px;
}

.table-panel-heading {
  align-items: center;
}

.cancellation-actions {
  display: flex;
  max-width: 100%;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.cancellation-actions .tool-button {
  white-space: nowrap;
}

.search-field {
  position: relative;
  display: flex;
  width: min(310px, 100%);
  flex: 0 0 auto;
  align-items: center;
}

.search-field input {
  padding: 0 12px 0 40px;
  font-size: 0.8rem;
}

.search-field input::placeholder {
  color: var(--muted);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.cancellation-table {
  min-width: 1160px;
}

.compact-table table {
  min-width: 560px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 850;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.4;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: var(--surface-alt);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.numeric {
  text-align: right;
  white-space: nowrap;
}

.product-name {
  display: grid;
  gap: 2px;
  font-weight: 750;
}

.product-name small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
}

.table-clip {
  display: block;
  overflow: hidden;
  max-width: 190px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.description-cell {
  max-width: 260px;
}

.load-more-button {
  width: 100%;
  margin-top: 12px;
}

.cancellation-list {
  display: grid;
  gap: 9px;
}

.cancellation-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.cancellation-card[open] {
  border-color: var(--border-strong);
  background: var(--surface);
}

.cancellation-card-summary {
  display: grid;
  min-height: 62px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 14px;
  cursor: pointer;
  padding: 10px 12px;
  list-style: none;
}

.cancellation-card-summary::-webkit-details-marker {
  display: none;
}

.cancellation-card-summary::after {
  grid-column: 3;
  color: var(--primary);
  content: "+";
  font-size: 1.15rem;
  font-weight: 800;
}

.cancellation-card[open] .cancellation-card-summary::after {
  content: "−";
}

.cancellation-card-title,
.cancellation-card-subtitle {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cancellation-card-title {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 850;
}

.cancellation-card-subtitle {
  color: var(--muted);
  font-size: 0.7rem;
}

.cancellation-card-value {
  grid-column: 2;
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.cancellation-card-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--border);
  margin: 0;
}

.cancellation-card-details > div {
  display: grid;
  min-width: 0;
  gap: 3px;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

.cancellation-card-details > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.cancellation-card-details .cancellation-detail-wide {
  grid-column: 1 / -1;
}

.cancellation-card-details dt {
  color: var(--muted);
  font-size: 0.61rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cancellation-card-details dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--text);
  font-size: 0.76rem;
  line-height: 1.4;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--border);
  margin-top: 26px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  padding: 18px 2px 0;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 14px));
  max-width: min(390px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: var(--navy-strong);
  box-shadow: var(--shadow-lg);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.45;
  padding: 12px 15px;
  pointer-events: none;
  transform: translateY(18px);
  opacity: 0;
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }

  50% {
    opacity: 1;
  }
}

@media (max-width: 1180px) {
  .filter-controls {
    grid-template-columns: repeat(2, minmax(150px, 1fr)) minmax(260px, 1.25fr);
  }

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

  .metric-card {
    min-height: 132px;
  }

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

  .panel-wide {
    grid-column: span 2;
  }
}

@media (max-width: 940px) {
  .login-layout {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.84fr);
    gap: 38px;
  }

  .login-intro-copy h1 {
    font-size: clamp(2.2rem, 5vw, 3.3rem);
  }

  .login-benefits {
    display: none;
  }

  .login-intro-footer {
    margin-top: 36px;
  }

  .sidebar {
    width: min(286px, 86vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(-104%);
    transition: transform 190ms ease;
  }

  .app-shell.is-menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 45;
    inset: 0 0 0 min(286px, 86vw);
    display: block;
    visibility: hidden;
    background: rgba(4, 10, 19, 0.56);
    cursor: pointer;
    opacity: 0;
    transition:
      opacity 190ms ease,
      visibility 190ms ease;
  }

  .app-shell.is-menu-open .sidebar-backdrop {
    visibility: visible;
    opacity: 1;
  }

  .workspace {
    margin-left: 0;
  }

  .mobile-menu-button {
    display: grid;
  }
}

@media (max-width: 760px) {
  .login-screen {
    place-items: center;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-right: max(14px, calc(env(safe-area-inset-right) + 10px));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(14px, calc(env(safe-area-inset-left) + 10px));
  }

  .login-layout {
    grid-template-columns: 1fr;
    place-items: center;
    gap: 0;
  }

  .login-intro {
    display: none;
  }

  .login-brand {
    margin-bottom: 20px;
  }

  .login-intro-logo {
    width: 68px;
    height: 46px;
  }

  .login-brand span,
  .login-intro-copy > p:last-child,
  .login-intro-footer {
    display: none;
  }

  .login-intro-copy h1 {
    max-width: 520px;
    margin-bottom: 0;
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .login-card {
    max-width: 520px;
    max-height: calc(100vh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
    justify-self: center;
    gap: clamp(8px, 1.4dvh, 14px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: var(--radius);
    padding: clamp(14px, 2.2dvh, 20px);
  }

  .login-card[data-step="connection"] {
    gap: clamp(7px, 1.15dvh, 11px);
    padding-block: clamp(12px, 1.8dvh, 18px);
  }

  .login-logo {
    width: 88px;
    height: 52px;
  }

  .login-heading {
    margin-top: 0;
  }

  .login-heading h2 {
    margin-bottom: 4px;
    font-size: clamp(1.25rem, 3.2dvh, 1.55rem);
  }

  .login-heading > p:last-child {
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .connection-fields,
  .credential-fields {
    gap: clamp(7px, 1.1dvh, 11px);
  }

  .login-field {
    gap: 4px;
  }

  .login-field input,
  .login-card[data-step="connection"] .login-field input {
    height: 44px;
  }

  .topbar {
    min-height: 74px;
    padding-right: max(12px, calc(env(safe-area-inset-right) + 8px));
    padding-left: max(12px, calc(env(safe-area-inset-left) + 8px));
  }

  .topbar h1 {
    font-size: 1.42rem;
  }

  .topbar .eyebrow,
  .dashboard-company-name,
  .session-label {
    max-width: 48vw;
  }

  .refresh-button {
    width: 44px;
    padding: 0;
  }

  .refresh-button span {
    display: none;
  }

  main {
    padding-top: 14px;
  }

  .error-banner {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .loading-banner {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .loading-banner .cancel-query-button {
    width: 100%;
  }

  .error-banner .tool-button {
    width: 100%;
  }

  .filter-panel {
    padding: 14px;
  }

  .filter-toggle {
    display: inline-flex;
  }

  .filter-content.is-collapsed {
    display: none;
  }

  .quick-ranges {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .range-button {
    min-width: 0;
    padding-inline: 6px;
  }

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

  .document-filter {
    grid-column: 1 / -1;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .metric-card {
    min-height: 128px;
    padding: 14px;
  }

  .metric-heading {
    font-size: 0.66rem;
  }

  .metric-icon {
    width: 29px;
    height: 29px;
  }

  .metric-card > strong {
    font-size: clamp(1.35rem, 6.5vw, 1.9rem);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 9px;
    margin-top: 9px;
  }

  .panel,
  .panel-wide {
    grid-column: auto;
  }

  .panel {
    min-height: auto;
    padding: 15px;
  }

  .bar-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 9px;
  }

  .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .bar-value {
    text-align: right;
  }

  .donut-wrap {
    grid-template-columns: 138px minmax(0, 1fr);
    gap: 14px;
  }

  .donut {
    width: 138px;
  }

  .history-row {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .history-value {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
  }

  .table-panel-heading {
    display: grid;
  }

  .cancellation-actions {
    display: grid;
    width: 100%;
  }

  .cancellation-actions .tool-button {
    width: 100%;
  }

  .search-field {
    width: 100%;
  }
}

@media (max-width: 820px) {
  .responsive-table {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .responsive-table table,
  .responsive-table .cancellation-table {
    display: block;
    min-width: 0;
  }

  .responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .responsive-table tbody {
    display: grid;
    gap: 9px;
  }

  .responsive-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
  }

  .responsive-table tbody tr:hover {
    background: var(--surface-alt);
  }

  .responsive-table td {
    display: grid;
    min-width: 0;
    gap: 3px;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px 11px;
    overflow-wrap: anywhere;
  }

  .responsive-table td:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .responsive-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.61rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .responsive-table td.numeric {
    text-align: left;
  }

  .responsive-table td[data-label="Cliente"],
  .responsive-table td[data-label="Descrição"],
  .sales-table td[data-label="Nota"],
  .sales-table td[data-label="Valor"],
  .product-table td[data-label="Produto"],
  .product-table td[data-label="Participação"],
  .responsive-table td:only-child {
    grid-column: 1 / -1;
  }

  .responsive-table td:only-child::before {
    display: none;
  }

  .responsive-table .table-clip {
    max-width: none;
    overflow: visible;
    text-overflow: initial;
    white-space: normal;
  }
}

@media (max-width: 460px) {
  .login-screen {
    padding-right: max(10px, calc(env(safe-area-inset-right) + 8px));
    padding-left: max(10px, calc(env(safe-area-inset-left) + 8px));
  }

  .login-intro-copy h1 {
    font-size: 1.8rem;
  }

  .login-card {
    gap: 9px;
    padding: 13px;
  }

  .new-connection-copy small {
    display: none;
  }

  .connection-address-grid {
    grid-template-columns: minmax(0, 1fr) 104px;
    gap: 8px;
  }

  .login-logo {
    width: 78px;
    height: 46px;
  }

  .connection-badge {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .login-actions:has(.secondary:not(.is-hidden)),
  .login-actions.has-secondary {
    grid-template-columns: 1fr;
  }

  .topbar-title-group {
    gap: 8px;
  }

  .topbar-actions {
    gap: 5px;
  }

  .topbar .eyebrow,
  .dashboard-company-name,
  .session-label,
  .topbar-data-status span {
    max-width: 42vw;
  }

  .topbar h1 {
    font-size: 1.18rem;
  }

  .filter-panel-heading {
    align-items: flex-end;
  }

  .filter-toggle {
    width: 44px;
    flex: 0 0 auto;
    padding: 0;
  }

  .filter-toggle {
    font-size: 0;
  }

  .filter-toggle svg {
    width: 18px;
    height: 18px;
  }

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

  .filter-controls {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-actions .tool-button {
    width: 100%;
  }

  .document-filter {
    grid-column: auto;
  }

  .responsive-table tr {
    grid-template-columns: 1fr;
  }

  .cancellation-card-details {
    grid-template-columns: 1fr;
  }

  .cancellation-card-details > div,
  .cancellation-card-details > div:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

  .cancellation-card-details > div:last-child {
    border-bottom: 0;
  }

  .responsive-table td {
    grid-column: 1 / -1;
  }

  .responsive-table td:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

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

  .metric-card {
    min-height: 116px;
  }

  .metric-card > strong {
    font-size: 1.28rem;
  }

  .donut-wrap {
    grid-template-columns: 1fr;
  }

  .donut {
    margin: 0 auto;
  }

  .panel-heading {
    display: grid;
  }

  .pill {
    width: fit-content;
  }

  .app-footer {
    display: grid;
  }

  .toast {
    right: max(16px, calc(env(safe-area-inset-right) + 10px));
    bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px));
    left: max(16px, calc(env(safe-area-inset-left) + 10px));
  }
}

@media (max-width: 760px) and (max-height: 720px) {
  .login-screen {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .login-card,
  .login-card[data-step="connection"] {
    gap: 6px;
    padding: 10px 12px;
  }

  .login-card-header {
    display: none;
  }

  .login-heading {
    margin: 0;
  }

  .login-heading .eyebrow {
    display: none;
  }

  .login-heading h2 {
    margin-bottom: 2px;
    font-size: 1.08rem;
  }

  .login-heading > p:last-child,
  .login-security-note {
    display: none;
  }

  .login-step-label {
    margin: -2px 0 0;
    font-size: 0.66rem;
  }

  .connection-fields,
  .credential-fields {
    gap: 5px;
  }

  .login-field input,
  .login-card[data-step="connection"] .login-field input {
    height: 44px;
  }

  .login-error {
    min-height: 0;
    font-size: 0.72rem;
  }

  .login-error:not(.is-visible) {
    display: none;
  }

  .login-actions .tool-button {
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 112px;
  }

  .metric-card > strong {
    font-size: 1.55rem;
  }
}

@media (max-width: 340px) {
  .metric-card > strong {
    font-size: 1.6rem;
  }
}

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