:root {
  --panel: rgba(8, 29, 45, 0.94);
  --card: rgba(255, 255, 255, 0.9);
  --line: rgba(12, 27, 38, 0.12);
  --text: #10202c;
  --text-soft: #556773;
  --accent: #f47b20;
  --accent-deep: #0f3f58;
  --shadow: 0 24px 60px rgba(12, 26, 37, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: "Segoe UI Variable Text", "Bahnschrift", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(244, 123, 32, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(9, 71, 110, 0.14), transparent 26%),
    linear-gradient(140deg, #dde5e8, #f4f6f7 42%, #e8eff3);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(10, 33, 49, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10, 33, 49, 0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  min-height: 100vh;
}

body.app-authenticated .page-shell {
  grid-template-columns: 1fr;
}

body.app-authenticated .hero-panel {
  display: none;
}

.hero-panel {
  padding: 44px;
  background:
    linear-gradient(160deg, rgba(244, 123, 32, 0.22), transparent 38%),
    linear-gradient(180deg, #0d2c40 0%, #081d2d 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-mark img {
  width: 220px;
  max-width: 100%;
  display: block;
}

.hero-kicker,
.chip {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 8px 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.hero-kicker {
  background: rgba(255, 255, 255, 0.1);
  color: #f7c093;
}

.hero-panel h1 {
  margin: 20px 0 14px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.96;
  max-width: 8ch;
}

.hero-meta {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  color: rgba(255, 255, 255, 0.88);
}

.hero-support {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.hero-support-block {
  display: grid;
  gap: 6px;
  color: rgba(255, 255, 255, 0.92);
}

.hero-support-label {
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

.hero-support a {
  color: #f7c093;
  text-decoration: none;
}

.hero-support a:hover {
  text-decoration: underline;
}

.workspace {
  padding: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
}

.auth-card,
.dashboard {
  width: min(1320px, 100%);
}

.auth-card,
.detail-panel,
.table-card,
.kpi-card {
  background: var(--card);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 520px;
  padding: 34px;
}

.stack {
  display: grid;
  gap: 18px;
}

label span,
.table-meta,
.title-block p,
.panel-source,
.feedback,
.detail-preview {
  color: var(--text-soft);
}

input {
  width: 100%;
  border: 1px solid rgba(10, 33, 49, 0.14);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 0.96rem;
  color: var(--text);
}

button,
.upload-btn span {
  font: inherit;
}

.primary-btn,
.upload-btn,
.ghost-btn,
.tab-btn {
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.primary-btn {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent), #ff9a47);
  color: white;
}

.primary-btn:disabled {
  opacity: 0.72;
  cursor: progress;
}

.ghost-btn {
  padding: 12px 16px;
  background: rgba(8, 29, 45, 0.08);
  color: var(--text);
}

.dashboard {
  display: grid;
  gap: 12px;
  min-height: calc(100vh - 56px);
  overflow: hidden;
}

.dashboard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 48px;
}

.panel-head h3 {
  margin: 0;
  font-size: 1.7rem;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
}

.upload-btn {
  position: relative;
  overflow: hidden;
}

.upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-btn span {
  display: inline-flex;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent-deep), #146a81);
  color: white;
}

.chip {
  background: rgba(13, 44, 64, 0.08);
  color: #0d516d;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.kpi-strip-vertical {
  grid-template-columns: 1fr;
}

.main-nav {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
}

.main-nav-btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  background: rgba(8, 29, 45, 0.08);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  flex: 0 0 180px;
  min-width: 180px;
  height: 48px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.main-nav-btn.active {
  background: linear-gradient(135deg, var(--accent), #ff9a47);
  color: white;
}

.kpi-card {
  padding: 12px 14px;
  border-radius: 18px;
  box-shadow: none;
}

.kpi-card span {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}

.kpi-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
}

.detail-panel,
.table-card {
  padding: 18px;
}

.page-panel {
  min-height: calc(100vh - 190px);
}

.table-card-compact {
  display: grid;
  gap: 12px;
}

.suivi-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-height: 0;
  overflow: hidden;
}

.kpi-drawer {
  position: sticky;
  top: 0;
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 0;
}

.kpi-drawer.is-open {
  width: 220px;
  min-width: 220px;
}

.kpi-drawer.is-collapsed {
  width: 42px;
  min-width: 42px;
}

.kpi-toggle {
  border: none;
  border-radius: 16px;
  height: 48px;
  background: rgba(8, 29, 45, 0.08);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.kpi-drawer.is-collapsed .kpi-strip {
  display: none;
}

.kpi-drawer.is-collapsed .priority-toggle-drawer {
  display: none;
}

.suivi-card {
  min-height: calc(100vh - 190px);
  min-width: 0;
  overflow: hidden;
}

.suivi-layout.kpi-collapsed {
  grid-template-columns: 42px minmax(0, 1fr);
}

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

.panel-head-compact {
  min-height: 18px;
  justify-content: flex-end;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.detail-item {
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.detail-item span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}

.detail-preview {
  margin: 14px 0 0;
  line-height: 1.5;
}

.sheet-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: -2px;
  min-width: 0;
}

.sheet-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: visible;
  padding-bottom: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.tab-btn {
  padding: 10px 12px;
  background: rgba(8, 29, 45, 0.08);
  color: var(--text);
  min-width: 0;
  text-align: center;
  flex: 1 1 0;
  white-space: nowrap;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent), #ff9a47);
  color: white;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.priority-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  white-space: nowrap;
}

.priority-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.priority-toggle span {
  margin: 0;
  color: var(--text);
}

.search-input {
  min-width: 220px;
  max-width: 340px;
}

.topbar-search {
  width: 320px;
  min-width: 220px;
  max-width: 320px;
}

.table-wrap {
  overflow: auto;
  max-height: 68vh;
  border-radius: 16px;
  border: 1px solid var(--line);
  min-width: 0;
  max-width: 100%;
}

.table-wrap-compact {
  max-height: calc(100vh - 180px);
}

table {
  width: max-content;
  border-collapse: collapse;
  min-width: 100%;
  table-layout: auto;
  background: rgba(255, 255, 255, 0.72);
}

thead th {
  position: sticky;
  top: 0;
  background: #f7fafc;
  z-index: 1;
  text-align: left;
  padding: 10px 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  border-bottom: 1px solid var(--line);
  height: 48px;
  min-height: 48px;
  white-space: nowrap;
  min-width: 132px;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  vertical-align: top;
  font-size: 0.84rem;
  min-width: 132px;
}

.table-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.priority-toggle-drawer {
  display: flex;
}

tbody tr:hover {
  background: rgba(244, 123, 32, 0.06);
}

.row-enriched {
  background: rgba(15, 143, 122, 0.05);
}

.row-generated {
  background: rgba(244, 123, 32, 0.08);
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  max-height: calc(100vh - 260px);
  overflow: auto;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.history-main,
.history-meta {
  display: grid;
  gap: 4px;
}

.history-main span,
.history-meta span,
.history-empty {
  color: var(--text-soft);
}

.history-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.history-delete-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(179, 59, 45, 0.1);
  color: #b33b2d;
  cursor: pointer;
  font: inherit;
}

.history-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(15, 63, 88, 0.1);
  color: var(--accent-deep);
  text-decoration: none;
  font-size: 1.1rem;
}

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

.upload-dropzone {
  display: grid;
  gap: 8px;
  padding: 28px;
  border: 2px dashed rgba(15, 63, 88, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  cursor: pointer;
}

.upload-dropzone input {
  display: none;
}

.upload-dropzone-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.upload-dropzone-text {
  color: var(--text-soft);
}

.upload-progress {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid rgba(15, 63, 88, 0.16);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.detail-panel-inline {
  padding: 16px;
  box-shadow: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 29, 45, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
}

.modal-card {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions,
.modal-preview-head,
.modal-preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h3 {
  margin: 10px 0 0;
  font-size: 1.4rem;
}

.modal-text {
  color: var(--text-soft);
  margin: 14px 0 18px;
}

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

.modal-preview-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(247, 250, 252, 0.88);
}

.modal-preview-head span,
.modal-preview-meta span,
.modal-empty,
.modal-change-item span {
  color: var(--text-soft);
}

.modal-preview-meta {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 6px;
}

.modal-change-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.modal-change-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
}

.modal-section-title {
  margin-top: 14px;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.modal-row-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.modal-row-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
}

.modal-row-item span {
  color: var(--text-soft);
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none;
}

.success {
  color: #0b8f7a;
}

.error {
  color: #b33b2d;
}

@media (max-width: 1200px) {
  body {
    overflow-y: auto;
  }

  .page-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .workspace {
    padding: 20px;
    min-height: auto;
    overflow: visible;
  }

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

  .suivi-layout {
    grid-template-columns: 1fr;
  }

  .kpi-drawer,
  .kpi-drawer.is-open,
  .kpi-drawer.is-collapsed {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 840px) {
  body {
    overflow-y: auto;
  }

  .hero-panel {
    display: none;
  }

  .hero-panel {
    padding: 24px 20px;
    gap: 18px;
  }

  .hero-mark img {
    width: 180px;
  }

  .hero-panel h1 {
    max-width: none;
    font-size: 1.9rem;
  }

  .hero-meta,
  .hero-support {
    margin-top: 12px;
  }

  .workspace {
    padding: 16px;
    overflow: visible;
  }

  .auth-card {
    max-width: none;
    width: 100%;
    padding: 22px 18px;
    margin: 0;
  }

  .dashboard-topbar,
  .sheet-toolbar,
  .sheet-actions,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .sheet-actions {
    min-width: 0;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar-search {
    width: 100%;
    max-width: none;
  }

  .main-nav {
    flex-wrap: wrap;
  }

  .main-nav-btn,
  .tab-btn {
    flex: 1 1 100%;
    min-width: 0;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .search-input {
    min-width: 0;
    max-width: none;
  }

  .kpi-strip,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 16px;
  }

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

@media (max-width: 520px) {
  .page-shell {
    min-height: auto;
  }

  .hero-panel {
    display: none;
  }

  .hero-panel {
    padding: 18px 16px;
  }

  .workspace {
    padding: 12px;
  }

  .auth-card {
    padding: 18px 14px;
    border-radius: 18px;
  }

  input,
  .primary-btn,
  .ghost-btn {
    font-size: 0.95rem;
  }
}
