:root {
  --ink: #17212b;
  --muted: #68727f;
  --line: #d8dee6;
  --panel: #ffffff;
  --soft: #f3f6f8;
  --accent: #0f6b63;
  --accent-dark: #094b45;
  --gold: #bb8a2e;
  --danger: #a33a30;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(15, 107, 99, 0.12), rgba(187, 138, 46, 0.12)),
    #eef2f4;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 430px);
  padding: 34px;
  border: 1px solid rgba(23, 33, 43, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 70px rgba(23, 33, 43, 0.16);
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.login-logo {
  max-width: 250px;
  margin: -4px 0 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1,
.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1;
}

.intro {
  margin: 18px 0 26px;
  color: var(--muted);
  line-height: 1.55;
}

.login-form,
.entry-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #384452;
  font-size: 0.9rem;
  font-weight: 750;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 150px;
  padding: 12px;
  line-height: 1.5;
}

.upload-tile {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 74px;
  padding: 14px 16px;
  border: 1px dashed #b9c9d5;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.upload-tile:hover {
  border-color: var(--accent);
  background: #f7fbfa;
}

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

.upload-title {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 900;
}

.upload-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 99, 0.15);
}

.custom-select {
  position: relative;
  display: block;
}

.custom-select-button {
  width: 100%;
  min-height: 44px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  text-align: left;
}

.custom-select-button::after {
  content: "⌄";
  position: absolute;
  right: 14px;
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 900;
}

.custom-select-button:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 99, 0.15);
  outline: none;
}

.custom-select-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  overflow: hidden;
  border: 1px solid #cbd8df;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(23, 33, 43, 0.16);
}

.custom-select-menu button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid #edf1f4;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
}

.custom-select-menu button:last-child {
  border-bottom: 0;
}

.custom-select-menu button:hover {
  background: #f0faf8;
  color: var(--accent);
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-form button,
.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.login-form button:hover,
.primary-button:hover {
  background: var(--accent-dark);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding: 10px 0 28px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
}

.top-logo {
  width: 172px;
  flex: 0 0 172px;
}

.header-title {
  text-align: right;
}

.header-title h1 {
  font-size: clamp(1.55rem, 2.8vw, 2.25rem);
  line-height: 1.05;
}

.top-actions {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 12px;
  margin-left: auto;
}

.search-wrap {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #384452;
  font-size: 0.9rem;
  font-weight: 750;
}

.sort-controls {
  display: grid;
  gap: 7px;
  color: #384452;
  font-size: 0.9rem;
  font-weight: 750;
}

.sort-controls > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sort-button {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
}

.sort-button.is-active,
.sort-button:hover {
  border-color: #c9ddd9;
  background: #f0faf8;
  color: var(--accent);
}

.top-actions .ghost-button {
  order: 1;
}

.ghost-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-weight: 800;
}

.overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.supplier-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 28px rgba(23, 33, 43, 0.06);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.module-card {
  display: grid;
  gap: 10px;
  min-height: 180px;
  padding: 22px;
  border: 1px solid rgba(23, 33, 43, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 16px 50px rgba(23, 33, 43, 0.08);
}

.module-card:hover {
  border-color: rgba(15, 107, 99, 0.35);
  box-shadow: 0 18px 54px rgba(15, 107, 99, 0.12);
}

.module-card strong {
  font-size: 1.45rem;
  line-height: 1.15;
}

.module-card span:last-child {
  color: var(--muted);
  line-height: 1.45;
}

.module-kicker {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.document-categories {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.document-category-card {
  min-height: 64px;
  padding: 16px 18px;
  border: 1px solid #dfe6ec;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.document-category-card:hover,
.document-category-card.is-active {
  border-color: rgba(15, 107, 99, 0.42);
  background: #f0faf8;
}

.document-category-all {
  border-color: rgba(255, 59, 61, 0.24);
  background: #fff7f7;
}

.document-category-all:hover,
.document-category-all.is-active {
  border-color: rgba(255, 59, 61, 0.42);
  background: #ffecec;
}

.document-category-card h3 {
  margin: 0;
  font-size: 1rem;
}

.summary,
.tile {
  border: 1px solid rgba(23, 33, 43, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 50px rgba(23, 33, 43, 0.08);
}

.summary {
  display: grid;
  gap: 4px;
  padding: 18px;
  color: var(--muted);
  font-weight: 700;
}

.summary-number {
  color: var(--ink);
  font-size: 1.65rem;
  font-weight: 900;
}

.tile {
  overflow: hidden;
}

.tile-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.tile-header h2 {
  font-size: 1.75rem;
}

.table-wrap {
  overflow-x: visible;
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

.supplier-table th:nth-child(1),
.supplier-table td:nth-child(1) {
  width: 11%;
}

.supplier-table th:nth-child(2),
.supplier-table td:nth-child(2) {
  width: 8%;
}

.supplier-table th:nth-child(3),
.supplier-table td:nth-child(3) {
  width: 10%;
}

.supplier-table th:nth-child(4),
.supplier-table td:nth-child(4) {
  width: 17%;
}

.supplier-table th:nth-child(5),
.supplier-table td:nth-child(5),
.supplier-table th:nth-child(6),
.supplier-table td:nth-child(6) {
  width: 10%;
}

.supplier-table th:nth-child(7),
.supplier-table td:nth-child(7) {
  width: 12%;
}

.supplier-table th:nth-child(8),
.supplier-table td:nth-child(8) {
  width: 5%;
}

.supplier-table th:nth-child(9),
.supplier-table td:nth-child(9) {
  width: 9%;
}

.supplier-table th:nth-child(10),
.supplier-table td:nth-child(10) {
  width: 8%;
}

.recipe-table th:nth-child(1),
.recipe-table td:nth-child(1) {
  width: 18%;
}

.recipe-table th:nth-child(2),
.recipe-table td:nth-child(2) {
  width: 13%;
}

.recipe-table th:nth-child(3),
.recipe-table td:nth-child(3) {
  width: 12%;
}

.recipe-table th:nth-child(4),
.recipe-table td:nth-child(4) {
  width: 24%;
}

.recipe-table th:nth-child(5),
.recipe-table td:nth-child(5) {
  width: 22%;
}

.recipe-table th:nth-child(6),
.recipe-table td:nth-child(6) {
  width: 11%;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid #e8edf1;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--soft);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: #26313d;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.muted-text,
.file-name {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.file-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #c9ddd9;
  border-radius: 7px;
  background: #f0faf8;
  color: var(--accent);
  font-weight: 900;
  text-decoration: none;
}

.file-link + .file-name {
  margin-top: 6px;
}

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

.row-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

td[data-label="Aktion"] .row-actions {
  align-items: flex-start;
}

.entry-form .form-actions {
  grid-column: 1 / -1;
}

.entry-form .form-wide {
  grid-column: 1 / -1;
}

.edit-button,
.edit-document-button,
.edit-recipe-button,
.move-document-button,
.delete-button {
  min-width: 34px;
  min-height: 34px;
  border-radius: 7px;
  font-weight: 900;
  white-space: nowrap;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 1rem;
}

.edit-button,
.edit-document-button,
.edit-recipe-button,
.move-document-button {
  padding: 0 12px;
  border: 1px solid #c9ddd9;
  background: #f0faf8;
  color: var(--accent);
}

.edit-recipe-button {
  min-width: 92px;
  justify-content: center;
}

.delete-button {
  border: 1px solid #ead1cc;
  background: #fff6f4;
  color: var(--danger);
}

.entry-form {
  grid-template-columns: 1.15fr 0.8fr 0.8fr 1.5fr 1.2fr 0.6fr;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.recipe-form {
  grid-template-columns: 1.3fr 0.9fr 0.9fr;
}

.notes-block {
  padding: 22px 24px 24px;
}

@media (max-width: 820px) {
  .topbar,
  .tile-header {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
    width: 100%;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .top-logo {
    width: 210px;
    flex-basis: auto;
  }

  .header-title {
    text-align: left;
  }

  .search-wrap {
    width: 100%;
  }

  .supplier-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .sort-controls > div {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overview,
  .entry-form,
  .dashboard-grid,
  .document-categories {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  body {
    background: #eef2f4;
  }

  .app-shell {
    width: min(100% - 14px, 560px);
    padding-top: 18px;
  }

  .login-screen {
    padding: 14px;
  }

  .login-panel {
    padding: 24px 18px;
  }

  .login-logo {
    max-width: 220px;
    margin-bottom: 14px;
  }

  .topbar {
    padding-bottom: 16px;
  }

  .top-logo {
    width: 190px;
  }

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

  .overview {
    gap: 10px;
    margin-bottom: 12px;
  }

  .summary {
    padding: 14px 16px;
  }

  .tile-header,
  .entry-form,
  .notes-block {
    padding: 18px 16px;
  }

  .tile-header h2 {
    font-size: 1.35rem;
  }

  .table-wrap {
    overflow: visible;
    padding: 0 8px 12px;
    background: #fbfcfd;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    width: 100%;
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
  }

  .supplier-table th,
  .supplier-table td,
  .recipe-table th,
  .recipe-table td {
    width: 100% !important;
  }

  thead {
    display: none;
  }

  tr {
    width: 100%;
    max-width: 100%;
    margin: 12px 0 0;
    border: 1px solid #dfe6ec;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(23, 33, 43, 0.06);
    overflow: hidden;
  }

  td {
    display: grid;
    grid-template-columns: minmax(82px, 31%) minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border-bottom: 1px solid #edf1f4;
    font-size: 0.92rem;
    overflow-wrap: anywhere;
  }

  .supplier-table td[data-label="Sortiment"],
  .supplier-table td[data-label="Freitext"],
  .recipe-table td[data-label="Zutatenliste"],
  .recipe-table td[data-label="Zubereitung"] {
    grid-template-columns: 1fr;
    gap: 6px;
    line-height: 1.45;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  td:first-child {
    grid-template-columns: 1fr;
    gap: 4px;
    color: var(--ink);
    font-size: 1rem;
    font-weight: 850;
    background: #f3f6f8;
  }

  td:first-child::before {
    font-size: 0.72rem;
  }

  td:last-child {
    border-bottom: 0;
  }

  td[data-label="Aktion"] .row-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    width: 100%;
  }

  .empty-row {
    display: block;
    padding: 16px;
  }

  .empty-row::before {
    content: "";
  }

  .delete-button {
    width: 44px;
    min-width: 44px;
    justify-self: start;
    font-size: 1.1rem;
  }

  .edit-button,
  .edit-document-button,
  .edit-recipe-button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0 13px;
  }

  input,
  textarea,
  .login-form button,
  .primary-button,
  .ghost-button {
    width: 100%;
    max-width: 100%;
    min-height: 48px;
  }
}
