* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #EEF4FB; --primary: #3D5A80; --dark: #2B4163; --mid: #5C7BA3;
  --light: #C8D9EE; --lighter: #E0EBF6; --white: #FFFFFF;
  --text: #1E2F45; --muted: #6B85A0; --red: #A32D2D; --red-bg: #FCEBEB;
  --green-bg: #E1F5EE; --green-text: #0F6E56;
  --amber-bg: #FAEEDA; --amber-text: #854F0B;
  --gray-bg: #F1EFE8; --gray-text: #5F5E5A;
  --blue-bg: #E0EBF6; --blue-text: #3D5A80;
  --purple-bg: #EEEDFE; --purple-text: #534AB7;
  --teal-bg: #E1F5EE; --teal-text: #0F6E56;
  --yellow-bg: #FEFCE8; --yellow-text: #854D0E;
  --sky-bg: #E0F2FE; --sky-text: #0369A1;
  --navy-bg: #DBEAFE; --navy-text: #1D4ED8;
  --pink-bg: #FCE7F3; --pink-text: #9D174D;
  --orange-bg: #FFF3E0; --orange-text: #B45309;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); min-height: 100vh; }
.screen { display: none; }
.screen.active { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem; }
.login-card { background: var(--white); border: 1px solid var(--light); border-radius: 16px; padding: 2rem; width: 100%; max-width: 380px; box-shadow: 0 4px 24px rgba(44,65,99,0.08); }
.login-logo { text-align: center; margin-bottom: 1.25rem; }
.login-logo img { width: 150px; height: auto; }
.login-tagline { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 1.25rem; }
.divider { height: 1px; background: var(--lighter); margin-bottom: 1.25rem; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 5px; letter-spacing: 0.4px; text-transform: uppercase; }
.field input { width: 100%; padding: 10px 13px; font-size: 14px; border: 1px solid var(--light); border-radius: 8px; background: var(--bg); color: var(--text); outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.field input:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px var(--lighter); }
.login-btn { width: 100%; padding: 11px; font-size: 14px; font-weight: 600; background: var(--primary); color: var(--white); border: none; border-radius: 8px; cursor: pointer; transition: background 0.15s; }
.login-btn:hover { background: var(--dark); }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { background: var(--mid); cursor: not-allowed; }
.error-msg { font-size: 12px; color: var(--red); background: var(--red-bg); border-radius: 8px; padding: 9px 12px; margin-bottom: 13px; display: none; }
.error-msg.show { display: block; }
.login-hint { font-size: 11px; color: var(--muted); text-align: center; margin-top: 14px; line-height: 1.5; }

#portalScreen { display: none; flex-direction: column; align-items: stretch; min-height: 100vh; }
#portalScreen.active { display: flex; }
.header { background: var(--dark); padding: 0.75rem 1.5rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.header-logo img { height: 40px; width: auto; }
.header-right { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--mid); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #EEF4FB; border: 1px solid #5C7BA3; flex-shrink: 0; }
.buyer-name { font-size: 12px; color: #C8D9EE; }
.logout-btn { font-size: 11px; color: #8AAAC8; background: none; border: 1px solid #3D5A80; border-radius: 6px; padding: 5px 11px; cursor: pointer; }
.logout-btn:hover { background: rgba(255,255,255,0.08); color: #C8D9EE; }

.main { padding: 1.5rem; max-width: 900px; margin: 0 auto; width: 100%; flex: 1; }
.page-title { font-size: 20px; font-weight: 600; color: var(--dark); margin-bottom: 3px; }
.page-sub { font-size: 13px; color: var(--muted); margin-bottom: 1.25rem; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 1.25rem; }
.stat { background: var(--white); border: 1px solid var(--light); border-radius: 10px; padding: 12px 14px; }
.stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.stat-val { font-size: 20px; font-weight: 600; color: var(--dark); }

/* CONTROLS BAR */
.controls-bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 1.25rem; }

.controls-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.controls-row-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; min-width: 36px; }

.filter-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 11px; font-weight: 600; padding: 5px 12px;
  border-radius: 20px; border: 1.5px solid var(--light);
  background: var(--white); color: var(--muted);
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
  user-select: none; display: inline-flex; align-items: center; gap: 4px;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active       { background: var(--primary);    border-color: var(--primary);    color: var(--white); }
.chip.active-green { background: var(--green-bg);   border-color: var(--green-text); color: var(--green-text); }
.chip.active-amber { background: var(--amber-bg);   border-color: var(--amber-text); color: var(--amber-text); }
.chip.active-red   { background: var(--red-bg);     border-color: var(--red);        color: var(--red); }

.sort-select {
  font-size: 12px; font-weight: 600; padding: 5px 10px;
  border: 1.5px solid var(--light); border-radius: 20px;
  background: var(--white); color: var(--text);
  cursor: pointer; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236B85A0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 26px;
  transition: border-color 0.15s;
}
.sort-select:hover, .sort-select:focus { border-color: var(--primary); color: var(--primary); }
.sort-select.has-value { background-color: var(--blue-bg); border-color: var(--primary); color: var(--primary); }

.controls-right { margin-left: auto; }
.filter-count { font-size: 11px; color: var(--muted); white-space: nowrap; }

.no-results { text-align: center; padding: 2.5rem 1rem; color: var(--muted); font-size: 14px; background: var(--white); border: 1px solid var(--light); border-radius: 12px; }

/* TRACKER */
.tracker-wrap { padding: 14px 16px 4px; border-bottom: 1px solid var(--lighter); }
.tracker-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 10px; }
.tracker { display: flex; align-items: flex-start; overflow-x: auto; padding-bottom: 10px; }
.step { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 64px; position: relative; }
.step:not(:last-child)::after { content: ''; position: absolute; top: 10px; left: 50%; width: 100%; height: 2px; background: var(--lighter); z-index: 0; }
.step:not(:last-child).done::after { background: var(--primary); }
.step-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--lighter); border: 2px solid var(--light); display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--muted); z-index: 1; flex-shrink: 0; }
.step.done .step-dot { background: var(--primary); border-color: var(--primary); color: white; }
.step.current .step-dot { background: var(--white); border-color: var(--primary); border-width: 2.5px; box-shadow: 0 0 0 3px var(--lighter); }
.step-name { font-size: 9px; color: var(--muted); text-align: center; margin-top: 5px; line-height: 1.3; max-width: 62px; }
.step.done .step-name { color: var(--primary); font-weight: 600; }
.step.current .step-name { color: var(--dark); font-weight: 700; }

