:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --border: #e5e5e8;
  --text: #1a1a1f;
  --text-2: #6b6b76;
  --text-3: #9a9aa4;
  --accent: oklch(55% 0.16 260);
  --accent-hover: oklch(48% 0.17 260);
  --accent-soft: oklch(95% 0.025 260);
  --success: oklch(60% 0.14 150);
  --success-soft: oklch(95% 0.035 150);
  --warning: oklch(78% 0.15 80);
  --warning-soft: oklch(96% 0.045 80);
  --danger: oklch(58% 0.19 25);
  --danger-soft: oklch(96% 0.03 25);
}

/* 2026-09-20: dark theme, the same palette as the provider panel. It follows the computer's setting until someone presses the
   sun/moon button in the top bar; that choice is remembered in the browser (see js/theme.js). Filled buttons keep white text, so the
   accent stays mid-tone in dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --border: #2a2e38;
    --text: #eceef2; --text-2: #a3a8b4; --text-3: #7c8190;
    --accent: oklch(64% 0.16 260); --accent-hover: oklch(70% 0.15 260); --accent-soft: oklch(28% 0.06 260);
    --success: oklch(70% 0.15 150); --success-soft: oklch(28% 0.05 150);
    --warning: oklch(80% 0.13 80); --warning-soft: oklch(30% 0.05 80);
    --danger: oklch(68% 0.18 25); --danger-soft: oklch(29% 0.06 25);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --border: #2a2e38;
  --text: #eceef2; --text-2: #a3a8b4; --text-3: #7c8190;
  --accent: oklch(64% 0.16 260); --accent-hover: oklch(70% 0.15 260); --accent-soft: oklch(28% 0.06 260);
  --success: oklch(70% 0.15 150); --success-soft: oklch(28% 0.05 150);
  --warning: oklch(80% 0.13 80); --warning-soft: oklch(30% 0.05 80);
  --danger: oklch(68% 0.18 25); --danger-soft: oklch(29% 0.06 25);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

input::placeholder {
  color: var(--text-3);
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.app-sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  height: 64px;
  flex: 0 0 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  position: relative;
}

.app-content {
  flex: 1;
  padding: 28px 32px;
  /* 2026-09-24: "keep everything working on mobile" - a page whose own content is wider than the
     screen (a wide table, a fixed-width grid) scrolls INSIDE this box instead of breaking the whole
     layout (pushing the sidebar off-screen, forcing the page itself to scroll sideways). This is a
     safety net on top of the page-by-page responsive work below, not a substitute for it. */
  overflow-x: auto;
}

.sidebar-toggle {
  display: none;
}
.sidebar-backdrop {
  display: none;
}

/* 2026-09-24: "consider doing the design mobile or tablet friendly while everything keep working" -
   below 900px (phone and most tablets in portrait) the sidebar becomes an off-canvas drawer instead
   of a permanent 240px column: it starts off-screen (transform, not display:none, so it keeps its
   own scroll position and open sub-menus) and slides in over the content when the hamburger button
   (top left of the bar, see MainLayout.razor) is pressed. A translucent backdrop behind it closes it
   on tap, and it also closes itself on every real navigation (MainLayout's own LocationChanged
   handler) so picking a page doesn't leave the drawer open over it. */
@media (max-width: 900px) {
  .app-shell {
    display: block;
  }
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 210;
    width: 260px;
    flex: none;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 28px rgba(0, 0, 0, 0.25);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    width: 100%;
  }
  .sidebar-toggle {
    display: flex;
  }
  .sidebar-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 21, 0.4);
    z-index: 205;
  }
  .app-topbar {
    padding: 0 14px;
    gap: 10px;
  }
  .app-content {
    padding: 16px;
  }
}

/* Phones specifically: the brand-name middle column and the username text next to the gear menu
   are the first things to give up space so the logo, hamburger and gear stay tappable. */
@media (max-width: 520px) {
  .app-topbar .topbar-username-text {
    display: none;
  }
}

/* 2026-09-24: "I want it like the picture as rectangular but the width is more than the length" -
   flex-wrap with a min-width floor (the previous attempt) still collapsed to one column wide once
   the columns hit that floor, which is exactly the tall single-column list the owner was rejecting.
   A fixed 2-column CSS grid guarantees the panel is always at least 2 columns wide - never a single
   vertical list - regardless of how narrow the actual screen is; only the column contents get
   narrower, never the column count. */
.gear-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  width: min(520px, calc(100vw - 32px));
  max-height: min(70vh, 520px);
  overflow-y: auto;
}

/* Primary nav */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* Settings sub-nav */
.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.settings-item:hover {
  background: var(--bg);
}
.settings-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Forms */
.field-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field-value {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  background: var(--surface);
}

/* Tables */
.row:hover {
  background: var(--bg);
}

/* Toggles */
.toggle-on {
  width: 32px;
  height: 18px;
  border-radius: 10px;
  background: var(--accent);
  position: relative;
  flex: 0 0 32px;
  border: none;
  padding: 0;
  cursor: pointer;
}
.toggle-on div {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  right: 2px;
}
.toggle-off {
  width: 32px;
  height: 18px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  flex: 0 0 32px;
  border: none;
  padding: 0;
  cursor: pointer;
}
.toggle-off div {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
}

/* Toolbar */
.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn-accent {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* 2026-09-24: color-coded action buttons (Omega Software walkthrough reference: green=commit, orange/
   accent=save a draft, red=delete). .btn-accent above is the "save" color; these two round out the set
   for any form that also needs a positive-commit and a destructive action next to it. */
.btn-success {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border: none;
  border-radius: 9px;
  background: var(--success);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-danger {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border: none;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* Sales item tabs */
.tab-1 {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}
.tab-1.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-1 .badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  flex: 0 0 24px;
}
.tab-1.active .badge {
  background: var(--accent-soft);
  color: var(--accent);
}
.tab-2 {
  padding: 10px 16px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
}
.tab-2.active {
  color: var(--text);
  font-weight: 800;
  border-bottom-color: var(--accent);
}
.tab-3 {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  border-radius: 20px;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
  background: none;
  border: none;
}
.tab-3.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
/* 2026-09-24: horizontally-scrolling tab row (Omega Software walkthrough reference) - a tab row that
   doesn't fit the screen scrolls sideways in one line instead of wrapping to a second line or relying
   on the page-wide overflow-x safety net to shift the whole page. Wrap any row of .tab-1/.tab-2/.ci-tab
   buttons in a div with this class. */
.tab-row-scroll {
  display: flex;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.tab-row-scroll::-webkit-scrollbar {
  height: 5px;
}
.tab-row-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  flex: 0 0 22px;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* Blazor connection banner */
#blazor-error-ui {
  background: var(--danger);
  color: #fff;
  bottom: 0;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
  display: none;
  left: 0;
  padding: 0.75rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
  font-size: 13.5px;
}
#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}
#blazor-error-ui .reload {
  color: #fff;
  text-decoration: underline;
}

.blazor-error-boundary {
  background: var(--danger);
  padding: 1rem;
  color: white;
  border-radius: 8px;
}
.blazor-error-boundary::after {
  content: "An error has occurred.";
}
