:root {
  color-scheme: light;
  --brand-blue: #2a6fff;
  --brand-amber: #d97706;
  --brand-teal: #0ea5a8;
  --surface: #ffffff;
  --surface-muted: #f5f7fb;
  --border-color: rgba(15, 23, 42, 0.12);
  --text-color: #0f172a;
  --muted-text: #475569;
  --shadow-soft: 0 15px 45px rgba(15, 23, 42, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #0f172a;
  --surface-muted: #020617;
  --border-color: rgba(255, 255, 255, 0.15);
  --text-color: #f8fafc;
  --muted-text: #cbd5f5;
  --shadow-soft: 0 25px 60px rgba(2, 6, 23, 0.65);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  background: radial-gradient(circle at top, rgba(42, 111, 255, 0.08), transparent 45%),
    radial-gradient(circle at 15% 20%, rgba(14, 165, 233, 0.12), transparent 35%),
    var(--surface-muted);
  color: var(--text-color);
  transition: background 0.3s ease, color 0.3s ease;
}

:root[data-theme="dark"] body {
  background: radial-gradient(circle at top, rgba(42, 111, 255, 0.2), transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(217, 119, 6, 0.2), transparent 45%),
    var(--surface-muted);
}

html {
  scroll-behavior: smooth;
}

.skip-link {
  position: absolute;
  left: 50%;
  top: -100%;
  transform: translate(-50%, -50%);
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  background-color: var(--brand-amber);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.2s ease;
  z-index: 9999;
}

.skip-link:focus {
  top: 1rem;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .site-header {
  background: rgba(2, 6, 23, 0.92);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 140px;
  height: 60px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  overflow: hidden;
}

.brand-logo {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.brand-details {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-title {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--muted-text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-color);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 10px 24px rgba(42, 111, 255, 0.1);
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.nav-pill:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  box-shadow: 0 16px 30px rgba(42, 111, 255, 0.18);
}

.nav-pill:active {
  transform: translateY(1px);
}

.cta-pill {
  background: var(--brand-amber);
  color: #fff;
  border: none;
  box-shadow: 0 12px 28px rgba(217, 119, 6, 0.35);
}

.cta-pill:hover {
  color: #fff;
  background: #f79020;
  box-shadow: 0 16px 32px rgba(217, 119, 6, 0.45);
}

.avatar-pill {
  border-radius: 999px;
  padding: 0.45rem;
  width: 2.35rem;
  height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
}

.mobile-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  padding: 0.35rem;
  width: 2.6rem;
  height: 2.6rem;
  color: var(--text-color);
}

.mobile-toggle svg {
  width: 20px;
  height: 20px;
}

.mobile-toggle:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.mobile-menu.active {
  display: block;
}

.mobile-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.mobile-menu-panel {
  position: relative;
  margin: 1.5rem auto;
  max-width: 420px;
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
}

.mobile-menu-panel .header-inner {
  max-width: none;
  margin: 0;
  padding: 0;
  justify-content: space-between;
}

.mobile-menu nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.mobile-menu .nav-pill {
  justify-content: center;
}

.app-main {
  flex: 1;
  width: 100%;
}

.content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.content-wrapper > *:first-child {
  margin-top: 0;
}

.content-wrapper > *:last-child {
  margin-bottom: 0;
}

.content-wrapper h1,
.content-wrapper h2,
.content-wrapper h3 {
  color: var(--text-color);
  font-weight: 700;
}

main .container {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-color);
}

:root[data-theme="dark"] main .container {
  background: rgba(15, 23, 42, 0.9);
}

.table-container {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-soft);
}

:root[data-theme="dark"] .table-container {
  background: rgba(15, 23, 42, 0.85);
}

.button-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.company-dashboard .muted {
  color: var(--muted-text);
}

.company-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.company-header .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-size: 0.75rem;
  color: var(--brand-blue);
  margin-bottom: 0.45rem;
}

.company-switcher {
  min-width: 280px;
}

.company-switcher label {
  font-size: 0.85rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.35rem;
}

.company-switcher .controls-row {
  display: flex;
  gap: 0.5rem;
}

.company-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.company-tab {
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  background: rgba(255, 255, 255, 0.65);
  color: var(--text-color);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.company-tab .badge {
  margin-left: 0.5rem;
}

.company-tab.active {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  background: rgba(42, 111, 255, 0.08);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: rgba(42, 111, 255, 0.1);
  color: var(--brand-blue);
  font-size: 0.75rem;
  font-weight: 600;
}

.company-panel {
  display: none;
  margin-bottom: 2rem;
}

.company-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.table-controls input[type="text"],
.table-controls input[type="date"] {
  min-width: 160px;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.85);
}

:root[data-theme="dark"] .table-controls input[type="text"],
:root[data-theme="dark"] .table-controls input[type="date"] {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(148, 163, 184, 0.35);
  color: #f8fafc;
}

.table-wrapper {
  overflow-x: auto;
}

.company-table th {
  white-space: nowrap;
}

.company-table th.sortable {
  cursor: pointer;
  position: relative;
  user-select: none;
  padding-right: 1.5rem;
}

.company-table th.sortable::after {
  content: '⇅';
  font-size: 0.7rem;
  margin-left: 0.35rem;
  color: var(--muted-text);
}

.company-table th.sortable[data-sort-active="true"][data-sort-dir="asc"]::after {
  content: '↑';
  color: var(--brand-blue);
}

