:root {
  --yellow: #ffc300;
  --red: #da291c;
  --ink: #1f2328;
  --muted: #667085;
  --line: #e7e9ee;
  --surface: #ffffff;
  --canvas: #f4f5f7;
  --green: #16845b;
  --shadow: 0 14px 40px rgba(31, 35, 40, 0.09);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

button, input, select { font: inherit; }

button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(218, 41, 28, 0.28);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img { width: auto; height: 42px; }
.brand span { display: grid; }
.brand strong { font-size: 1rem; }
.brand small { color: var(--muted); font-size: 0.76rem; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.page-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 24px auto 70px;
}

.launch-banner {
  padding: clamp(22px, 4vw, 34px);
  border-radius: 24px;
  color: #fff;
  background: linear-gradient(125deg, #2a2f36 0%, #3d4147 58%, #7a271f 100%);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.launch-banner.is-live { background: linear-gradient(125deg, #114d3b, #16845b 60%, #2a6655); }
.launch-banner h1 { margin: 4px 0 8px; font-size: clamp(1.35rem, 3vw, 2rem); }
.launch-banner p { margin: 0; max-width: 700px; color: rgba(255,255,255,0.78); }
.eyebrow { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; color: var(--red); }
.launch-banner .eyebrow { color: var(--yellow); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stats article {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 4px;
}

.stats span { color: var(--muted); font-size: 0.78rem; }
.stats strong { font-size: 1.45rem; }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(330px, 0.78fr) minmax(520px, 1.5fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(31, 35, 40, 0.05);
  padding: 22px;
}

.upload-panel { position: sticky; top: 94px; }
.panel-heading, .library-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 1.25rem; }

.upload-defaults, .filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

label { display: grid; gap: 7px; font-size: 0.78rem; font-weight: 700; color: #4f5662; }
input, select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #cfd4dc;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}

.drop-zone {
  margin: 16px 0;
  min-height: 195px;
  padding: 24px;
  border: 2px dashed #bdc3cc;
  border-radius: 16px;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  transition: 0.15s ease;
}

.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--red); background: #fff7f5; transform: translateY(-1px); }
.drop-zone span { color: var(--muted); font-size: 0.88rem; }
.drop-zone small { color: #89909a; margin-top: 8px; }
.drop-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #1d1f22 !important; background: var(--yellow); font-size: 1.5rem !important; font-weight: 900; }

.queue { display: grid; gap: 10px; margin-bottom: 14px; max-height: 460px; overflow: auto; }
.queue:empty { display: none; }
.queue-item { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.queue-top { display: flex; align-items: flex-start; gap: 9px; }
.queue-top > div { flex: 1; min-width: 0; }
.queue-name { margin: 0; font-size: 0.82rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-meta { margin-top: 3px; color: var(--muted); font-size: 0.7rem; }
.queue-controls { display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px; margin-top: 10px; }
.queue-controls input, .queue-controls select { min-height: 36px; padding: 7px 8px; font-size: 0.76rem; }
.queue-progress { height: 5px; margin-top: 10px; border-radius: 999px; overflow: hidden; background: #eceff2; }
.queue-progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--red), var(--yellow)); transition: width 0.2s ease; }
.queue-status { display: block; margin-top: 5px; font-size: 0.7rem; color: var(--muted); }
.queue-item.is-error { border-color: #f0b4af; background: #fff8f7; }
.queue-item.is-complete { border-color: #9dd7c1; background: #f4fcf8; }

.button, .icon-button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button { min-height: 40px; padding: 9px 14px; font-size: 0.82rem; }
.button:disabled { opacity: 0.48; cursor: not-allowed; }
.button-primary { color: #1c1c1c; background: var(--yellow); }
.button-primary:hover { background: #ffd13e; }
.button-secondary { color: var(--ink); background: #fff; border: 1px solid #d7dbe1; }
.button-ghost { color: var(--muted); background: transparent; }
.button-dark { color: #fff; background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.24); }
.button-danger { color: #fff; background: var(--red); }
.button-wide { width: 100%; }
.icon-button { width: 32px; height: 32px; flex: 0 0 auto; background: #f2f3f5; color: #667085; font-size: 1.05rem; }

.filters { grid-template-columns: 1.4fr 1fr 0.8fr; margin-bottom: 16px; }
.document-list { display: grid; gap: 10px; }
.document-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.document-main { min-width: 0; }
.document-title { margin: 0; font-size: 0.94rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; color: var(--muted); font-size: 0.72rem; }
.status-pill { border-radius: 999px; padding: 3px 8px; font-weight: 800; }
.status-pill.active { color: #0d6b48; background: #dcf7eb; }
.status-pill.archived { color: #6d5361; background: #f2e9ee; }
.document-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.document-actions .button { min-height: 34px; padding: 7px 10px; font-size: 0.74rem; }
.empty-list { padding: 48px 20px; text-align: center; color: var(--muted); border: 1px dashed #d0d4db; border-radius: 14px; }

.login-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 15%, #fff6d5, #f4f5f7 46%, #f8eae8); }
.login-card { width: min(420px, 100%); padding: 34px; border-radius: 24px; background: #fff; box-shadow: var(--shadow); display: grid; gap: 16px; }
.login-card img { height: 54px; width: auto; }
.login-card h1 { margin: -8px 0 0; }
.login-card p { margin: -8px 0 0; color: var(--muted); line-height: 1.45; }
.form-error { min-height: 20px; color: var(--red) !important; font-size: 0.78rem; }

.modal { width: min(500px, calc(100% - 30px)); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 26px 80px rgba(16,24,40,.28); }
.modal::backdrop { background: rgba(20, 23, 28, 0.55); backdrop-filter: blur(3px); }
.modal form { padding: 24px; display: grid; gap: 16px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.modal h2 { margin: 4px 0 0; }
.modal p { margin: 0; color: var(--muted); line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 150; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; max-width: min(520px, calc(100% - 32px)); padding: 12px 16px; color: #fff; background: #20242a; border-radius: 10px; box-shadow: var(--shadow); transition: 0.2s ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.toast.is-error { background: #a9231a; }
.app-version { position: fixed; right: 10px; bottom: 8px; z-index: 30; padding: 4px 7px; border-radius: 7px; color: #60656e; background: rgba(255,255,255,.9); font-size: .68rem; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.08); }

@media (max-width: 980px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .upload-panel { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .topbar { align-items: flex-start; }
  .brand small { display: none; }
  .topbar-actions { flex-direction: column; align-items: stretch; }
  .topbar-actions .button { min-height: 34px; padding: 6px 9px; }
  .page-shell { width: min(100% - 20px, 1480px); margin-top: 10px; }
  .launch-banner { align-items: stretch; flex-direction: column; }
  .stats { gap: 8px; }
  .stats article { padding: 14px; }
  .panel { padding: 16px; }
  .upload-defaults, .filters { grid-template-columns: 1fr; }
  .queue-controls { grid-template-columns: 1fr; }
  .document-card { grid-template-columns: 1fr; }
  .document-actions { justify-content: flex-start; }
}
