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

:root {
  --bg: #edf1f5;
  --bg-deep: #dfe7ee;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --panel-muted: #f7f9fb;
  --ink: #1d2630;
  --muted: #667384;
  --line: rgba(86, 102, 120, 0.16);
  --line-strong: rgba(56, 76, 99, 0.24);
  --brand: #245c88;
  --brand-dark: #174262;
  --brand-soft: #dbe9f5;
  --accent: #eb9a36;
  --accent-soft: #f9e4c7;
  --danger: #c65c3b;
  --danger-soft: #f8e0d9;
  --success: #1f8c67;
  --success-soft: #dbf2e8;
  --warning: #a7761e;
  --warning-soft: #f8edcf;
  --neutral-soft: #e8edf2;
  --shadow-lg: 0 18px 50px rgba(22, 35, 48, 0.08);
  --shadow-md: 0 10px 28px rgba(22, 35, 48, 0.06);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-sans: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(36, 92, 136, 0.12), transparent 22%),
    radial-gradient(circle at top right, rgba(235, 154, 54, 0.12), transparent 18%),
    linear-gradient(180deg, #f4f7fa 0%, var(--bg) 48%, var(--bg-deep) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.3), transparent 72%);
}

.app-shell {
  width: min(1680px, calc(100% - 32px));
  margin: 18px auto 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  margin-bottom: 18px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(86, 102, 120, 0.12);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
}

.brand-block {
  display: grid;
  gap: 6px;
}

.brand-kicker,
.section-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--brand);
}

.topbar h1,
.empty-copy h2,
.filters-panel h2,
.sheet-head h2,
.modal-copy h2 {
  margin: 0;
  line-height: 1;
  letter-spacing: -0.04em;
}

.topbar h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.main-stage {
  min-height: calc(100vh - 180px);
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 190px);
}

.empty-card,
.summary-panel,
.filters-panel,
.sheet-shell,
.modal-card {
  background: var(--panel);
  border: 1px solid rgba(86, 102, 120, 0.12);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}

.empty-card {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(400px, 1fr);
  gap: 22px;
  width: min(1180px, 100%);
  padding: 22px;
  border-radius: 30px;
}

.empty-sheet {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(36, 92, 136, 0.96), rgba(23, 66, 98, 0.98));
  color: #f2f8fc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.sheet-mock {
  display: grid;
  grid-template-columns: 1.45fr 1.1fr 0.55fr 0.55fr 0.9fr;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.86rem;
}

.sheet-mock-head {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.11);
}

.mock-badge {
  display: inline-flex;
  width: fit-content;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 700;
}

.mock-badge-warn {
  background: rgba(249, 228, 199, 0.22);
  color: #ffe0ad;
}

.mock-badge-ok {
  background: rgba(219, 242, 232, 0.2);
  color: #baf1dc;
}

.empty-copy {
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 12px 6px 12px 4px;
}

.empty-copy h2 {
  font-size: clamp(2.2rem, 3vw, 3rem);
}

.empty-text,
.modal-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1rem;
}

.upload-form {
  display: grid;
  gap: 14px;
}

.upload-tile {
  display: grid;
  gap: 10px;
  padding: 20px;
  border-radius: 22px;
  border: 1.5px dashed rgba(36, 92, 136, 0.25);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 249, 252, 0.98)),
    var(--panel-strong);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.upload-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(36, 92, 136, 0.5);
  box-shadow: var(--shadow-md);
}

.upload-tile input {
  display: none;
}

