@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --ink: #0b1220;
  --muted: #5b6577;
  --accent: #1d4ed8;
  --accent-2: #2563eb;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --bg-1: #ffffff;
  --bg-2: #e8eef8;
  --bg-3: #f4f7fd;
}

body.dark {
  --ink: #e6eefb;
  --muted: #9fb1c9;
  --accent: #5aa6ff;
  --accent-2: #2f75e6;
  --surface: #0f1b2d;
  --surface-2: #15243a;
  --border: rgba(145, 178, 221, 0.2);
  --shadow: 0 20px 50px rgba(5, 12, 22, 0.5);
  --bg-1: #0a1626;
  --bg-2: #0d2140;
  --bg-3: #111b2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, var(--bg-3), transparent 55%),
    radial-gradient(circle at 10% 90%, var(--bg-2), transparent 55%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-3) 45%, var(--bg-1) 100%);
  min-height: 100vh;
}

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: grid;
  gap: 28px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--accent-2);
  margin: 0 0 6px;
}

h1 {
  font-size: clamp(32px, 3vw, 46px);
  margin: 0 0 8px;
}

.sub {
  margin: 0;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.status {
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent-2);
}

.panel {
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
  border: 1px solid var(--border);
  display: grid;
  gap: 18px;
  animation: fadeIn 0.6s ease;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 20px;
}

button {
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.4);
}

button.ghost:hover {
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.15);
}

.link-button {
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid rgba(37, 99, 235, 0.4);
  color: var(--accent);
}

.link-button:hover {
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.15);
}

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

.top-tabs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.top-tabs-right {
  margin-left: auto;
}

.tab {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
}

.tab.active {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.type-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls-flex {
  display: flex;
  gap: 12px;
  align-items: center;
}

.controls-flex input {
  flex: 1;
}

.hidden {
  display: none;
}

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

.preview-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-canvas {
  background: #f9f6ef;
  border-radius: 16px;
  padding: 16px;
  display: grid;
  place-items: center;
  min-height: 420px;
}

.preview-canvas canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 15, 30, 0.45);
}

.modal-content {
  position: relative;
  width: min(1200px, 94vw);
  max-height: 90vh;
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  gap: 20px;
  overflow: auto;
  animation: fadeIn 0.3s ease;
}

.modal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-form {
  display: grid;
  gap: 12px;
}

.modal-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.modal-actions {
  display: grid;
  gap: 8px;
}

.modal-actions span {
  color: var(--muted);
  font-size: 13px;
}

.preview-panel {
  display: grid;
  gap: 14px;
}

.preview-panel .preview-canvas {
  background: var(--surface-2);
  min-height: 420px;
}

.line-items-panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  background: var(--surface-2);
  display: grid;
  gap: 12px;
}

.line-items-panel.hidden {
  display: none;
}

.line-items-title {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.line-items-table {
  display: grid;
  gap: 8px;
}

.line-items-row {
  display: grid;
  grid-template-columns: 1.6fr 0.4fr 0.5fr 0.5fr 0.9fr;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface);
  font-size: 13px;
}

.line-items-row.header {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  padding: 0 4px 4px;
}

.line-items-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(239, 95, 60, 0.25);
}

.table {
  display: grid;
  gap: 12px;
}

.row {
  display: grid;
  grid-template-columns: 1.2fr 0.6fr 0.5fr 0.6fr 1fr;
  gap: 16px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: border 0.2s ease;
  cursor: pointer;
}

.row.processed {
  grid-template-columns: 0.4fr 1.3fr 1.6fr 0.7fr 0.5fr 0.4fr;
  align-items: center;
}

.row>div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row.header {
  background: transparent;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  border: none;
  padding: 0 16px 4px;
  cursor: default;
}

.row.needs-review {
  border-color: rgba(239, 95, 60, 0.4);
}

.row:hover {
  border-color: rgba(37, 99, 235, 0.35);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(11, 107, 92, 0.12);
  color: var(--accent-2);
}

.tag.alert {
  background: rgba(239, 95, 60, 0.18);
  color: var(--accent);
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
}

select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
}

input:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

select:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

@media (max-width: 900px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-fields {
    grid-template-columns: 1fr;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Date Popover */
.popover {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  min-width: 250px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.popover.hidden {
  display: none;
}

.popover-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.popover-presets button {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.popover-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.popover-inputs label {
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popover-inputs input {
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}


/* Queue Controls */
.queue-panel {
  display: grid;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  animation: fadeIn 0.4s ease;
}

.queue-panel.hidden {
  display: none;
}

.queue-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.queue-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 14px;
}

#queue-counter {
  font-feature-settings: "tnum";
}

.progress-bar-container {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.queue-actions {
  display: flex;
  gap: 8px;
}

.queue-actions button {
  padding: 6px 14px;
  font-size: 13px;
}