:root {
  color-scheme: light;
  font-family: Figtree, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --background: hsl(60 9.1% 97.8%);
  --canvas: hsl(60 4.8% 95.9%);
  --background-hovered: hsl(60 2.9% 93.1%);
  --foreground: hsl(12 6.5% 15.1%);
  --card: hsl(0 0% 100%);
  --muted: hsl(30 5.6% 92.9%);
  --muted-foreground: hsl(25 5.3% 44.7%);
  --border: hsl(12 6.5% 15.1% / 0.11);
  --border-strong: hsl(12 6.5% 15.1% / 0.18);
  --ring: hsl(191.6 91.4% 36.5% / 0.42);
  --primary: hsl(191.6 91.4% 36.5%);
  --primary-hovered: hsl(192.5 86.1% 33.9%);
  --primary-foreground: hsl(183.2 100% 96.3%);
  --primary-tint: hsl(191.6 91.4% 36.5% / 0.1);
  --secondary: hsl(168.4 83.8% 78.2%);
  --secondary-foreground: hsl(176.1 69.4% 21.8%);
  --secondary-tint: hsl(174.7 83.9% 31.6% / 0.11);
  --destructive: hsl(345.4 82.7% 40.8%);
  --destructive-tint: hsl(345.4 82.7% 40.8% / 0.09);
  --warning: hsl(32 91% 36%);
  --warning-tint: hsl(43 96% 56% / 0.14);
  --success: hsl(160 84% 30%);
  --success-tint: hsl(160 84% 39% / 0.1);
  --sidebar: hsl(30 6.2% 25.1%);
  --sidebar-foreground: hsl(60 9.1% 97.8%);
  --sidebar-muted: hsl(24 5.7% 82.9%);
  --sidebar-accent: hsl(33.3 5.5% 32.4%);
  --sidebar-icon: hsl(12 6.5% 15.1%);
  --sidebar-border: hsl(60 9.1% 97.8% / 0.15);
  --shadow-xs: 0 1px 2px hsl(12 6.5% 15.1% / 0.05);
  --shadow-sm: 0 1px 3px hsl(12 6.5% 15.1% / 0.08), 0 1px 2px hsl(12 6.5% 15.1% / 0.04);
  --shadow-lg: 0 20px 45px hsl(12 6.5% 15.1% / 0.14);
  background: var(--canvas);
  color: var(--foreground);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--foreground);
  font-size: 0.9375rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  min-height: 2.375rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

button {
  cursor: pointer;
  padding: 0.5rem 0.8rem;
  font-weight: 600;
}

button:hover:not(:disabled) {
  border-color: hsl(12 6.5% 15.1% / 0.28);
  background: var(--background-hovered);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px hsl(191.6 91.4% 20% / 0.16);
}

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

button.danger {
  border-color: transparent;
  background: transparent;
  color: hsl(352.6 95.7% 81.8%);
  box-shadow: none;
}

button.danger:hover:not(:disabled) {
  border-color: var(--sidebar-border);
  background: var(--sidebar-accent);
  color: hsl(355.6 100% 94.7%);
}

button:disabled {
  cursor: not-allowed;
  background: var(--muted);
  color: hsl(12 6.5% 15.1% / 0.4);
  box-shadow: none;
}

input,
select {
  width: 100%;
  padding: 0.5rem 0.65rem;
}

input::placeholder {
  color: hsl(25 5.3% 44.7% / 0.72);
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--foreground);
  font-size: 0.78rem;
  font-weight: 600;
}

label > span {
  color: var(--muted-foreground);
}

a {
  color: var(--primary);
}

.eyebrow {
  display: block;
  color: var(--primary-hovered);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.brand-icon {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--sidebar-border);
  border-radius: 0.625rem;
  background: var(--sidebar-icon);
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.16);
}

.brand-icon img {
  width: 1.5rem;
  height: 1.5rem;
}

.brand-icon-large {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
}

.brand-icon-large img {
  width: 1.75rem;
  height: 1.75rem;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 20% 12%, hsl(191.6 91.4% 36.5% / 0.1), transparent 27rem),
    radial-gradient(circle at 82% 88%, hsl(174.7 83.9% 31.6% / 0.08), transparent 24rem),
    var(--canvas);
}

.loading-panel,
.login-panel {
  width: min(28rem, 100%);
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--card);
  box-shadow: var(--shadow-lg);
}

.loading-panel {
  margin: 15vh auto;
  padding: 2rem;
}

.loading-panel p {
  margin: 1.25rem 0 0;
  color: var(--muted-foreground);
}

.loading-brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.loading-brand h1 {
  margin: 0.15rem 0 0;
  font-size: 1.2rem;
  line-height: 1.25;
}

.login-panel {
  padding: 2rem;
}

