:root {
  --sidebar-from: #131a22;
  --sidebar-to: #232f3e;
  --sidebar-accent: #ff9900;
  --sidebar-glow: rgba(255, 153, 0, 0.3);
  --sidebar-text: #f1f5f9;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(255, 153, 0, 0.18);
  --sidebar-active-border: #ffb84d;
  --bg: #eef2f7;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --green: #15803d;
  --green-bg: #dcfce7;
  --blue: #1d4ed8;
  --blue-bg: #dbeafe;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --grey: #475569;
  --grey-bg: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #e8eef6 0%, var(--bg) 120px);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(145deg, #131a22 0%, #232f3e 55%, #ff9900 160%);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 2rem 2rem 1.75rem;
}

.login-brand { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 1.5rem; }
.login-title { margin: 0 0 0.35rem; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
.login-subtitle { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.92rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-field { display: flex; flex-direction: column; gap: 0.35rem; }
.login-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.login-field input { width: 100%; padding: 0.65rem 0.8rem; border: 1px solid var(--border); border-radius: 10px; font-size: 0.95rem; }
.login-field input:focus { outline: none; border-color: var(--sidebar-accent); box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.15); }
.login-error { margin: 0; color: var(--red); font-size: 0.875rem; }
.login-submit { width: 100%; margin-top: 0.25rem; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  background: linear-gradient(165deg, var(--sidebar-from) 0%, var(--sidebar-to) 55%, #16324f 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  flex-shrink: 0;
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
  position: relative;
  overflow: hidden;
}

.sidebar::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -30%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--sidebar-glow) 0%, transparent 70%);
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 0.85rem; padding: 0 1.35rem 1.35rem; margin-bottom: 0.5rem; position: relative; z-index: 1; }
.brand-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--sidebar-accent), #ffc266);
  display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; color: #131a22;
  box-shadow: 0 4px 12px rgba(255, 153, 0, 0.4);
}
.brand-title { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.62rem; letter-spacing: 0.14em; color: var(--sidebar-muted); margin-top: 3px; font-weight: 500; }

