*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  background: #f5f6fa;
  color: #222;
}

.hidden { display: none !important; }

/* ── Login ────────────────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.login-box h1 { font-size: 28px; margin-bottom: 8px; }
.login-box p  { color: #666; margin-bottom: 32px; }

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: #1a1a2e;
  color: #fff;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
}

.brand { font-size: 18px; font-weight: 700; white-space: nowrap; }

nav { display: flex; gap: 4px; flex: 1; }

.nav-btn {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
}

.nav-btn:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,.15); color: #fff; }

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  font-size: 14px;
  color: #ccc;
}

/* ── Main layout ──────────────────────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.view-header h2 { font-size: 22px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s;
}

.btn:hover    { opacity: .88; }
.btn-primary  { background: #4f46e5; color: #fff; }
.btn-secondary{ background: #e5e7eb; color: #374151; }
.btn-danger   { background: #ef4444; color: #fff; }
.btn-large    { padding: 12px 28px; font-size: 16px; }
.btn-small    { padding: 5px 12px; font-size: 13px; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
  background: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.filter-bar input,
.filter-bar select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }

.filter-bar input[type="text"] { width: 220px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.data-table th {
  background: #f8f9fb;
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }

/* ── Sites & Warehouses ───────────────────────────────────────────────────── */
.warehouse-section {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.warehouse-section h3 { font-size: 16px; margin-bottom: 12px; color: #374151; }

.site-block {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.site-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.site-block-header h3 { font-size: 16px; color: #374151; }

.warehouse-list { display: flex; flex-wrap: wrap; gap: 10px; }

.warehouse-chip {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.warehouse-chip .chip-name { font-weight: 500; }
.warehouse-chip .chip-default { font-size: 11px; color: #9ca3af; }

/* ── PZ items ─────────────────────────────────────────────────────────────── */
.pz-item-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.pz-item-row select { flex: 2; min-width: 160px; }
.pz-item-row input  { flex: 1; min-width: 80px; }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px;
  width: 460px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.modal-wide { width: 680px; }

.modal-box h3 { font-size: 18px; margin-bottom: 20px; }
.modal-box h4 { font-size: 15px; margin: 16px 0 10px; }

.modal-box label {
  display: inline-block;  /* iOS Safari: never flex on label */
  width: 100%;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 14px;
}

.modal-box input[type="text"],
.modal-box input[type="number"],
.modal-box input[type="date"],
.modal-box select,
.modal-box textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.form-row { display: flex; gap: 16px; }
.form-row label { flex: 1; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.error { color: #ef4444; font-size: 13px; margin-top: 8px; }

.badge-active   { color: #16a34a; }
.badge-inactive { color: #9ca3af; }