.company-table th.sortable[data-sort-active="true"][data-sort-dir="desc"]::after {
  content: '↓';
  color: var(--brand-blue);
}

.link-pill {
  display: inline-flex;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  text-decoration: none;
  color: var(--brand-blue);
  font-size: 0.9rem;
}

:root[data-theme="dark"] .link-pill {
  border-color: rgba(148, 163, 184, 0.4);
}

.table-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.button.small {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

.mono {
  font-family: "JetBrains Mono", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
}

.customer-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-width: 160px;
}

.customer-id {
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border-radius: 0.4rem;
  background: rgba(42, 111, 255, 0.08);
  border: 1px solid rgba(42, 111, 255, 0.2);
}

.customer-name {
  font-size: 0.8rem;
  color: var(--muted-text);
}

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

.text-center {
  text-align: center;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: rgba(248, 250, 252, 0.85);
  color: var(--text-color);
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  min-height: 120px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(42, 111, 255, 0.35);
  outline: none;
  box-shadow: 0 0 0 3px rgba(42, 111, 255, 0.15);
  background-color: #fff;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: rgba(15, 23, 42, 0.8);
  color: #f8fafc;
}

button,
input[type="submit"],
.button,
.container button {
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.75rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background-color: var(--brand-amber);
  color: #fff;
  box-shadow: 0 10px 22px rgba(217, 119, 6, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

button:hover,
input[type="submit"]:hover,
.button:hover {
  transform: translateY(-1px);
  background-color: #f79020;
  box-shadow: 0 14px 26px rgba(217, 119, 6, 0.45);
}

button:active,
input[type="submit"]:active,
.button:active {
  transform: translateY(0);
  background-color: #d36805;
}

.button-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 16px;
  padding: 0.75rem 1.5rem;
}

.button-secondary:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.rail-panel {
  background: rgba(255, 255, 255, 0.96) !important;
  border-radius: 18px !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: var(--shadow-soft) !important;
  color: var(--text-color) !important;
}

.rail-panel h2,
.rail-panel .price-value {
  color: var(--text-color) !important;
}

.rail-panel .price-note,
.rail-panel .price-meta {
  color: var(--muted-text) !important;
}

:root[data-theme="dark"] .rail-panel {
  background: rgba(15, 23, 42, 0.9) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #f8fafc !important;
}

:root[data-theme="dark"] .rail-panel h2,
:root[data-theme="dark"] .rail-panel .price-value {
  color: #f8fafc !important;
}

:root[data-theme="dark"] .rail-panel .price-note,
:root[data-theme="dark"] .rail-panel .price-meta {
  color: rgba(226, 232, 240, 0.85) !important;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.25rem 0;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

table thead {
  background: rgba(42, 111, 255, 0.08);
}

table th,
table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  font-size: 0.95rem;
  color: var(--text-color);
}

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

.alert {
  border-radius: 18px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(14, 165, 168, 0.25);
  background: rgba(14, 165, 168, 0.1);
  color: var(--brand-teal);
  font-weight: 600;
}

.alert-error {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.flash-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.data-notice {
  margin-top: 2rem;
  border: 1px dashed rgba(42, 111, 255, 0.35);
  border-radius: 18px;
  padding: 1rem 1.25rem;
  background: rgba(42, 111, 255, 0.05);
  color: var(--text-color);
  font-size: 0.9rem;
  line-height: 1.5;
}

.data-notice strong {
  color: var(--brand-blue);
}

.site-footer {
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.9);
}

:root[data-theme="dark"] .site-footer {
  background: rgba(2, 6, 23, 0.92);
}

.footer-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
}

.footer-meta {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.75rem;
  color: var(--muted-text);
  margin-bottom: 0.5rem;
}

.footer-note {
  text-align: center;
  padding: 1.25rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--muted-text);
}

.cookie-note {
  font-size: 0.85rem;
  color: var(--muted-text);
  margin-top: 0.5rem;
}

.loading-cursor,
.loading-cursor * {
  cursor: progress !important;
}

#theme-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  color: var(--text-color);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: var(--shadow-soft);
}

#theme-toggle:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

@media (max-width: 1024px) {
  .header-inner {
    padding: 1rem;
  }

  .header-actions {
    display: none;
  }

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

@media (min-width: 1025px) {
  .mobile-toggle {
    display: none;
  }
}

@media (max-width: 640px) {
  .content-wrapper {
    padding: 1.5rem 1rem 2.5rem;
  }

  main .container {
    padding: 1.25rem;
  }

  table {
    font-size: 0.85rem;
  }

  .brand-mark {
    width: 120px;
    height: 50px;
  }
}

:root[data-theme="dark"] table {
  background: rgba(15, 23, 42, 0.85);
}

:root[data-theme="dark"] table thead {
  background: rgba(148, 163, 184, 0.1);
}

:root[data-theme="dark"] table th,
:root[data-theme="dark"] table td {
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .nav-pill,
:root[data-theme="dark"] .mobile-toggle,
:root[data-theme="dark"] #theme-toggle {
  background: rgba(2, 6, 23, 0.8);
  border-color: rgba(148, 163, 184, 0.35);
  color: #f8fafc;
}

:root[data-theme="dark"] .nav-pill {
  box-shadow: 0 14px 32px rgba(2, 6, 23, 0.7);
}

:root[data-theme="dark"] .brand-mark {
  background: rgba(2, 6, 23, 0.9);
}
