:root {
  --blue: #1a4f8b;
  --blue-dark: #143a68;
  --blue-light: #2a6db8;
  --yellow: #ffd400;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e1e4ea;
  --text: #1a1a1a;
  --muted: #6b7280;
  --error: #b3261e;
  --error-bg: #fdecea;
  --total-bg: #eef2f7;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--blue-light) 100%);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
}

.logo {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--blue);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.brand-title { font-size: 18px; font-weight: 700; }
.brand-sub   { font-size: 12px; opacity: .85; margin-top: 2px; }

/* ---------- кнопка выйти ---------- */

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.logout-form { margin: 0; }

.btn-logout {
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 6px;
  padding: 7px 14px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn-logout:hover {
  background: rgba(255, 255, 255, .25);
  border-color: #fff;
}
.btn-logout:active { transform: scale(.97); }

/* ---------- hero ---------- */

.hero {
  background: linear-gradient(180deg, var(--blue-light) 0%, var(--blue) 100%);
  color: #fff;
  padding: 60px 24px;
  text-align: center;
}
.hero-inner { max-width: 720px; margin: 0 auto; }
.hero h1 { margin: 0 0 12px; font-size: 28px; }
.hero p  { margin: 0; font-size: 15px; opacity: .9; }

/* ---------- контейнер и карточки ---------- */

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}

.card h2 {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 600;
}

.login-wrap { max-width: 460px; margin: 40px auto; }

/* ---------- поля ---------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--muted);
}
.field input,
.text-form textarea,
.qty-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field input:focus,
.text-form textarea:focus,
.qty-input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: var(--blue);
}

.text-form textarea {
  min-height: 84px;
  resize: vertical;
  margin-bottom: 10px;
}

/* ---------- кнопки ---------- */

.btn-primary,
.btn-accent,
.btn-danger,
.btn-icon {
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  transition: background .15s, filter .15s, transform .05s;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }

.btn-accent { background: var(--yellow); color: #222; }
.btn-accent:hover { filter: brightness(.94); }

.btn-danger { background: #d32f2f; color: #fff; }
.btn-danger:hover { background: #b71c1c; }

.btn-block { display: block; width: 100%; }

.btn-icon {
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 18px;
  border-radius: 6px;
}
.btn-icon:hover { background: #f0f0f0; color: var(--error); }

button:active { transform: scale(.98); }

/* ---------- upload ---------- */

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 28px 16px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.upload-area.dragging {
  border-color: var(--blue);
  background: #f0f6ff;
}

.muted { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.divider {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 18px 0;
  position: relative;
}
.divider::before,
.divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}
.divider::before { left: 0; }
.divider::after  { right: 0; }

/* ---------- список позиций ---------- */

.item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
}

.item-name {
  flex: 1;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}

.item-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.item-unit-price {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.item-op {
  color: var(--muted);
  font-size: 13px;
}

.qty-input {
  width: 64px;
  padding: 6px 8px;
  text-align: center;
  font-size: 15px;
}

.item-sum {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  min-width: 110px;
  text-align: right;
  white-space: nowrap;
}

/* ---------- итог ---------- */

.order-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-top: 12px;
  background: var(--total-bg);
  border-radius: 8px;
  font-size: 16px;
  color: var(--muted);
}

.order-total strong {
  font-size: 20px;
  color: var(--blue-dark);
  font-weight: 700;
  white-space: nowrap;
}

.order-top,
.order-bottom { margin: 10px 0; }

.order-clear { margin-top: 10px; }

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 24px 8px;
  font-size: 14px;
}

/* ---------- статус заказа ---------- */

.status-card {
  text-align: center;
  padding: 44px 20px;
}

.status-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 34px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.status-icon-pending {
  background: #fff8e1;
  color: #b28704;
}

.status-number { font-size: 18px; margin: 16px 0 24px; }

/* ---------- ошибки ---------- */

.error-msg {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #f5c6c3;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 14px;
}

/* ---------- spinner ---------- */

.spinner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.82);
  color: #fff;
  padding: 14px 22px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }

/* ---------- модальное окно ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
}

.modal h3 {
  margin: 0 0 20px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  color: var(--text);
}

.modal .btn-primary,
.modal .btn-danger {
  margin-top: 10px;
}

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .logo { width: 40px; height: 40px; font-size: 13px; }
  .brand-title { font-size: 15px; }
  .brand-sub { display: none; }

  .btn-logout { padding: 6px 12px; font-size: 12px; }

  .hero { padding: 40px 18px; }
  .hero h1 { font-size: 22px; }
  .hero p { font-size: 14px; }

  .container { padding: 14px 10px 90px; }
  .card { padding: 16px; border-radius: 8px; }

  .item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .item-controls {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
  }
  .item-unit-price { font-size: 12px; }
  .item-sum {
    min-width: 0;
    flex: 1;
    text-align: right;
    font-size: 15px;
  }
  .qty-input { width: 56px; padding: 6px; }

  .order-total { padding: 12px 14px; font-size: 15px; }
  .order-total strong { font-size: 18px; }

  .modal { padding: 18px; }
  .modal h3 { font-size: 15px; margin-bottom: 16px; }
}