:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f3d63;
  --primary-soft: #e8f0f6;
  --accent: #d66b2d;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2b;
  --surface-2: #162235;
  --text: #e6edf7;
  --muted: #93a4bd;
  --border: #23324a;
  --primary: #d66b2d;
  --primary-soft: #1d2b3e;
  --accent: #f5a264;
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.14);
  --shadow: 0 20px 44px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 85%, var(--surface)));
  color: var(--text);
}

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

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

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
  border-radius: 16px;
  background: var(--surface-2);
  padding: 8px;
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}

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

.topbar h1 {
  font-size: 1.6rem;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-badge {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 14px;
  min-width: 260px;
}

.user-badge span {
  font-size: .86rem;
  color: var(--muted);
}

.content {
  display: grid;
  gap: 22px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 12px;
}

.stat-value {
  font-size: 1.9rem;
  color: var(--primary);
  font-weight: 700;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 18px;
}

.muted {
  color: var(--muted);
  font-size: .95rem;
  margin-top: 6px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: .9rem;
  color: var(--muted);
  font-weight: 600;
}

.field input,
.field select {
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
}

.filters-actions {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: .18s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: .92rem;
}

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

.btn-outline,
.theme-toggle {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.theme-toggle {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  cursor: pointer;
}

.theme-toggle.floating {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 40;
}

.btn-block {
  width: 100%;
}

.table-wrap {
  overflow: auto;
}

.modern-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

.modern-table th,
.modern-table td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.modern-table th {
  color: var(--muted);
  font-size: .86rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.modern-table tbody tr:hover {
  background: var(--surface-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.tag.success { color: var(--success); background: var(--success-soft); }
.tag.warning { color: var(--warning); background: var(--warning-soft); }
.tag.danger  { color: var(--danger);  background: var(--danger-soft); }
.tag.info    { color: var(--info);    background: var(--info-soft); }
.tag.neutral { color: var(--muted);   background: var(--surface-2); border-color: var(--border); }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 28px !important;
}

.login-page {
  background:
    radial-gradient(circle at top right, rgba(214, 107, 45, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 88%, var(--surface)));
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-panel {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 26px;
  align-items: center;
}

.brand-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 34px;
  display: flex;
  gap: 22px;
  align-items: center;
}

.brand-block h1 {
  font-size: 2rem;
  margin-bottom: 10px;
}

.brand-block p {
  color: var(--muted);
  line-height: 1.6;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-card h2 {
  margin-bottom: 8px;
}

.form-grid {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.alert {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: .95rem;
  margin-top: 14px;
}

.alert-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.detail-hero h2 {
  margin-top: 10px;
  font-size: 1.7rem;
}

.hero-status {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}

.detail-grid.single {
  grid-template-columns: 1fr;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.detail-list.three-cols {
  grid-template-columns: repeat(3, 1fr);
}

.detail-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  min-height: 84px;
}

.detail-label {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: 8px;
}

.detail-value {
  font-size: 1rem;
  line-height: 1.35;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.timeline-step {
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.timeline-step span {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.timeline-step.done {
  border-color: color-mix(in srgb, var(--success) 30%, var(--border));
  background: var(--success-soft);
}

.timeline-step.pending {
  border-color: color-mix(in srgb, var(--warning) 30%, var(--border));
  background: var(--warning-soft);
}

.timeline-step.neutral {
  border-color: var(--border);
  background: var(--surface-2);
}

@media (max-width: 1400px) {
  .cards-grid { grid-template-columns: repeat(3, 1fr); }
  .timeline { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1080px) {
  .login-panel,
  .detail-grid,
  .filters-grid,
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .detail-list,
  .detail-list.three-cols,
  .timeline {
    grid-template-columns: 1fr;
  }

  .topbar,
  .detail-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions,
  .filters-actions {
    width: 100%;
  }

  .btn, .theme-toggle {
    width: 100%;
  }
}
