* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #e8f0fe 0%, #f0e6ff 50%, #fce4ec 100%);
  background-attachment: fixed;
  color: #1d1d1f;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Nav ──────────────────────────────────────────── */
nav {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  color: #1d1d1f;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  gap: 2px;
  position: sticky;
  top: 0;
  z-index: 100;
}

nav .brand {
  margin-right: 24px;
  display: flex;
  align-items: center;
  text-decoration: none;
}

nav .brand-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
}

nav a {
  color: #6e6e73;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

nav a:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #1d1d1f;
}

nav a.active {
  background: rgba(0, 122, 255, 0.1);
  color: #007aff;
  font-weight: 600;
}

nav .spacer { flex: 1; }

nav .sync-btn {
  background: #007aff;
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s ease;
}

nav .sync-btn:hover {
  background: #0062cc;
  transform: scale(1.02);
}

.last-sync { color: #8e8e93; font-size: 12px; margin-left: 8px; }

/* ── Layout ───────────────────────────────────────── */
.container { max-width: 1300px; margin: 0 auto; padding: 24px; }

h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; color: #1d1d1f; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: #1d1d1f; }

/* ── Glass Cards ─────────────────────────────────── */
.card {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-radius: 16px;
  padding: 20px 24px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.04), 0 0 1px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 0 1px rgba(0, 0, 0, 0.1);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-radius: 16px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.04);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

