@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap");

:root {
  --bg: #f5f1e8;
  --panel: #fffdf8;
  --ink: #1f1a14;
  --muted: #6f665c;
  --line: #d8cfbf;
  --accent: #0f766e;
  --accent-soft: #d6f2ef;
  --warn: #a16207;
  --warn-bg: #fff1d6;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --plan-bg: #edf4f4;
  --ist-bg: #fff4df;
  --replan-bg: #eef6ec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Roboto", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #f9ecd1 0, transparent 28%),
    linear-gradient(180deg, #efe7d7 0%, var(--bg) 35%, #f7f3ec 100%);
}

a {
  color: var(--accent);
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 45;
  background: rgba(245, 241, 232, 0.96);
  backdrop-filter: blur(12px);
  transition: padding 0.18s ease, box-shadow 0.18s ease;
}

.site-header.is-compact {
  padding: 0.42rem 0.75rem;
  box-shadow: 0 6px 18px rgba(31, 26, 20, 0.07);
}

.site-title-group {
  display: grid;
  gap: 0.25rem;
}

.header-meta {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.88rem;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  border: 1px solid rgba(15, 118, 110, 0.2);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.site-header h1,
.card h2,
.card h3 {
  margin: 0 0 0.5rem;
}

.site-nav {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

.nav-user {
  color: var(--muted);
  font-size: 0.88rem;
}

.logout-form {
  margin: 0;
}

.page-shell {
  padding: 1.5rem;
}

.plan-toolbar-card {
  padding: 0.65rem 0.8rem;
}

.plan-toolbar-card .section-header {
  margin-bottom: 0.45rem;
}

.plan-toolbar-card h2 {
  margin-bottom: 0.2rem;
  font-size: 1.2rem;
}

.plan-toolbar-card .muted {
  font-size: 0.92rem;
}

.plan-toolbar-card .filters {
  gap: 0.65rem;
}

.plan-toolbar-card input,
.plan-toolbar-card select {
  padding: 0.45rem 0.55rem;
}

.plan-toolbar-card .button {
  padding: 0.5rem 0.8rem;
}

.plan-toolbar-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.card {
  background: color-mix(in srgb, var(--panel) 92%, white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 30px rgba(31, 26, 20, 0.05);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at top left, #f9ecd1 0, transparent 28%),
    linear-gradient(180deg, #efe7d7 0%, var(--bg) 35%, #f7f3ec 100%);
}

.auth-card {
  width: min(100%, 25rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 96%, white);
  box-shadow: 0 22px 60px rgba(31, 26, 20, 0.1);
}

.auth-card-login {
  padding: 0;
}

.auth-card-banner {
  padding: 2rem 1.5rem 1.7rem;
  text-align: center;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(249, 236, 209, 0.9) 0, transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 253, 248, 0.94));
  border-bottom: 1px solid var(--line);
}

.auth-card-banner h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.auth-card-banner p {
  margin: 0.6rem 0 0;
  font-size: 1rem;
  color: var(--muted);
}

.auth-card-body {
  padding: 2rem 2rem 2.2rem;
}

.auth-form {
  gap: 1.2rem;
}

.auth-form label {
  display: grid;
  gap: 0.55rem;
  font-weight: 600;
  color: #2f2f35;
}

.auth-submit {
  width: 100%;
  min-height: 3.1rem;
  font-size: 1rem;
  margin-top: 0.35rem;
  border-radius: 12px;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.18);
}

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

.dashboard-grid,
.split-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.split-layout-orders {
  grid-template-columns: minmax(16rem, 1fr) minmax(32rem, 3fr) !important;
}

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

.stat-card h3 {
  margin: 0;
  font-size: 2rem;
}

.dashboard-card {
  text-decoration: none;
  color: inherit;
}

.dashboard-card:hover {
  transform: translateY(-1px);
}

.muted {
  color: var(--muted);
}

.filters {
  display: flex;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
}

.filters label {
  display: grid;
  gap: 0.35rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.92rem 1rem;
  border: 1px solid #d8d7df;
  border-radius: 12px;
  background: #fff;
  color: #2b2632;
  font: inherit;
  box-shadow: inset 0 1px 2px rgba(31, 26, 20, 0.04);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.16);
  border-color: var(--accent);
}

.stack-form {
  display: grid;
  gap: 0.8rem;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

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

.page-actions,
.action-links {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  filter: brightness(0.97);
}

.button-secondary {
  background: transparent;
  color: var(--accent);
  border-color: rgba(15, 118, 110, 0.28);
}

.form-errors {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  background: var(--danger-bg);
  color: var(--danger);
}

@media (max-width: 860px) {
  .auth-card {
    width: 100%;
  }

  .auth-card-body {
    padding: 1.5rem;
  }
}

.inline-upload-form {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
}

.sheet-filter-group {
  display: grid;
  gap: 0.35rem;
}

.sheet-checkboxes {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: white;
}

.upload-label {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

.multi-select {
  position: relative;
  min-width: 12rem;
}

.multi-select summary {
  list-style: none;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
}

.multi-select summary::-webkit-details-marker {
  display: none;
}

.multi-select-panel {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.35rem);
  left: 0;
  width: 100%;
  max-height: 15rem;
  overflow: auto;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(31, 26, 20, 0.12);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
}

.modal-shell[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 26, 20, 0.28);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(80vh, 52rem);
  overflow: auto;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(31, 26, 20, 0.18);
}

.modal-actions-top {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.column-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem 1rem;
  margin-bottom: 1rem;
}

.column-picker-option {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  padding: 0.4rem 0.45rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
}

.checkbox-option {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.2rem;
}

.checkbox-option[hidden] {
  display: none !important;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(31, 26, 20, 0.24);
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-panel {
  width: min(30rem, calc(100vw - 2rem));
  padding: 1rem 1.1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 20px 40px rgba(31, 26, 20, 0.18);
}

.loading-bar {
  margin: 0.75rem 0 0.5rem;
  width: 100%;
  height: 0.7rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e0d1;
}

.loading-bar-fill {
  display: block;
  width: 35%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #5ab5ad);
  animation: loading-slide 1.15s ease-in-out infinite;
}

@keyframes loading-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

input,
select,
button {
  font: inherit;
}

input,
select {
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: white;
}

.button,
button {
  display: inline-block;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  cursor: pointer;
}

.secondary-button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.filter-search {
  min-width: 14rem;
}

.filter-toggle {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding-bottom: 0.45rem;
}

.filter-toggle input {
  width: auto;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--accent-soft);
  position: sticky;
  top: 0;
  z-index: 6;
}

.plan-table td:last-child {
  color: var(--warn);
  font-weight: 700;
}

.sticky-col {
  position: sticky;
  z-index: 3;
}

.sticky-col-1 {
  left: 0;
  min-width: 6.5rem;
}

.sticky-col-2 {
  left: 6.5rem;
  min-width: 6rem;
}

.sticky-col-3 {
  left: 12.5rem;
  min-width: 6rem;
}

.sticky-cell {
  background: color-mix(in srgb, var(--panel) 96%, white);
  box-shadow: 1px 0 0 var(--line);
}

thead .sticky-col {
  background: var(--accent-soft);
}

thead .group-plan,
tbody td.group-plan {
  background: var(--plan-bg);
}

thead .group-ist,
tbody td.group-ist {
  background: var(--ist-bg);
}

thead .group-replan,
tbody td.group-replan {
  background: var(--replan-bg);
}

thead .col-focus,
tbody td.col-focus {
  font-weight: 700;
  box-shadow: inset 2px 0 0 rgba(15, 118, 110, 0.28), inset -2px 0 0 rgba(15, 118, 110, 0.28);
}

thead .col-focus {
  border-top: 2px solid rgba(15, 118, 110, 0.4);
  border-bottom: 2px solid rgba(15, 118, 110, 0.4);
}

thead .col-focus-replan-order,
tbody td.col-focus-replan-order {
  background: color-mix(in srgb, var(--replan-bg) 82%, #d8f0d2);
}

thead .col-focus-ist-order,
tbody td.col-focus-ist-order {
  background: color-mix(in srgb, var(--ist-bg) 79%, #ffe8bd);
}

thead .col-focus-ist-sale,
tbody td.col-focus-ist-sale {
  background: color-mix(in srgb, var(--ist-bg) 80%, #ffe3b0);
}

thead .col-focus-ist-inbound,
tbody td.col-focus-ist-inbound {
  background: color-mix(in srgb, var(--ist-bg) 78%, #fff0c7);
}

.model-card {
  padding-top: 0.8rem;
}

.model-card-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

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

.has-warning-row {
  background: linear-gradient(90deg, var(--warn-bg), transparent 60%);
}

.totals-row {
  background: color-mix(in srgb, var(--accent-soft) 55%, white);
  font-weight: 700;
}

.warning-list {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.warning-pill {
  display: inline-flex;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1.2;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, white);
}

.warning-pill-plan-oos,
.warning-pill-ist-oos,
.warning-pill-replan-oos {
  background: var(--danger-bg);
  color: var(--danger);
}

.warning-pill-changed {
  background: var(--accent-soft);
  color: var(--accent);
}

.warning-pill-keine-deals {
  background: #fff0c2;
  color: #946200;
}

.warning-text {
  color: var(--danger);
  font-weight: 700;
}

.match-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.match-pill-ok {
  color: var(--accent);
  background: rgba(15, 118, 110, 0.12);
}

.match-pill-missing {
  color: var(--danger);
  background: var(--danger-bg);
}

.inline-edit {
  margin: 0;
}

.editable-display {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.28rem 0.5rem;
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, white);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
}

.editable-display:hover {
  border-color: var(--accent);
  background: rgba(214, 242, 239, 0.45);
}

.editable-value {
  white-space: nowrap;
}

.inline-edit-row,
.order-edit-grid {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.editable-editor.inline-edit-row {
  display: none;
}

.js-inline-editable.is-editing .editable-display {
  display: none;
}

.js-inline-editable.is-editing .editable-editor.inline-edit-row {
  display: flex;
}

.models-import-form {
  margin: 0.75rem 0 0.5rem;
}

.small-input {
  min-width: 4.25rem;
  max-width: 12rem;
  padding: 0.25rem 0.45rem;
  height: 2rem;
}

.factor-input {
  min-width: 4.25rem;
  max-width: 4.75rem;
}

.mini-button {
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
}

.mini-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border-radius: 999px;
  font-size: 0.85rem;
}

.cancel-button {
  background: transparent;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 50%, white);
}

.save-state {
  min-width: 4.2rem;
  font-size: 0.75rem;
  color: var(--accent);
}

.danger-button {
  background: var(--danger);
}

.switch {
  position: relative;
  display: inline-flex;
  width: 3rem;
  height: 1.7rem;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d4c8b3;
  transition: background 0.2s ease;
  cursor: pointer;
}

.switch-slider::before {
  content: "";
  position: absolute;
  top: 0.16rem;
  left: 0.16rem;
  width: 1.38rem;
  height: 1.38rem;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(31, 26, 20, 0.2);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
  background: var(--accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(1.28rem);
}

.model-card-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.subcard {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.45);
}

.subcard h4 {
  margin: 0 0 0.5rem;
}

.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-left: 0.2rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: help;
}

.info-tip-box {
  display: none;
  position: absolute;
  bottom: calc(100% + 0.45rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: 14rem;
  max-width: 18rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: #fffdf8;
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(31, 26, 20, 0.12);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.35;
  z-index: 30;
}

.plan-table .info-tip-box {
  display: none !important;
}

.floating-info-tip {
  position: fixed;
  z-index: 100;
  min-width: 14rem;
  max-width: 18rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: #fffdf8;
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(31, 26, 20, 0.18);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.35;
  pointer-events: none;
}

.info-tip:hover .info-tip-box,
.info-tip:focus .info-tip-box {
  display: block;
}

@media (max-width: 720px) {
  .site-header {
    padding: 0.65rem 0.8rem;
    flex-direction: column;
  }

  .page-shell {
    padding: 1rem;
  }

  .dashboard-grid,
  .split-layout,
  .stats-grid,
  .two-cols,
  .column-picker-grid {
    grid-template-columns: 1fr;
  }

  .model-card-head,
  .model-card-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
