/* ============================================================
   Diagnostic Factory — Design System
   ============================================================ */

:root {
  --bg-primary: #0A0F1E;
  --bg-secondary: #111827;
  --bg-card: #1A2234;
  --text-primary: #FFFFFF;
  --text-secondary: #94A3B8;
  --accent-gold: #D4A017;
  --accent-gold-hover: #B8860B;
  --accent-blue: #3B82F6;
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --border: #1E293B;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Source Serif Pro", "Charter", Georgia, serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

ul, ol {
  list-style: none;
}

/* ============================================================
   Typography
   ============================================================ */
h1, .h1 {
  font-size: 48px;
  font-weight: 700;
  font-family: var(--font-serif);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

h2, .h2 {
  font-size: 32px;
  font-weight: 700;
  font-family: var(--font-serif);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

h3, .h3 {
  font-size: 24px;
  font-weight: 600;
  font-family: var(--font-serif);
  line-height: 1.3;
}

h4, .h4 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}

p, .body-text, .prose {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  line-height: 1.65;
}

/* Monospace for data */
.mono, .case-id, .token-field, .amount-field,
td.mono, span.mono {
  font-family: var(--font-mono);
}

.small, small {
  font-size: 14px;
}

.label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ============================================================
   Layout
   ============================================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 80px 0;
}

/* ============================================================
   Navigation
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  height: 64px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

.nav-logo {
  color: var(--accent-gold);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 150ms;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
}

.nav-auth-btn {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 500;
  min-height: 44px;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background-color 150ms, color 150ms, border-color 150ms, opacity 150ms;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-gold {
  background-color: var(--accent-gold);
  color: #000;
  font-weight: 600;
}

.btn-gold:hover:not(:disabled) {
  background-color: var(--accent-gold-hover);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--error);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
}

.btn-blue {
  background-color: var(--accent-blue);
  color: #fff;
}

.btn-blue:hover:not(:disabled) {
  background-color: #2563eb;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  min-height: 36px;
}

/* ============================================================
   Card
   ============================================================ */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.badge-error {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

.badge-blue {
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.badge-gray {
  background-color: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

.badge-gold {
  background-color: rgba(212, 160, 23, 0.15);
  color: var(--accent-gold);
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-secondary);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

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

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px;
  font-size: 14px;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: 20px;
}

label.form-label,
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 150ms;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-gold);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

select option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--error);
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--success);
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warning);
}

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-gold);
  border-radius: 4px;
  padding: 20px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 6px;
}

/* ============================================================
   Pipeline
   ============================================================ */
.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.pipeline-connector {
  flex: 1;
  height: 1px;
  background-color: var(--border);
  align-self: center;
  margin: 0 -12px;
}

/* ============================================================
   Mobile Bottom Navigation
   ============================================================ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 200;
  flex-direction: row;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 10px;
  transition: color 150ms;
}

.mobile-nav-item.active {
  color: var(--accent-gold);
}

.mobile-nav-item:hover {
  color: var(--text-primary);
}

/* ============================================================
   Sidebar & Workspace Layout
   ============================================================ */
.sidebar {
  width: 280px;
  min-width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border);
  height: calc(100vh - 64px);
  overflow-y: auto;
  flex-shrink: 0;
}

.workspace-layout {
  display: flex;
  height: calc(100vh - 64px);
}

.main-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ============================================================
   Tab Navigation
   ============================================================ */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: color 150ms, border-color 150ms;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-gold);
}

/* ============================================================
   Filter Row
   ============================================================ */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 150ms, color 150ms;
}

.filter-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.filter-btn.active {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* ============================================================
   Deadline Row Highlights
   ============================================================ */
.deadline-red td {
  background-color: rgba(239, 68, 68, 0.05);
}

.deadline-yellow td {
  background-color: rgba(245, 158, 11, 0.05);
}

/* ============================================================
   Grids
   ============================================================ */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.two-col {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 48px;
}

.two-col-65 {
  display: grid;
  grid-template-columns: 65% 35%;
  gap: 32px;
}

/* ============================================================
   Step Numbers
   ============================================================ */
.step-number {
  font-size: 40px;
  font-weight: 700;
  color: var(--accent-gold);
  opacity: 0.4;
  line-height: 1;
  margin-bottom: 12px;
}

/* ============================================================
   Divider
   ============================================================ */
.divider {
  height: 1px;
  background-color: var(--border);
  margin: 48px 0;
}

/* ============================================================
   Breadcrumb
   ============================================================ */
.breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 150ms;
}

.breadcrumb a:hover {
  color: var(--text-primary);
}

/* ============================================================
   Workflow Stages
   ============================================================ */
.workflow-stages {
  display: flex;
  gap: 0;
  overflow-x: auto;
  margin-bottom: 32px;
}

.stage {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: 12px 8px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  position: relative;
}

.stage.active {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background-color: rgba(212, 160, 23, 0.05);
}

.stage.done {
  border-color: var(--success);
  color: var(--success);
  background-color: rgba(16, 185, 129, 0.05);
}

.stage + .stage {
  border-left: none;
}

/* ============================================================
   Utilities
   ============================================================ */
.text-gold { color: var(--accent-gold); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--text-primary); }

.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mt-40 { margin-top: 40px; }
.mt-48 { margin-top: 48px; }

.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.mb-40 { margin-bottom: 40px; }
.mb-48 { margin-bottom: 48px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.gap-32 { gap: 32px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-left { text-align: left; }

.pb-8 { padding-bottom: 8px; }
.pl-20 { padding-left: 20px; }
.border-bottom { border-bottom: 1px solid var(--border); }

/* ============================================================
   Loading
   ============================================================ */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-secondary);
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  margin-bottom: 12px;
}

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

/* ============================================================
   Toast
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  max-width: 320px;
  color: var(--text-primary);
  animation: fadeIn 150ms ease-out;
  word-break: break-word;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   Section backgrounds
   ============================================================ */
.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }

/* ============================================================
   Inline stat rows (label/value pair)
   ============================================================ */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.stat-row-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================================
   Product detail rows
   ============================================================ */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}

.detail-row-label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-row-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* ============================================================
   Case list items in sidebar
   ============================================================ */
.case-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 150ms;
}

.case-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.case-item.selected {
  background-color: rgba(212, 160, 23, 0.07);
  border-left: 2px solid var(--accent-gold);
}

/* ============================================================
   Responsive — Mobile (≤768px)
   ============================================================ */
@media (max-width: 768px) {
  h1 { font-size: 32px; }
  h2 { font-size: 24px; }
  h3 { font-size: 20px; }

  .section { padding: 48px 0; }
  .container { padding: 0 16px; }

  .mobile-nav { display: flex; }
  .nav-links { display: none; }
  .nav-auth-btn { display: none; }

  body { padding-bottom: 72px; }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .two-col,
  .two-col-65 {
    grid-template-columns: 1fr;
  }

  .two-col { gap: 32px; }
  .two-col-65 { gap: 24px; }

  .sidebar {
    display: none;
  }

  .workspace-layout {
    flex-direction: column;
    height: auto;
  }

  .main-panel {
    padding: 16px;
  }

  .stat-value {
    font-size: 24px;
  }

  .tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Additional utilities */
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.gap-4 { gap: 4px; }
.flex-wrap { flex-wrap: wrap; }
.pb-8 { padding-bottom: 8px; }
.pl-20 { padding-left: 20px; }
.pr-8 { padding-right: 8px; }
.p-0 { padding: 0; }
.border-bottom { border-bottom: 1px solid var(--border); }
.border-gold { border-color: var(--accent-gold) !important; }
