:root {
  color-scheme: light;
  --bg: #fff3e8;
  --panel: rgba(255, 255, 255, 0.9);
  --ink: #12202a;
  --muted: #657584;
  --line: rgba(18, 32, 42, 0.12);
  --accent: #f2761d;
  --accent-dark: #b84d12;
  --gold: #ffd166;
  --shadow: 0 24px 70px rgba(126, 61, 18, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(242, 118, 29, 0.2), transparent 34rem),
    linear-gradient(135deg, #fffaf5 0%, var(--bg) 48%, #ffe3c7 100%);
}

body.login-active {
  height: 100vh;
  overflow: hidden;
}

.brand-ribbon {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.08;
  display: grid;
  align-content: space-around;
  transform: rotate(-7deg);
}

.brand-ribbon span {
  width: max-content;
  color: #9b3f0d;
  font-size: clamp(4rem, 12vw, 12rem);
  font-weight: 900;
  white-space: nowrap;
  animation: sweep 18s linear infinite;
}

.brand-ribbon span:nth-child(2) {
  animation-direction: reverse;
  animation-duration: 22s;
}

.brand-ribbon span:nth-child(3) {
  animation-duration: 26s;
}

@keyframes sweep {
  from {
    transform: translateX(-105vw);
  }
  to {
    transform: translateX(105vw);
  }
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 24px;
}

.login-active .app-shell {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.login-view {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.login-active .login-view {
  min-height: 0;
  height: calc(100vh - 48px);
}

.login-panel,
.panel,
.upload-card,
.metric-card,
.side-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-panel {
  width: min(440px, 100%);
  padding: 34px;
  border-radius: 8px;
}

.workspace-grid {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.workspace-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
}

.workspace-card img {
  flex: 0 0 96px;
  width: 96px;
  height: 56px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.workspace-card strong,
.workspace-card small {
  display: block;
}

.workspace-card strong {
  color: #24160d;
  font-size: 1rem;
}

.workspace-card small {
  margin-top: 4px;
  color: var(--muted);
}

.workspace-icon {
  display: grid;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.back-button {
  width: max-content;
  margin-bottom: 16px;
  padding: 8px 12px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.eyebrow,
.card-kicker {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
}

h2 {
  max-width: 820px;
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 1.04;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.muted {
  color: var(--muted);
  line-height: 1.55;
}

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

label {
  display: grid;
  gap: 8px;
  color: #5f341c;
  font-size: 0.9rem;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  font: inherit;
  background: rgba(255, 255, 255, 0.86);
}

button,
.file-button {
  border: 0;
  border-radius: 8px;
  padding: 13px 18px;
  color: #fff;
  font: inherit;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover,
.file-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(184, 77, 18, 0.24);
}

.ghost-button {
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.small-button {
  padding: 9px 12px;
  font-size: 0.84rem;
}

.error-text {
  min-height: 1.2em;
  margin: 0;
  color: #b42318;
  font-weight: 700;
}

.company-login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.company-login-brand img {
  width: 86px;
  height: 46px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.company-login-brand strong,
.company-login-brand span {
  display: block;
}

.company-login-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.is-hidden {
  display: none;
}

.dashboard-view {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  width: min(1320px, 100%);
  margin: 0 auto;
}

.dashboard-view.is-hidden {
  display: none;
}

.side-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
  padding: 20px;
  border-radius: 8px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.side-brand span {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.side-brand strong,
.side-brand small {
  display: block;
}

.side-brand small {
  margin-top: 4px;
  color: var(--muted);
}

.side-nav {
  display: grid;
  gap: 10px;
  margin: 24px 0 auto;
}

.side-nav a {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 13px 14px;
  color: #5f341c;
  font-weight: 900;
  text-decoration: none;
  background: rgba(255, 244, 232, 0.82);
}

.side-nav a:hover {
  border-color: rgba(242, 118, 29, 0.28);
  color: var(--accent-dark);
  background: #fff;
}

.dashboard-main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.3rem);
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  padding: 10px 16px;
  color: #4a2408;
  font-weight: 900;
  background: var(--gold);
}

.upload-grid,
.metric-grid,
.content-grid,
.upload-status-grid,
.chart-grid {
  display: grid;
  gap: 18px;
}

.view-section {
  display: none;
}

.view-section.is-active {
  display: block;
}

.side-nav a.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.upload-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.upload-status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.upload-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  border-radius: 8px;
}

.file-button {
  display: inline-grid;
  place-items: center;
  min-width: 136px;
}

.file-button input {
  display: none;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.chart-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.chart-panel {
  min-height: 260px;
}

.bar-chart {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(242, 118, 29, 0.14);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.bar-value {
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.metric-card {
  padding: 20px;
  border-radius: 8px;
}

.metric-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 800;
}

.metric-card strong {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
}

.content-grid {
  grid-template-columns: minmax(300px, 0.85fr) minmax(420px, 1.15fr);
  align-items: start;
}

.panel {
  min-height: 360px;
  padding: 22px;
  border-radius: 8px;
}

.compact-panel {
  min-height: auto;
}

.history-list {
  display: grid;
  gap: 10px;
}

.quality-list {
  display: grid;
  gap: 8px;
  line-height: 1.5;
}

.quality-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 242, 0.74);
}

.quality-item strong {
  color: var(--accent-dark);
}

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 242, 0.74);
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
}

.search-panel {
  min-height: auto;
  max-width: 980px;
}

.question-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: end;
  gap: 14px;
  margin-bottom: 12px;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  font: inherit;
  background: rgba(255, 255, 255, 0.92);
}

.question-examples {
  margin-bottom: 12px;
}

.answer-box {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 242, 0.8);
  line-height: 1.6;
}

.answer-box strong {
  color: var(--accent-dark);
}

.answer-box ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.follow-up-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -4px 0 16px;
}

.follow-up-actions button {
  padding: 9px 12px;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid rgba(242, 118, 29, 0.22);
}

.choice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.choice-actions button {
  padding: 9px 12px;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid rgba(242, 118, 29, 0.22);
}

.helper-summary {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 244, 232, 0.78);
  color: var(--muted);
  font-weight: 800;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  font: inherit;
  background: rgba(255, 255, 255, 0.92);
}

.quick-searches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.quick-searches button {
  padding: 9px 12px;
  color: var(--accent-dark);
  background: #fff4e8;
  border: 1px solid rgba(242, 118, 29, 0.22);
}

.search-results-wrap {
  max-height: 560px;
  margin-top: 12px;
}

.search-results-wrap.is-collapsed {
  display: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.summary-box {
  max-height: 520px;
  overflow: auto;
  color: #22343f;
  line-height: 1.65;
}

.summary-box ul {
  margin: 12px 0 0;
  padding-left: 20px;
}

.empty-state {
  color: var(--muted);
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: #fff;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.88rem;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  color: #fff;
  background: var(--accent-dark);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .dashboard-view {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    min-height: auto;
  }

  .topbar,
  .upload-card {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-grid,
  .upload-status-grid,
  .chart-grid,
  .metric-grid,
  .content-grid,
  .question-box {
    grid-template-columns: 1fr;
  }
}
