@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Backgrounds */
  --bg-main: #F4F6FB;
  --bg-secondary: #EEF2F6;
  
  /* Typography */
  --text-main: #334155;
  --text-muted: #64748B;
  
  /* Core Gradients */
  --grad-mint: linear-gradient(135deg, #10B981, #34D399);
  --grad-blue: linear-gradient(135deg, #0284C7, #38BDF8);
  --grad-violet: linear-gradient(135deg, #8B5CF6, #C084FC);
  --grad-orange: linear-gradient(135deg, #F97316, #FDBA74);
  --grad-red: linear-gradient(135deg, #EF4444, #F87171);
  
  /* Shadows */
  --shadow-soft: 0 16px 32px rgba(18, 38, 63, 0.06);
  --shadow-inner: inset 0 2px 4px rgba(255, 255, 255, 0.8), inset 0 -2px 4px rgba(18, 38, 63, 0.05);
  
  /* Border Radiuses */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-main);
}

body {
  margin: 0;
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 400;
}

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

h1 {
  font-size: 19px;
  font-weight: 700;
}

h2 {
  font-size: 13px;
  font-weight: 700;
}

p {
  color: var(--text-muted);
}

.gradient-text-blue {
  background: var(--grad-blue);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 212px;
  max-height: 100vh;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border-right: 1px solid rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px 12px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.1);
}

.brand-logo {
  display: block;
  width: 96px;
  max-width: 100%;
  height: auto;
}

nav {
  display: grid;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-btn {
  width: 100%;
  min-height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-main);
  transform: translateX(4px);
}

.nav-btn.active {
  background: var(--grad-blue);
  color: #ffffff;
  box-shadow: var(--shadow-soft);
}

.session-bar {
  margin: 0 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(18, 38, 63, 0.1);
  display: grid;
  gap: 8px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.session-bar a {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
}

.shell {
  min-height: 100vh;
  margin-left: 212px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 18px;
  background: rgba(244, 246, 251, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

#view-subtitle {
  margin-top: 3px;
  font-size: 11px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Glass Cards mapped to metrics and panels */
.metric, .panel {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft), var(--shadow-inner);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  opacity: 0;
  animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.metric:hover, .panel:hover {
  transform: translateY(-5px) scale(1.005);
  box-shadow: 0 24px 48px rgba(18, 38, 63, 0.1), var(--shadow-inner);
}

.metric {
  padding: 12px;
  min-height: 78px;
}

.metric strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text-main);
  font-size: 20px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.metric span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.route-path-originator {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

@media (max-width: 900px) {
  .route-path-originator {
    grid-template-columns: 1fr;
  }
}

.panel {
  overflow: hidden;
}

.panel-head {
  min-height: 38px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
  background: rgba(255, 255, 255, 0.4);
}

.bind-tabs {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  padding-top: 4px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.08);
}

.bind-tabs button {
  border-radius: 10px 10px 0 0;
  box-shadow: none;
}

.bind-tabs button.active {
  background: var(--grad-blue);
  color: #fff;
}

.bind-tab-panel {
  display: none;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 4px 0;
}

.bind-tab-panel.active {
  display: grid;
}

.form-hint {
  grid-column: 1 / -1;
  font-size: 12px;
}

button {
  border: 0;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  background: #ffffff;
  border: 1px solid rgba(18, 38, 63, 0.1);
  color: var(--text-main);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(18, 38, 63, 0.1);
}

button::after {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: all 0.5s ease;
}

button:hover::after {
  left: 150%;
}

button.primary {
  background: var(--grad-blue);
  color: #ffffff;
  border: none;
}

button.link-btn {
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: #0284C7;
  box-shadow: none;
}

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

.form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 9px;
  padding: 11px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
  align-items: end;
}

.form label {
  display: grid;
  gap: 5px;
}

.form label span {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  min-height: 30px;
  border: 1px solid rgba(18, 38, 63, 0.1);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  font: inherit;
  transition: all 0.2s ease;
}

textarea {
  min-height: 132px;
  grid-column: 1 / -1;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.pill, .status-dot {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.75rem;
  font-size: 12px;
  font-weight: 600;
}

.pill.active, .pill.delivered, .pill.approved, .pill.ok, .pill.settled, .pill.posted, .status-dot:not(.error) {
  background: rgba(16, 185, 129, 0.1);
  color: #10B981;
}

.pill.scheduled, .pill.pending, .pill.received, .pill.open {
  background: rgba(249, 115, 22, 0.1);
  color: #F97316;
}

.pill.archived, .pill.void, .pill.disabled {
  background: rgba(100, 116, 139, 0.1);
  color: var(--text-muted);
}

.pill.failed, .pill.rejected, .pill.dead, .pill.mismatch, .status-dot.error {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
}

.pill.processing, .pill.retrying, .pill.provider_credit {
  background: rgba(139, 92, 246, 0.1);
  color: #8B5CF6;
}

.alerts, .content {
  width: min(100%, 1560px);
  margin: 0 auto;
  padding: 14px 18px;
}

.alerts {
  padding-bottom: 0;
}

.alerts:empty {
  display: none;
}

.content {
  display: grid;
  gap: 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 0.9rem;
  align-items: start;
}

.chart-body {
  padding: 12px 14px 14px;
}

.chart-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.chart-summary strong {
  color: var(--text-main);
  font-size: 18px;
  line-height: 1;
}

.chart-summary span,
.empty-state {
  color: var(--text-muted);
  font-size: 12px;
}

.chart-plot {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.chart-y-axis {
  height: 146px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding-top: 10px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

.chart-area {
  position: relative;
  height: 146px;
}

.chart-grid {
  position: absolute;
  inset: 10px 0 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.chart-grid span {
  display: block;
  border-top: 1px solid rgba(18, 38, 63, 0.08);
}

.minute-chart {
  position: absolute;
  inset: 10px 0 0;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.16);
}

.minute-bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px 2px 0 0;
  background: #0284C7;
  opacity: 0.78;
}

.minute-bar:hover {
  opacity: 1;
}

.empty-state {
  padding: 10px 0;
}

.recent-stack {
  display: grid;
  gap: 0.9rem;
}

.recent-block {
  overflow: hidden;
}

.recent-summary {
  min-height: 38px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.recent-summary::-webkit-details-marker {
  display: none;
}

.recent-summary strong {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.recent-row-positive td {
  background: rgba(16, 185, 129, 0.1);
}

.recent-row-negative td {
  background: rgba(239, 68, 68, 0.1);
}

.recent-row-neutral td {
  background: rgba(255, 255, 255, 0.5);
}

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

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

th, td {
  max-width: 220px;
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

td {
  color: var(--text-main);
  white-space: nowrap;
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.5);
}

tbody tr.total-row {
  background: rgba(18, 38, 63, 0.06);
  font-weight: 700;
}

tbody tr.company-total-row {
  background: rgba(16, 185, 129, 0.12);
  font-weight: 800;
}

tbody tr.grand-total-row {
  background: rgba(2, 132, 199, 0.16);
  font-weight: 900;
}

tbody tr.company-gap-row td {
  height: 14px;
  padding: 0;
  border-bottom: 0;
  background: transparent;
}

.alert {
  padding: 12px 14px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: var(--radius-sm);
  color: #F97316;
  font-weight: 600;
}

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

.metric:nth-child(1) { animation-delay: 0.05s; }
.metric:nth-child(2) { animation-delay: 0.1s; }
.metric:nth-child(3) { animation-delay: 0.15s; }
.metric:nth-child(4) { animation-delay: 0.2s; }

.panel:nth-child(1) { animation-delay: 0.1s; }
.panel:nth-child(2) { animation-delay: 0.2s; }
.panel:nth-child(3) { animation-delay: 0.3s; }

@media (max-width: 1120px) {
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.9);
  }

  .brand {
    flex: 0 0 auto;
    padding-bottom: 0;
    border-bottom: 0;
  }

  nav {
    display: flex;
    flex: 1 0 auto;
    overflow: visible;
    padding-right: 0;
  }

  .nav-btn {
    width: auto;
    white-space: nowrap;
  }

  .shell {
    margin-left: 0;
  }

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

@media (max-width: 680px) {
  body {
    font-size: 13px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .alerts,
  .content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .grid,
  .two-col,
  .split-grid,
  .form,
  .bind-tab-panel {
    grid-template-columns: 1fr;
  }

th,
td {
  padding: 9px 10px;
}
}
