:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172126;
  --muted: #5d6b73;
  --line: #dce4e8;
  --accent: #0f766e;
  --accent-2: #b45309;
  --blue: #1d7fe5;
  --danger: #b91c1c;
  --ok: #166534;
  --soft: #e9f5f3;
  --shadow: 0 10px 28px rgba(23, 33, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button.secondary {
  background: #eef3f5;
  color: var(--ink);
}

button.warning {
  background: var(--accent-2);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  align-items: center;
  background: #102024;
  color: white;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand strong {
  font-size: 17px;
}

.brand span,
.user-meta {
  color: #cbd7db;
  font-size: 13px;
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

.layout {
  display: grid;
  flex: 1;
  gap: 22px;
  grid-template-columns: 240px minmax(0, 1fr);
  padding: 22px;
}

.sidebar,
.panel,
.auth-card,
.product-card,
.order-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  align-self: start;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.nav-button {
  background: transparent;
  color: var(--ink);
  justify-content: flex-start;
  text-align: left;
}

.nav-button.active {
  background: var(--soft);
  color: var(--accent);
}

.content {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 18px;
}

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

.panel-header h1,
.panel-header h2 {
  margin: 0;
}

.panel-header p,
.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.products {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.product-card,
.order-card {
  padding: 15px;
}

.product-card {
  display: grid;
  gap: 12px;
}

.product-card h3,
.order-card h3 {
  margin: 0;
}

.settings-details {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.settings-details p {
  margin: 0;
}

.sub-panel {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.sub-panel h2 {
  margin-top: 0;
}

.price-line {
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
}

.qty-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 42px 1fr 42px;
}

.qty-row button {
  padding: 0;
}

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

.cart-footer {
  justify-content: space-between;
}

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

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

tr.invite-sent-row {
  background: #f3f5f6;
  color: #6b747b;
}

tr.invite-sent-row code {
  color: #5f6b72;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
}

.badge.new {
  background: #e0f2fe;
  color: #075985;
}

.badge.accepted,
.badge.sent,
.badge.awaiting_pickup,
.badge.in_transport {
  background: #fef3c7;
  color: #92400e;
}

.badge.completed,
.badge.delivered {
  background: #dcfce7;
  color: var(--ok);
}

.badge.cancelled,
.badge.error,
.badge.missing_token {
  background: #fee2e2;
  color: var(--danger);
}

.badge.not_sent {
  background: #eef3f5;
  color: var(--muted);
}

.auth-page {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  margin: 0 auto;
  max-width: 520px;
  padding: 26px;
  width: 100%;
}

.auth-card h1 {
  margin: 0 0 8px;
}

.auth-card form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.notice {
  border-radius: 8px;
  margin: 0 0 14px;
  padding: 12px;
}

.notice.error {
  background: #fee2e2;
  color: var(--danger);
}

.notice.ok {
  background: #dcfce7;
  color: var(--ok);
}

.notice.info {
  background: #e0f2fe;
  color: #075985;
}

.invite-links {
  display: grid;
  gap: 8px;
}

.invite-links code {
  background: #f1f5f9;
  border-radius: 6px;
  display: block;
  overflow-x: auto;
  padding: 9px;
  white-space: nowrap;
}

.order-list {
  display: grid;
  gap: 12px;
}

.order-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.items-list {
  margin: 10px 0 0;
  padding-left: 18px;
}

.totals-box {
  background: #f6f8fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
  overflow: hidden;
}

.totals-box div {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.totals-box div + div {
  border-left: 1px solid var(--line);
}

.totals-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.totals-box strong {
  font-size: 17px;
}

.transport-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0 0;
}

.status-progress {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.status-progress-top,
.progress-steps {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.status-progress-top span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.progress-track {
  background: #e7edf2;
  border: 1px solid #d5e0e8;
  border-radius: 999px;
  height: 24px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  background-color: var(--blue);
  border-radius: inherit;
  height: 100%;
  min-width: 0;
  transition: width 220ms ease;
}

.sombrero-pattern {
  background-color: var(--blue);
  background-image: url("data:image/svg+xml,%3Csvg width='48' height='24' viewBox='0 0 48 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(255,255,255,0.55)' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 15c4 3 10 3 14 0'/%3E%3Cpath d='M13 15c1-5 5-5 6 0'/%3E%3Cpath d='M29 15c4 3 10 3 14 0'/%3E%3Cpath d='M33 15c1-5 5-5 6 0'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 48px 24px;
}

.progress-steps {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  gap: 8px;
}

.progress-steps span.active {
  color: var(--blue);
}

.footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 16px 24px;
  text-align: center;
}

.mail-preview {
  background: #f6f8fa;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .topbar,
  .panel-header,
  .cart-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .totals-box {
    grid-template-columns: 1fr;
  }

  .totals-box div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
