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

:root {
  --bg: #eef7f5;
  --bg-strong: #dceff0;
  --panel: #ffffff;
  --panel-soft: #f7fbfb;
  --text: #10343d;
  --muted: #5f7780;
  --border: #c7dde0;
  --primary: #0b6f8a;
  --primary-strong: #095c72;
  --accent: #f59e0b;
  --danger: #bf1f3a;
  --success-bg: #dcfce7;
  --success-text: #14532d;
  --success-border: #86efac;
  --shadow: 0 18px 40px rgba(10, 53, 71, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, #d7f2ff 0%, transparent 40%),
    radial-gradient(circle at 95% 10%, #d7ffe9 0%, transparent 32%),
    linear-gradient(180deg, var(--bg-strong) 0%, var(--bg) 42%, #f6fbfb 100%);
  min-height: 100vh;
}

body.login-page {
  background:
    radial-gradient(circle at 20% 8%, rgba(23, 126, 147, 0.28) 0%, transparent 42%),
    radial-gradient(circle at 88% 80%, rgba(46, 186, 129, 0.18) 0%, transparent 36%),
    linear-gradient(135deg, #0f3342 0%, #14536a 42%, #0f6f8a 100%);
}

.container {
  max-width: 1240px;
  margin: 2.1rem auto;
  padding: 0 1rem 2.5rem;
}

.login-container {
  max-width: 1080px;
  min-height: calc(100vh - 2rem);
  display: grid;
  align-items: center;
}

.header {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem 1.15rem;
  border: 1px solid rgba(10, 70, 88, 0.18);
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(246, 253, 252, 0.95)),
    var(--panel);
  box-shadow: var(--shadow);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.header-tabs {
  margin-top: 0.8rem;
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f5fbfc;
}

.header-tabs a,
.dashboard-tabs a,
.dashboard-subtabs a {
  text-decoration: none;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 0.38rem 0.82rem;
  color: var(--muted);
  font-weight: 600;
  background: transparent;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.header-tabs a:last-child,
.dashboard-tabs a:last-child,
.dashboard-subtabs a:last-child {
  border-right: 0;
}

.header-tabs a:hover,
.dashboard-tabs a:hover,
.dashboard-subtabs a:hover {
  color: var(--primary-strong);
  background: #e9f6f8;
}

.header-tabs a:focus-visible,
.dashboard-tabs a:focus-visible,
.dashboard-subtabs a:focus-visible {
  outline: 2px solid rgba(11, 111, 138, 0.35);
  outline-offset: -2px;
}

.header-tabs a.active,
.dashboard-tabs a.active,
.dashboard-subtabs a.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, #18806e 100%);
  border-right-color: rgba(255, 255, 255, 0.2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(13, 111, 138, 0.25);
}

.brand-copy h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.35rem, 2.2vw, 1.9rem);
  line-height: 1.04;
  letter-spacing: 0.01em;
}

.brand-eyebrow {
  display: block;
  margin-bottom: 0.18rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}

.header-logout {
  margin: 0;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.2rem;
  background: rgba(255, 255, 255, 0.88);
}

.lang-switch a {
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 0.36rem 0.58rem;
  color: var(--muted);
}

.lang-switch a.active {
  background: linear-gradient(135deg, var(--primary) 0%, #18806e 100%);
  color: #ffffff;
}

.panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 26px rgba(14, 70, 94, 0.08);
}

.panel h2,
.panel h3 {
  margin-top: 0;
  margin-bottom: 0.8rem;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.panel p {
  margin-top: 0;
}

.dashboard-tabs {
  display: inline-flex;
  gap: 0;
  margin-bottom: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f5fbfc;
}

.dashboard-subtabs {
  display: inline-flex;
  gap: 0;
  margin: 0 0 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f5fbfc;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.panel-header h2 {
  margin-bottom: 0;
}

.message {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  transition: opacity 220ms ease, transform 220ms ease;
}

.message.is-hidden {
  opacity: 0;
  transform: translateY(-4px);
}

.stack {
  display: grid;
  gap: 0.75rem;
}

.config-form {
  max-width: 760px;
}

.config-form .actions {
  width: 100%;
  justify-content: flex-end;
}

.config-field {
  display: grid;
  gap: 0.35rem;
}

.config-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

.auth-form {
  max-width: 100%;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.login-shell {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.2rem;
  align-items: stretch;
}

.login-hero {
  border: 1px solid rgba(237, 252, 255, 0.28);
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(8, 40, 52, 0.72), rgba(11, 65, 84, 0.75));
  box-shadow: 0 22px 44px rgba(6, 22, 29, 0.34);
  color: #e8f7ff;
  padding: 1.5rem 1.4rem;
}

.login-hero-logo {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  box-shadow: 0 12px 26px rgba(3, 23, 29, 0.3);
}

.login-hero .brand-eyebrow {
  color: #9fdcf9;
  margin-top: 1rem;
}

.login-hero h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.08;
}

.login-hero p {
  margin-top: 0.9rem;
  color: rgba(229, 245, 252, 0.9);
  max-width: 34ch;
}

.login-panel {
  max-width: 100%;
  margin: 0;
  padding: 1.25rem;
}

.login-panel h2 {
  margin-bottom: 1.1rem;
}

.login-lang {
  margin-bottom: 1rem;
}

.inline-form {
  margin-top: 1rem;
}

.document-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.75rem;
}

.document-meta {
  margin-bottom: 0;
}

.document-header-actions {
  display: inline-flex;
  flex-direction: row;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  width: auto;
}

.document-back-form,
.document-delete-form {
  margin: 0;
  display: inline-flex;
  align-items: center;
}

.order-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.order-form-grid label {
  display: grid;
  gap: 0.2rem;
}

.order-form-full {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid transparent;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, #18806e 100%);
  padding: 0.58rem 0.95rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(10, 81, 108, 0.25);
  filter: saturate(1.04);
}

button:active {
  transform: translateY(0);
}

button.danger {
  background: linear-gradient(135deg, var(--danger) 0%, #d73a56 100%);
}

button.secondary {
  border: 1px solid var(--border);
  color: var(--text);
  background: #ffffff;
}

button.secondary:hover {
  color: var(--text);
}

.icon-button {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.45rem 0.55rem;
  background: #ffffff;
}

select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.45rem 0.55rem;
  background: #ffffff;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(11, 111, 138, 0.18);
  border-color: var(--primary);
}

textarea {
  resize: vertical;
}

a {
  color: var(--primary-strong);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--primary);
}

.table-wrap {
  overflow-x: auto;
  border-radius: 2px;
  border: 1px solid rgba(14, 92, 114, 0.18);
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf8fb;
}

th,
td {
  border-bottom: 1px solid #d7e8ea;
  text-align: left;
  padding: 0.5rem;
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: #f8fcfc;
}

.wide {
  min-width: 1320px;
}

.excel-grid {
  width: auto;
  min-width: 1040px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 0.78rem;
}

.excel-grid.wide {
  min-width: 1040px;
}

.excel-grid col.col-pos {
  width: 44px;
}

.excel-grid col.col-article {
  width: 92px;
}

.excel-grid col.col-description {
  width: 210px;
}

.excel-grid col.col-cn {
  width: 76px;
}

.excel-grid col.col-mfr {
  width: 84px;
}

.excel-grid col.col-qty {
  width: 66px;
}

.excel-grid col.col-unit {
  width: 54px;
}

.excel-grid col.col-packages {
  width: 82px;
}

.excel-grid col.col-weight {
  width: 82px;
}

.excel-grid col.col-unit-price,
.excel-grid col.col-net,
.excel-grid col.col-vat-amount,
.excel-grid col.col-gross {
  width: 82px;
}

.excel-grid col.col-vat-rate {
  width: 74px;
}

.order-grid col.col-supplier-id {
  width: 86px;
}

.order-grid col.col-supplier {
  width: 130px;
}

.order-grid col.col-supplier-article {
  width: 140px;
}

.order-grid col.col-group-id {
  width: 88px;
}

.order-grid col.col-group {
  width: 180px;
}

.order-grid col.col-currency {
  width: 78px;
}

.excel-grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #e7edf2;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-bottom: 1px solid #c7d2d9;
  border-right: 1px solid #d7e1e7;
  padding: 0.3rem 0.36rem;
  white-space: nowrap;
}

.excel-grid thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #dfe8ef;
}