.login-brand > div > strong,
.login-brand > div > span {
  display: block;
}

.login-brand strong {
  font-size: 1rem;
  line-height: 1.25;
}

.login-brand div > span {
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.login-heading {
  margin: 2rem 0 1.5rem;
}

.login-heading h1 {
  margin: 0.45rem 0 0.4rem;
  font-size: 1.75rem;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.login-heading p {
  max-width: 25rem;
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.login-panel form {
  display: grid;
  gap: 1rem;
}

.login-submit {
  width: 100%;
  margin-top: 0.25rem;
}

.login-panel .error {
  min-height: 1.25rem;
  margin: 0;
  color: var(--destructive);
  font-size: 0.8rem;
}

.login-security {
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  text-align: center;
}

.login-security span {
  margin-right: 0.3rem;
  color: var(--success);
  font-size: 0.55rem;
  vertical-align: 0.12rem;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  overflow: hidden;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar);
  color: var(--sidebar-foreground);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.25rem 0.25rem 1.25rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-copy {
  min-width: 0;
}

.brand-copy strong,
.brand-copy span {
  display: block;
}

.brand-copy strong {
  color: var(--sidebar-foreground);
  font-size: 0.9rem;
  line-height: 1.25;
}

.brand-copy span {
  overflow: hidden;
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-label {
  padding: 0 0.65rem 0.45rem;
  color: hsl(24 5.7% 82.9% / 0.72);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.nav {
  display: grid;
  gap: 0.25rem;
}

.nav button {
  position: relative;
  width: 100%;
  min-height: 2.35rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  overflow: hidden;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--sidebar-muted);
  text-align: left;
}

.nav button:hover:not(:disabled) {
  border-color: transparent;
  background: var(--sidebar-accent);
  color: var(--sidebar-foreground);
}

.nav button.active {
  border-color: var(--sidebar-border);
  background: var(--sidebar-accent);
  color: var(--sidebar-foreground);
}

.nav-indicator {
  width: 0.38rem;
  height: 0.38rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: hsl(24 5.7% 82.9% / 0.45);
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.nav button.active .nav-indicator {
  background: var(--secondary);
  box-shadow: 0 0 0 3px hsl(168.4 83.8% 78.2% / 0.12);
}

.staff {
  margin-top: auto;
  padding: 0.85rem 0.25rem 0.1rem;
  border-top: 1px solid var(--sidebar-border);
}

.staff-profile {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  padding: 0 0.35rem;
}

.staff-avatar {
  width: 2rem;
  height: 2rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--sidebar-border);
  border-radius: 999px;
  background: var(--sidebar-icon);
  color: var(--secondary);
  font-size: 0.75rem;
  font-weight: 700;
}

.staff-profile div {
  min-width: 0;
}

.staff-profile strong,
.staff-profile div span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-profile strong {
  color: var(--sidebar-foreground);
  font-size: 0.76rem;
  line-height: 1.25;
}

.staff-profile div span {
  color: var(--sidebar-muted);
  font-size: 0.68rem;
}

.staff button {
  width: 100%;
  margin-top: 0.65rem;
}

.content {
  min-width: 0;
  min-height: 100vh;
  background: var(--canvas);
}

.topbar {
  min-height: 7.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.page-heading h1 {
  margin: 0.3rem 0 0;
  font-size: 1.65rem;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.page-heading p {
  margin: 0.35rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.86rem;
}

.date-controls,
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.55rem;
}

.date-controls label {
  width: 9.75rem;
}

.date-controls label:nth-child(3) {
  width: 8.75rem;
}

.refresh-button {
  min-width: 5rem;
}

.workspace {
  min-width: 0;
  padding: 1.5rem 2rem 3rem;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1.25rem;
  border: 1px solid hsl(191.6 91.4% 36.5% / 0.2);
  border-radius: 0.625rem;
  background: var(--primary-tint);
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.notice-mark {
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  margin-top: 0.05rem;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.72rem;
  font-weight: 800;
  font-family: ui-serif, Georgia, serif;
}

.notice strong,
.notice div span {
  display: block;
}

.notice strong {
  color: var(--foreground);
  font-size: 0.8rem;
}

.notice.error {
  border-color: hsl(345.4 82.7% 40.8% / 0.22);
  background: var(--destructive-tint);
  color: var(--destructive);
}

.notice.error::before {
  content: "!";
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: var(--destructive);
  color: white;
  font-weight: 800;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.card {
  min-height: 6.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.card:hover {
  border-color: hsl(191.6 91.4% 36.5% / 0.24);
  box-shadow: 0 8px 20px hsl(12 6.5% 15.1% / 0.08);
  transform: translateY(-1px);
}

.card .label {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 600;
}

.card .value {
  margin-top: 0.45rem;
  color: var(--foreground);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.card.good .value {
  color: var(--success);
}

.card.bad .value {
  color: var(--destructive);
}

.card.warn .value {
  color: var(--warning);
}

.panel {
  position: relative;
  margin-bottom: 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.panel-header {
  min-height: 3.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.panel-header h2 {
  margin: 0;
  color: var(--foreground);
  font-size: 0.95rem;
  font-weight: 650;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.filters .actions {
  align-self: end;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--foreground);
  font-size: 0.78rem;
}

th,
td {
  max-width: 28rem;
  padding: 0.72rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--background);
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

th button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  font-weight: inherit;
}

th button:hover:not(:disabled) {
  border: 0;
  background: transparent;
  color: var(--primary-hovered);
}

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

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

td code {
  color: hsl(194 70% 27%);
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.73rem;
  overflow-wrap: anywhere;
}

td pre {
  max-height: 9rem;
  margin: 0;
  overflow: auto;
  color: hsl(12 6.5% 24%);
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  white-space: pre-wrap;
}

.row-link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--primary-hovered);
  font-weight: 650;
  text-align: left;
  overflow-wrap: anywhere;
}

.row-link:hover:not(:disabled) {
  border: 0;
  background: transparent;
  color: hsl(194 70% 27%);
  text-decoration: underline;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 1.45rem;
  padding: 0.16rem 0.48rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.69rem;
  font-weight: 650;
  line-height: 1.1;
  white-space: nowrap;
}

.status.completed,
.status.delivered,
.status.responded {
  background: var(--success-tint);
  color: var(--success);
}

.status.failed,
.status.abandoned {
  background: var(--destructive-tint);
  color: var(--destructive);
}

.status.pending,
.status.in_progress,
.status.partial {
  background: var(--warning-tint);
  color: var(--warning);
}

.empty {
  padding: 3rem 1.5rem;
  color: var(--muted-foreground);
  text-align: center;
}

.pagination {
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.pagination div {
  display: flex;
  gap: 0.4rem;
}

.popover {
  position: absolute;
  right: 1rem;
  z-index: 10;
  width: min(24rem, calc(100vw - 2rem));
  max-height: 70vh;
  padding: 0.9rem;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 0.75rem;
  background: var(--card);
  box-shadow: var(--shadow-lg);
}

.popover h3 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.column-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.column-list label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--foreground);
  font-weight: 500;
}

.column-list input {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
}

.saved-view {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: hsl(12 6.5% 15.1% / 0.58);
  backdrop-filter: blur(3px);
}

.dialog {
  width: min(76rem, 100%);
  max-height: 94vh;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 0.875rem;
  background: var(--card);
  box-shadow: 0 28px 80px hsl(12 6.5% 15.1% / 0.28);
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.dialog-header h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.dialog-body {
  padding: 1rem;
}

.detail-section {
  margin-bottom: 1.4rem;
}

.detail-section h3 {
  margin: 0 0 0.65rem;
  color: var(--primary-hovered);
  font-size: 0.86rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.6rem;
}

.detail-item {
  padding: 0.75rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  background: var(--background);
}

.detail-item .key {
  margin-bottom: 0.3rem;
  color: var(--muted-foreground);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

@media (max-width: 1040px) {
  .topbar {
    align-items: flex-start;
  }

  .date-controls {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem;
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .brand {
    padding: 0;
    margin: 0;
    border: 0;
  }

  .nav-label {
    display: none;
  }

  .nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.3rem;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .nav button {
    width: auto;
    flex: 0 0 auto;
  }

  .staff {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0;
    margin: 0;
    border: 0;
  }

  .staff-profile div {
    display: none;
  }

  .staff button {
    width: auto;
    margin: 0;
  }

  .content {
    min-height: auto;
  }

  .topbar {
    min-height: auto;
    padding: 1.15rem 1rem;
  }

  .workspace {
    padding: 1rem 0.75rem 2rem;
  }

  .date-controls label,
  .date-controls label:nth-child(3) {
    width: calc(50% - 0.3rem);
  }

  .date-controls label:nth-child(3) {
    flex: 1 1 9rem;
  }

  .column-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .login-panel {
    padding: 1.5rem;
  }

  .brand-copy span {
    display: none;
  }

  .staff-avatar {
    display: none;
  }

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

  .date-controls label,
  .date-controls label:nth-child(3),
  .refresh-button {
    width: 100%;
  }

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

  .card {
    min-height: 6rem;
    padding: 0.85rem;
  }

  .panel-header {
    align-items: flex-start;
  }

  .panel-header .actions {
    width: 100%;
  }

  .panel-header .actions > * {
    flex: 1 1 auto;
  }

  .pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .popover {
    right: 0.5rem;
  }
}

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