.orders-list { display: flex; flex-direction: column; gap: 10px; }
.order-card { background: var(--white); border: 1px solid var(--light); border-radius: 12px; overflow: hidden; }
.order-header { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; gap: 12px; }
.order-header:hover { background: var(--lighter); }
.order-left { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.order-num { font-size: 14px; font-weight: 600; color: var(--dark); }
.order-date { font-size: 11px; color: var(--muted); }
.order-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
.badge { font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.badge-green  { background: var(--green-bg);  color: var(--green-text); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber-text); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue-text); }
.badge-gray   { background: var(--gray-bg);   color: var(--gray-text); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-purple { background: var(--purple-bg); color: var(--purple-text); }
.badge-teal   { background: var(--teal-bg);   color: var(--teal-text); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow-text); }
.badge-sky    { background: var(--sky-bg);    color: var(--sky-text); }
.badge-navy   { background: var(--navy-bg);   color: var(--navy-text); }
.badge-pink   { background: var(--pink-bg);   color: var(--pink-text); }
.badge-orange { background: var(--orange-bg); color: var(--orange-text); }
.chevron { font-size: 10px; color: var(--muted); transition: transform 0.2s; flex-shrink: 0; }
.chevron.open { transform: rotate(180deg); }
.order-body { border-top: 1px solid var(--lighter); display: none; }
.order-body.open { display: block; }
.items-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.items-table th { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; padding: 9px 16px; text-align: left; background: var(--bg); border-bottom: 1px solid var(--lighter); }
.items-table td { font-size: 12px; color: var(--text); padding: 9px 16px; border-bottom: 1px solid var(--lighter); word-break: break-word; }
.items-table tr:last-child td { border-bottom: none; }
.items-table th:nth-child(1), .items-table td:nth-child(1) { width: 52%; }
.items-table th:nth-child(2), .items-table td:nth-child(2) { width: 10%; }
.items-table th:nth-child(3), .items-table td:nth-child(3) { width: 19%; }
.items-table th:nth-child(4), .items-table td:nth-child(4) { width: 19%; }
.order-footer { padding: 12px 16px; background: var(--bg); border-top: 1px solid var(--lighter); display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.payment-block { display: flex; flex-direction: column; gap: 5px; min-width: 220px; }
.payment-row { display: flex; gap: 8px; font-size: 12px; }
.payment-label { color: var(--muted); min-width: 130px; }
.payment-val { font-weight: 600; color: var(--dark); }
.payment-val.red { color: var(--red); }
.notes-block { flex: 1; min-width: 160px; }
.notes-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; font-weight: 600; }
.notes-text { font-size: 12px; color: var(--muted); font-style: italic; line-height: 1.5; }
.tracking-text { font-size: 12px; color: var(--primary); font-weight: 600; }
.loading { text-align: center; padding: 3rem 1rem; color: var(--muted); font-size: 14px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--lighter); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) {
  .summary-grid { grid-template-columns: repeat(1, 1fr); }
  .buyer-name { display: none; }
  .main { padding: 1rem; }
}