.excel-grid td {
  border-right: 1px solid #dde6eb;
  border-bottom: 1px solid #dde6eb;
  padding: 0;
  background: #ffffff;
}

.excel-grid tr td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f1f5f8;
}

.excel-grid tbody tr:hover td {
  background: #f7fbff;
}

.excel-grid tbody tr:hover td:first-child {
  background: #eaf1f6;
}

.excel-grid .row-index {
  width: 3.6rem;
  padding: 0.3rem 0.4rem;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #244b57;
}

.excel-grid input,
.excel-grid textarea {
  border: 0;
  border-radius: 0;
  background: transparent;
  width: 100%;
  padding: 0.3rem 0.36rem;
}

.excel-grid textarea {
  min-height: 2rem;
}

.excel-grid td:focus-within {
  background: #eaf6ff;
}

.excel-grid td:focus-within .row-index {
  background: #eaf6ff;
}

.excel-grid input:focus,
.excel-grid textarea:focus {
  outline: 2px solid rgba(11, 111, 138, 0.55);
  outline-offset: -2px;
  border-color: transparent;
  background: #eaf6ff;
}

.excel-grid .numeric-cell input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.excel-grid .price-cell .price-meta {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #627f89;
  font-size: 0.66rem;
  line-height: 1.15;
  padding: 0 0.36rem 0.2rem;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
  width: 100%;
}

.row-open-form,
.row-delete-form {
  margin: 0;
}

.pagination {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5.4rem;
  padding: 0.38rem 0.66rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  background: #ffffff;
  color: var(--text);
  font-weight: 600;
}

.pagination-link:hover {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.pagination-link.disabled {
  opacity: 0.48;
  pointer-events: none;
}

.pagination-state {
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  padding: 0 1rem 1rem;
}

@media (max-width: 900px) {
  .container {
    margin-top: 1rem;
    padding-bottom: 1.2rem;
  }

  .header {
    padding: 0.9rem;
  }

  .header-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-tools {
    width: 100%;
    justify-content: space-between;
  }

  .login-container {
    min-height: auto;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .dashboard-tabs {
    display: flex;
    flex-wrap: wrap;
  }

  .dashboard-subtabs {
    display: flex;
    flex-wrap: wrap;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .document-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .order-form-grid {
    grid-template-columns: 1fr;
  }

  .document-header-actions {
    display: inline-flex;
    flex-direction: row;
    justify-content: flex-start;
    flex-wrap: nowrap;
    width: auto;
  }

  .row-actions {
    flex-wrap: wrap;
  }
}