.upload-badge {
  width: fit-content;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.upload-title {
  font-size: 1.18rem;
  font-weight: 800;
}

.upload-subtitle {
  color: var(--muted);
  line-height: 1.65;
}

.upload-meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.file-name {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.primary-button,
.secondary-button {
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #f8fcff;
  box-shadow: 0 12px 24px rgba(36, 92, 136, 0.18);
}

.secondary-button {
  background: linear-gradient(180deg, #f6f8fa, #e7edf3);
  color: #4d5c6c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
  filter: saturate(1.04);
}

.primary-button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.inline-status {
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-size: 0.93rem;
  line-height: 1.6;
}

.status-idle {
  background: var(--neutral-soft);
  color: #586474;
}

.status-loading {
  background: rgba(36, 92, 136, 0.12);
  color: var(--brand);
  border-color: rgba(36, 92, 136, 0.14);
}

.status-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(31, 140, 103, 0.14);
}

.status-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(198, 92, 59, 0.14);
}

.workspace {
  display: grid;
  gap: 16px;
}

.summary-panel,
.filters-panel,
.sheet-shell {
  border-radius: var(--radius-xl);
}

.summary-panel,
.filters-panel {
  padding: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.summary-tile {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(86, 102, 120, 0.1);
  background: rgba(255, 255, 255, 0.72);
}

.summary-tile .label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

.summary-tile .value {
  display: block;
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.tone-brand {
  background: linear-gradient(180deg, rgba(219, 233, 245, 0.96), rgba(243, 248, 252, 0.98));
}

.tone-accent {
  background: linear-gradient(180deg, rgba(249, 228, 199, 0.96), rgba(253, 246, 236, 0.98));
}

.tone-danger {
  background: linear-gradient(180deg, rgba(248, 224, 217, 0.96), rgba(252, 243, 240, 0.98));
}

.tone-success {
  background: linear-gradient(180deg, rgba(219, 242, 232, 0.96), rgba(243, 250, 247, 0.98));
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 999px;
  background: #eef3f7;
  border: 1px solid rgba(86, 102, 120, 0.1);
  color: #526171;
  font-size: 0.84rem;
}

.panel-head,
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sheet-head {
  padding: 18px 18px 0;
}

.filters-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.35fr) repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(86, 102, 120, 0.14);
  background: #fbfdff;
  color: var(--ink);
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(36, 92, 136, 0.4);
  box-shadow:
    0 0 0 4px rgba(36, 92, 136, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.sheet-shell {
  overflow: hidden;
  padding-bottom: 14px;
}

.results-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
  max-height: 76vh;
  margin: 14px 18px 0;
  border: 1px solid rgba(86, 102, 120, 0.12);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.sheet-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.sheet-table th,
.sheet-table td {
  border-right: 1px solid #e7edf3;
  border-bottom: 1px solid #e7edf3;
  padding: 10px 12px;
  background: #ffffff;
  vertical-align: top;
}

.sheet-table th {
  position: sticky;
  top: 0;
  z-index: 8;
  background: linear-gradient(180deg, #f3f7fb, #e4edf6);
  color: #4c5b6b;
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.45;
  text-align: left;
}

.sheet-table td {
  line-height: 1.48;
}

.sheet-table tbody tr:nth-child(even) td {
  background: #fbfdff;
}

.sheet-table tbody tr:hover td {
  background: #f3f8fd;
}

.sheet-table .sticky-col {
  position: sticky;
  z-index: 6;
}

.sheet-table th.sticky-col {
  z-index: 11;
}

.sheet-table .sticky-col-0 {
  left: 0;
}

.sheet-table .sticky-col-1 {
  left: 92px;
}

.sheet-table th.sticky-col,
.sheet-table td.sticky-col {
  background: linear-gradient(180deg, #ffffff, #f8fbfe);
}

.sheet-table tbody tr:nth-child(even) td.sticky-col {
  background: #f9fcff;
}

.sheet-table tbody tr:hover td.sticky-col {
  background: #eef5fb;
}

.sheet-row-need_add td {
  box-shadow: inset 4px 0 0 rgba(198, 92, 59, 0.18);
}

.sheet-row-excess td {
  box-shadow: inset 4px 0 0 rgba(31, 140, 103, 0.18);
}

.sheet-row-balanced td {
  box-shadow: inset 4px 0 0 rgba(167, 118, 30, 0.18);
}

.sheet-row-no_orders td {
  box-shadow: inset 4px 0 0 rgba(86, 102, 120, 0.12);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

.cell-error {
  color: var(--danger);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-need_add {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-excess {
  background: var(--success-soft);
  color: var(--success);
}

.badge-balanced {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-no_orders {
  background: var(--neutral-soft);
  color: #5a6675;
}

.column-source_row_number {
  width: 92px;
  min-width: 92px;
  max-width: 92px;
}

.column-seller_article {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
}

.column-name {
  width: 320px;
  min-width: 320px;
}

.column-region,
.column-subject,
.column-brand,
.column-delivery_time {
  min-width: 160px;
}

.column-status_label {
  min-width: 126px;
}

.column-recommendation {
  min-width: 240px;
  font-weight: 600;
  color: #425160;
}

.is-calculation {
  background-image: linear-gradient(180deg, rgba(219, 233, 245, 0.45), rgba(255, 255, 255, 0.98));
}

.sheet-table th.is-calculation {
  background: linear-gradient(180deg, #dbe9f5, #ccdded);
}

.is-empty-row td {
  padding: 24px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.96rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 30, 42, 0.42);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(620px, calc(100% - 24px));
  margin: 9vh auto 0;
  padding: 24px;
  border-radius: 28px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: #edf3f8;
  color: #546476;
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-copy {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding-right: 28px;
}

.modal-upload-tile {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 248, 252, 0.98));
}

.modal-meta-row {
  align-items: start;
}

.hidden {
  display: none !important;
}

@media (max-width: 1320px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .field-search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1040px) {
  .empty-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 18px, 1680px);
  }

  .topbar,
  .panel-head,
  .sheet-head,
  .upload-meta-row {
    flex-direction: column;
    align-items: stretch;
    display: flex;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

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

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

  .field-search {
    grid-column: 1 / -1;
  }

  .sheet-mock {
    grid-template-columns: 1fr;
  }

  .sheet-mock-head {
    display: none;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 16px;
  }

  .topbar h1 {
    font-size: 1.55rem;
  }

  .empty-card,
  .summary-panel,
  .filters-panel,
  .sheet-shell,
  .modal-card {
    border-radius: 22px;
  }

  .empty-card,
  .summary-panel,
  .filters-panel,
  .modal-card {
    padding: 16px;
  }

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

  .results-meta,
  .meta-line,
  .file-box {
    justify-content: flex-start;
  }

  .table-wrap {
    max-height: none;
    margin: 12px 12px 0;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