.nav-label { padding: 0.75rem 1.35rem 0.4rem; font-size: 0.65rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--sidebar-muted); position: relative; z-index: 1; }
.nav { display: flex; flex-direction: column; gap: 0.25rem; padding: 0 0.85rem; flex: 1; position: relative; z-index: 1; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.9rem; border-radius: 10px;
  color: var(--sidebar-text); text-decoration: none; font-size: 0.88rem; font-weight: 500;
  transition: background 0.18s, transform 0.12s; border: 1px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { background: var(--sidebar-active); border-color: rgba(255, 184, 77, 0.35); font-weight: 600; box-shadow: inset 3px 0 0 var(--sidebar-active-border); }
.nav-icon { width: 1.35rem; height: 1.35rem; display: grid; place-items: center; font-size: 0.95rem; opacity: 0.9; }

.sidebar-footer { padding: 1.25rem 1.35rem 0; font-size: 0.75rem; color: var(--sidebar-muted); display: flex; flex-direction: column; align-items: flex-start; gap: 0.65rem; position: relative; z-index: 1; }
.btn-logout { padding: 0.35rem 0.65rem; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px; background: transparent; color: var(--sidebar-text); font-size: 0.75rem; font-weight: 600; cursor: pointer; }
.btn-logout:hover { background: var(--sidebar-hover); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px rgba(74, 222, 128, 0.6); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.main { flex: 1; padding: 1.5rem 2rem 2rem; overflow: auto; min-width: 0; }
.page-header { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.25rem; }
.page-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.25rem; }
.page-topbar-actions { display: flex; align-items: flex-end; gap: 0.65rem; flex-shrink: 0; padding-top: 0.15rem; }

.btn-sap-retry {
  padding: 0.55rem 1rem; border: 1px solid #f59e0b; border-radius: 10px; background: #fffbeb; color: #92400e;
  font-size: 0.875rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn-sap-retry:hover:not(:disabled) { background: #fef3c7; border-color: #d97706; box-shadow: 0 1px 2px rgba(146, 64, 14, 0.08); }
.btn-sap-retry:disabled { opacity: 0.65; cursor: not-allowed; }

.page-eyebrow { margin: 0 0 0.3rem; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.page-header h1 { margin: 0; font-size: 1.65rem; font-weight: 700; letter-spacing: -0.03em; color: var(--text); line-height: 1.2; }
.page-title-muted { font-weight: 500; color: var(--muted); font-size: 0.88em; }
.page-header-intro { min-width: 0; flex: 1 1 220px; }

.stat-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.7rem; }
.stat-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.74rem; font-weight: 600; background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow-sm); line-height: 1.3; }
.stat-chip--success { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.stat-chip--danger { background: var(--red-bg); color: var(--red); border-color: #fecaca; }
.stat-chip--muted { background: #f8fafc; color: var(--muted); border-color: var(--border-light); }

.filter-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem 0.9rem; box-shadow: var(--shadow-sm); }
.filter-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem 0.85rem; align-items: end; }
.filter-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.filter-label { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.filter-field input[type="search"], .filter-field input[type="date"], .filter-field select {
  width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: 10px; background: #fafbfc;
  font-size: 0.875rem; font-weight: 500; color: var(--text); transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.filter-field input:focus, .filter-field select:focus { outline: none; border-color: var(--sidebar-accent); background: #fff; box-shadow: 0 0 0 3px rgba(255, 153, 0, 0.12); }
.filter-card-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px solid var(--border-light); }

.btn-ghost { padding: 0.55rem 1rem; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: background 0.15s, color 0.15s; }
.btn-ghost:hover { background: var(--border-light); color: var(--text); }

.btn-primary { padding: 0.55rem 1.15rem; border-radius: 10px; background: linear-gradient(135deg, var(--sidebar-accent), #f97316); color: #1a1200; border: none; font-size: 0.875rem; font-weight: 700; cursor: pointer; box-shadow: 0 2px 8px rgba(255, 153, 0, 0.35); transition: background 0.15s, box-shadow 0.15s, transform 0.12s; }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 12px rgba(255, 153, 0, 0.4); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-outline { padding: 0.52rem 1.1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 0.875rem; font-weight: 600; color: var(--text); transition: background 0.15s, border-color 0.15s; }
.btn-outline:hover:not(:disabled) { background: var(--border-light); border-color: #cbd5e1; }
.btn-outline:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-view { padding: 0.38rem 0.9rem; border: none; border-radius: 7px; background: linear-gradient(135deg, var(--sidebar-accent), #f97316); color: #1a1200; font-size: 0.78rem; font-weight: 700; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm); }
.btn-view:hover { transform: translateY(-1px); }

.error-banner { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.875rem; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-md); }
.table-scroll { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.report-table thead th {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%); color: var(--muted); font-weight: 700; text-align: left;
  padding: 0.75rem 0.85rem; border-bottom: 2px solid var(--border); white-space: nowrap; font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.06em; position: sticky; top: 0; z-index: 2;
}
.report-table tbody td { padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border-light); vertical-align: middle; line-height: 1.4; }
.report-table tbody tr.data-row:hover { background: #f8fafc; }
.report-table tbody tr:nth-child(even) { background: #fafbfc; }

.loading-cell { text-align: center; color: var(--muted); padding: 2.5rem !important; }
.col-idx { width: 3rem; text-align: center !important; }
.col-action { width: 6rem; text-align: center !important; }
.cell-center { text-align: center; }
.cell-muted { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.cell-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.78rem; }

.sortable-th { padding: 0; }
.sortable-btn { display: flex; align-items: center; gap: 0.35rem; width: 100%; padding: 0.75rem 0.85rem; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer; text-align: left; }
.sortable-btn:hover { color: var(--sidebar-accent); }
.sortable-th--active .sortable-btn { color: #c2410c; }
.sort-indicator { font-size: 0.65rem; line-height: 1; opacity: 0.9; }

.badge { display: inline-flex; align-items: center; padding: 0.22rem 0.55rem; border-radius: 999px; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; border: 1px solid transparent; }
.badge-success { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.badge-failed { background: var(--red-bg); color: var(--red); border-color: #fecaca; }
.badge-running { background: var(--blue-bg); color: var(--blue); border-color: #bfdbfe; }
.badge-acknowledged { background: var(--grey-bg); color: var(--grey); border-color: #e2e8f0; }
.badge-created { background: var(--amber-bg); color: var(--amber); border-color: #fde68a; }
.badge-default { background: var(--grey-bg); color: var(--grey); }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.9rem 1.15rem; border-top: 1px solid var(--border); background: #fafbfc; flex-wrap: wrap; }
.pagination-info { font-size: 0.84rem; color: var(--muted); font-weight: 500; }
.pagination-actions { display: flex; align-items: flex-end; gap: 0.65rem; }
.filter-inline { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.filter-inline select { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 0.875rem; font-weight: 500; min-width: 72px; color: var(--text); cursor: pointer; }

.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.modal-card { position: relative; width: min(760px, 100%); max-height: 85vh; background: #fff; border-radius: 12px; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25); display: flex; flex-direction: column; overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1rem; border-bottom: 1px solid #e2e8f0; }
.modal-header h2 { margin: 0; font-size: 1rem; }
.modal-close { border: none; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 1rem; overflow: auto; }

.trace-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.trace-card { background: linear-gradient(180deg, #f8fafc, #fff); border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.9rem; }
.trace-card-label { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.3rem; font-weight: 600; }
.trace-card-value { font-weight: 600; font-size: 0.9rem; word-break: break-all; }

.order-detail-box { border: 1px solid var(--border); border-radius: 12px; background: #fafbfc; overflow: hidden; }
.order-detail-box-title { padding: 0.65rem 1rem; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: #f1f5f9; border-bottom: 1px solid var(--border); }

.trace-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.trace-table th, .trace-table td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border-light); text-align: left; }
.trace-table th { background: #f1f5f9; color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; }

.sap-error-inline { margin: 0 0 1rem; padding: 0.75rem; background: var(--red-bg); color: #991b1b; border: 1px solid #fecaca; border-radius: 8px; font-size: 0.74rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; overflow: auto; max-height: 200px; }

.muted { color: var(--muted); font-size: 0.85rem; }
.trace-error { color: var(--red); padding: 1rem; }

@media (max-width: 1100px) {
  .filter-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 1rem; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label, .sidebar-footer { display: none; }
  .main { padding: 1rem; }
  .page-topbar { flex-direction: column; }
  .filter-card-grid { grid-template-columns: 1fr 1fr; }
  .report-table { table-layout: auto; min-width: 820px; }
}