.stat-card .num { font-size: 30px; font-weight: 700; color: #1d1d1f; }
.stat-card .label { font-size: 11px; color: #8e8e93; margin-top: 4px; font-weight: 500; letter-spacing: 0.02em; }

/* ── Tables ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: rgba(0, 0, 0, 0.03);
  text-align: center;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  color: #6e6e73;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

th.sortable:hover {
  background: rgba(0, 0, 0, 0.06);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  vertical-align: middle;
  text-align: center;
  color: #1d1d1f;
}

tr:hover td { background: rgba(0, 122, 255, 0.03); }

/* ── Badges / pills ───────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-new       { background: rgba(0, 122, 255, 0.12); color: #007aff; }
.badge-processing { background: rgba(255, 149, 0, 0.12); color: #ff9500; }
.badge-ready     { background: rgba(52, 199, 89, 0.12); color: #34c759; }
.badge-fulfilled { background: rgba(142, 142, 147, 0.12); color: #636366; }
.badge-cancelled { background: rgba(255, 59, 48, 0.12); color: #ff3b30; }

.action-ready       { background: rgba(52, 199, 89, 0.12); color: #248a3d; }
.action-pour        { background: rgba(255, 149, 0, 0.12); color: #c93400; }
.action-order       { background: rgba(255, 59, 48, 0.12); color: #d70015; }
.action-pour-order  { background: rgba(255, 204, 0, 0.15); color: #a05a2c; }
.action-none        { background: rgba(142, 142, 147, 0.1); color: #8e8e93; }
.action-pending     { background: rgba(142, 142, 147, 0.08); color: #aeaeb2; }

/* ── Qty coloring ─────────────────────────────────── */
.qty-zero   { color: #ff3b30; font-weight: 700; }
.qty-low    { color: #ff9500; font-weight: 700; }
.qty-ok     { color: #34c759; }

/* ── Buttons ──────────────────────────────────────── */
button, .btn {
  display: inline-block;
  padding: 7px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: #007aff;
  color: #fff;
}
.btn-primary:hover {
  background: #0062cc;
  transform: scale(1.02);
}

.btn-success {
  background: #34c759;
  color: #fff;
}
.btn-success:hover {
  background: #248a3d;
}

.btn-danger {
  background: #ff3b30;
  color: #fff;
}
.btn-danger:hover {
  background: #d70015;
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.05);
  color: #1d1d1f;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.08);
}

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }

button:disabled { opacity: .4; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────── */
input[type=text], input[type=password], input[type=number], select, textarea {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
  outline: none;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: #3a3a3c; }

/* ── Search bar ───────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.search-bar input { max-width: 320px; }

/* ── Filter tabs ──────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding-bottom: 0;
}

.filter-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: #8e8e93;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.filter-tab.active { color: #007aff; border-bottom-color: #007aff; font-weight: 600; }
.filter-tab:hover { color: #1d1d1f; }

/* ── Override select ──────────────────────────────── */
.override-select {
  width: auto !important;
  min-width: 100px;
  text-align: center;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 8px;
  cursor: pointer;
}

/* ── Inline edit ──────────────────────────────────── */
.editable { cursor: pointer; border-radius: 6px; transition: background 0.15s ease; }
.editable:hover { background: rgba(0, 122, 255, 0.06) !important; }

/* ── Toast ────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: #1d1d1f;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  animation: slideIn .25s ease;
  max-width: 340px;
}

.toast.success { border-left: 4px solid #34c759; }
.toast.error   { border-left: 4px solid #ff3b30; }
.toast.info    { border-left: 4px solid #007aff; }

@keyframes slideIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Modal ────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}

.modal {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-radius: 20px;
  padding: 28px;
  min-width: 360px;
  max-width: 560px;
  width: 90%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }

/* ── Misc ─────────────────────────────────────────── */
.text-muted { color: #8e8e93; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.alert {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.alert-warning { background: rgba(255, 149, 0, 0.1); color: #c93400; border: 1px solid rgba(255, 149, 0, 0.2); }
.alert-info    { background: rgba(0, 122, 255, 0.08); color: #0055b3; border: 1px solid rgba(0, 122, 255, 0.15); }

/* ── Attention dot ────────────────────────────────── */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ff3b30;
  margin-right: 4px;
}

.expandable-row td { background: rgba(0, 0, 0, 0.015); }

/* ── Links ───────────────────────────────────────── */
a { color: #007aff; }
a:hover { color: #0055b3; }

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ══════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Nav -> horizontal scroll, compact */
  nav {
    padding: 0 12px;
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    gap: 0;
  }

  nav .brand {
    margin-right: 12px;
  }

  nav .brand-logo {
    height: 32px;
  }

  nav a {
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  nav .sync-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .last-sync {
    display: none;
  }

  /* Layout */
  .container {
    padding: 14px;
  }

  h1 { font-size: 18px; margin-bottom: 14px; }
  h2 { font-size: 15px; }

  /* Cards */
  .card {
    padding: 14px 16px;
    border-radius: 14px;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
  }

  .stat-card {
    padding: 12px 10px;
    border-radius: 12px;
  }

  .stat-card .num { font-size: 22px; }
  .stat-card .label { font-size: 10px; }

  /* Tables */
  table { font-size: 12px; }
  th { padding: 8px 6px; font-size: 10px; }
  td { padding: 8px 6px; }

  .table-wrap {
    margin: 0 -16px;
    padding: 0 4px;
    -webkit-overflow-scrolling: touch;
  }

  /* Search */
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar input { max-width: 100%; }

  /* Filter tabs */
  .filter-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .filter-tab {
    padding: 6px 12px;
    font-size: 12px;
    flex-shrink: 0;
  }

  /* Buttons */
  .btn-sm { padding: 4px 8px; font-size: 11px; }

  /* Flex header */
  .flex {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Modals */
  .modal {
    min-width: unset;
    width: 95%;
    padding: 20px;
    border-radius: 16px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .btn {
    width: 100%;
    text-align: center;
  }

  /* Toast */
  #toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  nav {
    padding: 0 8px;
  }

  nav a {
    padding: 5px 7px;
    font-size: 11px;
  }

  nav .brand-logo {
    height: 28px;
  }

  nav .brand {
    margin-right: 8px;
  }

  .container {
    padding: 10px;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  table { font-size: 11px; }
  th { padding: 6px 4px; font-size: 9px; }
  td { padding: 6px 4px; font-size: 11px; }
}
