/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:      #C23B10;
  --accent-light:#E8A87C;
  --accent-bg:   #FEF0E6;
  --accent-dark: #9e2e0c;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-400:    #9ca3af;
  --gray-600:    #4b5563;
  --gray-800:    #1f2937;
  --white:       #ffffff;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  --radius:      8px;
  --radius-sm:   5px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login Page ────────────────────────────────────────────────────────────── */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fdf3ec 0%, #fef9f7 50%, #fff7f5 100%);
  padding: 24px;
}

.login-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo img {
  max-width: 180px;
  max-height: 80px;
  object-fit: contain;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-800);
  text-align: center;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 12.5px;
  color: var(--gray-400);
  text-align: center;
  margin-bottom: 28px;
}

.login-form .field-group { margin-bottom: 16px; }

/* ── Site Header ───────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-logo {
  max-height: 42px;
  max-width: 160px;
  object-fit: contain;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray-600);
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--accent); background: var(--accent-bg); text-decoration: none; }
.nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}
.nav-logout {
  font-size: 13px;
  color: var(--gray-400);
  margin-left: 8px;
}
.nav-logout:hover { color: var(--accent); }

/* ── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1140px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.page-header {
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 4px;
}
.page-sub {
  font-size: 13.5px;
  color: var(--gray-400);
}

/* ── Form Sections ─────────────────────────────────────────────────────────── */
.form-section {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px 28px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-600);
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-fixed {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gray-400);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 1px 6px;
  text-transform: uppercase;
}

.shipper-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--gray-600);
  line-height: 1.8;
}
.shipper-box p { margin: 0; }

/* ── Form Rows & Fields ────────────────────────────────────────────────────── */
.form-row {
  margin-bottom: 16px;
}
.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-group-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.field-group-inline label { white-space: nowrap; font-size: 13.5px; font-weight: 500; color: var(--gray-600); }
.field-group-inline select { flex: 0 0 280px; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194, 59, 16, 0.12);
}
input[readonly] {
  background: var(--gray-50);
  color: var(--gray-400);
  cursor: not-allowed;
}
select { cursor: pointer; }

.instructions-textarea {
  width: 100%;
  font-size: 13px;
  line-height: 1.75;
  resize: vertical;
  min-height: 100px;
}

.hint {
  font-size: 11.5px;
  color: var(--gray-400);
  font-weight: 400;
}

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

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.items-table th {
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  text-align: left;
}
.items-table td {
  border: 1px solid var(--gray-200);
  padding: 4px 6px;
  vertical-align: middle;
}
.items-table td input {
  padding: 5px 8px;
  font-size: 13px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.items-table td input:focus {
  background: var(--white);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(194, 59, 16, 0.10);
}
.items-table tr.item-row:hover td { background: var(--gray-50); }

.totals-row td {
  background: var(--gray-100) !important;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 10px;
}
.total-cell { font-variant-numeric: tabular-nums; }

/* ── Data Table (history) ──────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 12px;
  border-bottom: 2px solid var(--gray-200);
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
  vertical-align: middle;
}
.data-table tbody tr:hover td { background: var(--accent-bg); }
.data-table .bol-num {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}
.data-table .ts { color: var(--gray-400); font-size: 12px; }
.row-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: uppercase;
}
.badge-collect { background: #d1fae5; color: #065f46; }
.badge-prepaid  { background: #dbeafe; color: #1e40af; }

.abbrev-tag {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-light);
  border-radius: 4px;
  padding: 1px 7px;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: var(--white);
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-secondary:hover {
  background: var(--accent-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: var(--gray-200);
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-800);
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-danger:hover {
  background: #fef2f2;
}

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

.btn-full { width: 100%; }

.btn-lg {
  padding: 12px 32px;
  font-size: 15px;
}

.btn-remove-row {
  background: transparent;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color .15s, background .15s;
}
.btn-remove-row:hover {
  color: #dc2626;
  background: #fef2f2;
}

/* ── Form Actions ──────────────────────────────────────────────────────────── */
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
}

/* ── Search Bar ────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}
.search-input { flex: 1; min-width: 200px; }
.date-input   { width: 140px; }
.date-sep     { font-size: 12px; color: var(--gray-400); white-space: nowrap; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--gray-400);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .form-row.two-col { grid-template-columns: 1fr; }
  .header-inner     { padding: 0 16px; }
  .main-content     { padding: 20px 16px 48px; }
  .login-card       { padding: 28px 20px; }
  .form-section     { padding: 18px 16px; }
  .search-bar       { padding: 12px 14px; }
  .search-input     { min-width: 100%; }
  .date-input       { width: 100%; }
  .header-nav .nav-link { padding: 6px 8px; font-size: 12.5px; }
}
