:root {
  --ink: #151515;
  --muted: #6d655f;
  --line: #ded7cf;
  --paper: #f6f1ea;
  --panel: #fffdf9;
  --orange: #ef5d3d;
  --red: #c92b2b;
  --green: #087f55;
  --yellow: #efb33d;
  --blue: #2457c5;
  --dark: #070707;
  --shadow: 0 18px 45px rgba(18, 18, 18, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

input[type="file"] {
  padding: 9px 12px;
}

textarea {
  min-height: 88px;
  padding-top: 10px;
  resize: vertical;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--orange);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0.76)),
    url("../../images/restaurant.HEIC") center / cover;
}

.login-panel {
  width: min(440px, 100%);
  padding: 32px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 160px;
  margin-bottom: 26px;
}

.login-panel h1,
.admin-topbar h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-form label,
.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.image-upload-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.image-upload-field.compact {
  grid-row: span 3;
}

.ingredient-image-preview {
  width: 100%;
  height: 132px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ingredient-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ingredients-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(0, 1.22fr);
  gap: 16px;
  align-items: start;
}

.product-list {
  display: grid;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
  padding-right: 2px;
}

.product-list-row {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.product-list-row.active {
  border-color: rgba(239, 93, 61, 0.7);
  box-shadow: 0 0 0 2px rgba(239, 93, 61, 0.14);
}

.sortable-list .product-list-row {
  grid-template-columns: 24px 46px minmax(0, 1fr);
  cursor: grab;
}

.sortable-list .product-list-row:active {
  cursor: grabbing;
}

.product-list-row.dragging {
  opacity: 0.48;
}

.product-list-row.drag-over {
  border-color: rgba(239, 93, 61, 0.75);
  background: #fff7f3;
}

.drag-handle {
  color: var(--muted);
  font-size: 16px;
  font-weight: 950;
  letter-spacing: 0;
}

.product-list-row strong,
.product-list-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-list-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.form-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.form-details summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--ink);
  font-weight: 950;
  cursor: pointer;
}

.form-details .form-grid {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.supplier-price-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);
  gap: 16px;
  align-items: start;
}

.embedded-table {
  min-width: 0;
  overflow-x: auto;
}

.embedded-table h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.ingredient-image-preview strong,
.ingredient-thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--orange);
  background: #ffe0d4;
  font-weight: 950;
}

.ingredient-image-preview strong {
  width: 100%;
  height: 100%;
  font-size: 44px;
}

.ingredient-thumb,
.ingredient-thumb-placeholder {
  width: 46px;
  height: 46px;
  border-radius: 8px;
}

.ingredient-thumb {
  object-fit: cover;
}

.login-form button,
.topbar-actions button,
.primary-action {
  color: #fff;
  background: var(--orange);
}

.secondary-action {
  color: var(--ink);
  background: #ffe0d4;
}

.danger-action {
  color: #fff;
  background: var(--red);
}

.text-button {
  min-height: 0;
  padding: 0;
  color: var(--orange);
  background: transparent;
  border-radius: 0;
  font-weight: 950;
  text-align: left;
  text-decoration: underline;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.login-error[data-tone="info"] {
  color: var(--muted);
}

.login-error[data-tone="error"] {
  color: var(--red);
}

.login-note {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.admin-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  color: #fff;
  background: var(--dark);
  overflow-y: auto;
}

.admin-brand img {
  width: 170px;
}

.admin-user {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
}

.admin-user span {
  color: #cac3bd;
  font-size: 13px;
}

.admin-nav {
  display: grid;
  gap: 5px;
}

.admin-nav button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  color: #e9e2dc;
  background: transparent;
  text-align: left;
}

.admin-nav button.active {
  color: #111;
  background: #ffe0d4;
}

.admin-nav small {
  color: inherit;
  opacity: 0.72;
}

.logout-btn {
  margin-top: auto;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.admin-main {
  min-width: 0;
  padding: 22px;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection,
.status-chip,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
}

.connection.online,
.status-good,
.status-paid,
.status-active {
  color: #fff;
  background: var(--green);
}

.connection.syncing,
.connection.warning,
.status-watch,
.status-pending {
  color: #111;
  background: var(--yellow);
}

.connection.offline,
.status-risk,
.status-unpaid,
.status-blocked {
  color: #fff;
  background: var(--red);
}

.alert-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.alert {
  padding: 12px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(18, 18, 18, 0.06);
}

.alert span {
  color: var(--orange);
  font-size: 12px;
  font-weight: 950;
}

.alert p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.route-view {
  display: grid;
  gap: 16px;
}

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

.metric-card,
.panel,
.ladder-card {
  background: var(--panel);
  border: 1px solid rgba(222, 215, 207, 0.9);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(18, 18, 18, 0.06);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 16px;
}

.metric-card span,
.panel-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  font-weight: 800;
}

.metric-card.risk {
  border-color: rgba(201, 43, 43, 0.32);
}

.metric-card.good {
  border-color: rgba(8, 127, 85, 0.28);
}

.module-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
}

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

.panel {
  min-width: 0;
  padding: 16px;
  overflow: hidden;
}

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

.panel-head h2,
.panel-head p {
  margin: 0;
}

.panel-head p {
  margin-top: 5px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.panel p {
  color: var(--muted);
  line-height: 1.55;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.list-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.ladder-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
}

.ladder-card.active {
  border-color: rgba(239, 93, 61, 0.55);
  background: #fff2ec;
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadfd6;
}

.bar span {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--orange);
}

.form-grid,
.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

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

.chart-bars {
  display: grid;
  gap: 10px;
}

.chart-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 90px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
}

.chart-row .bar {
  height: 14px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  transform: translateY(18px);
  opacity: 0;
  padding: 12px 14px;
  color: #fff;
  background: #111;
  border-radius: 9px;
  box-shadow: var(--shadow);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1100px) {
  .admin-app {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .metric-grid,
  .three-grid,
  .alert-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .ingredients-layout,
  .supplier-price-grid {
    grid-template-columns: 1fr;
  }

  .product-list {
    max-height: 360px;
  }
}

@media (max-width: 760px) {
  .admin-app {
    display: block;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .three-grid,
  .alert-row,
  .form-grid,
  .filter-bar {
    grid-template-columns: 1fr;
  }
}
