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

:root {
  --purple:      #7F77DD;
  --purple-dark: #534AB7;
  --purple-light:#EEEDFE;
  --purple-text: #3C3489;
  --red:         #E24B4A;
  --red-light:   #FCEBEB;
  --red-text:    #A32D2D;
  --green:       #3B6D11;
  --green-light: #EAF3DE;
  --green-text:  #27500A;
  --amber:       #BA7517;
  --amber-light: #FAEEDA;
  --amber-text:  #633806;
  --blue:        #185FA5;
  --blue-light:  #E6F1FB;
  --blue-text:   #0C447C;
  --gray:        #888780;
  --gray-light:  #F1EFE8;
  --gray-dark:   #444441;
  --text:        #1a1a1a;
  --text-2:      #555;
  --text-3:      #888;
  --border:      #e0ddd8;
  --bg:          #f7f6f3;
  --white:       #ffffff;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg); }
#root { min-height: 100vh; }

/* ── Splash ── */
.splash { display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100vh; gap: 16px; }
.splash-dot { width: 40px; height: 40px; border-radius: 50%; background: var(--purple); }
.splash p { color: var(--text-2); font-size: 13px; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--white); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; position: fixed;
  top: 0; left: 0; bottom: 0; z-index: 100; }
.main-content { margin-left: 220px; flex: 1; min-height: 100vh; overflow-x: hidden; }
.page-header { background: var(--white); border-bottom: 1px solid var(--border);
  padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; }
.page-header h1 { font-size: 18px; font-weight: 600; }
.page-body { padding: 24px; }

/* ── Sidebar ── */
.sidebar-brand { padding: 20px 16px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--purple); flex-shrink: 0; }
.brand-name { font-size: 13px; font-weight: 700; line-height: 1.3; color: var(--text); }
.brand-sub  { font-size: 10px; color: var(--text-3); }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text-2); border: none; background: none; width: 100%; text-align: left;
  transition: background .15s, color .15s; }
.nav-item:hover { background: var(--gray-light); color: var(--text); }
.nav-item.active { background: var(--purple-light); color: var(--purple-text); }
.nav-item .badge { margin-left: auto; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 20px; min-width: 18px; text-align: center; }
.nav-icon { font-size: 16px; width: 18px; text-align: center; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.user-card { padding: 10px 12px; border-radius: var(--radius); background: var(--gray-light); }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-3); text-transform: capitalize; }
.logout-btn { margin-top: 8px; width: 100%; padding: 8px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--white); color: var(--text-2);
  font-size: 12px; cursor: pointer; }
.logout-btn:hover { background: var(--red-light); color: var(--red-text); border-color: var(--red); }

/* ── Cards ── */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.card-sm { padding: 14px 16px; }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; }
.stat-label { font-size: 11px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card.danger .stat-value  { color: var(--red); }
.stat-card.warning .stat-value { color: var(--amber); }
.stat-card.success .stat-value { color: var(--green); }

/* ── Order Cards ── */
.order-list { display: flex; flex-direction: column; gap: 10px; }
.order-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 20px; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.order-card:hover { box-shadow: var(--shadow-md); border-color: var(--purple); }
.order-card.delayed { border-left: 4px solid var(--red); }
.order-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.so-number { font-size: 15px; font-weight: 700; color: var(--text); }
.customer-name { font-size: 13px; color: var(--text-2); flex: 1; }
.order-card-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.order-card-meta span { display: flex; align-items: center; gap: 4px; }
.delay-badge { background: var(--red-light); color: var(--red-text); font-size: 11px;
  font-weight: 600; padding: 2px 8px; border-radius: 20px; }

/* ── Status Badges ── */
.status-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.status-new                  { background: var(--gray-light);   color: var(--gray-dark); }
.status-design_in_progress   { background: var(--blue-light);   color: var(--blue-text); }
.status-customer_approved    { background: var(--green-light);  color: var(--green-text); }
.status-branding_in_progress { background: var(--amber-light);  color: var(--amber-text); }
.status-branding_complete    { background: var(--purple-light); color: var(--purple-text); }
.status-in_production        { background: var(--purple-light); color: var(--purple-text); }
.status-ready_for_dispatch   { background: var(--amber-light);  color: var(--amber-text); }
.status-dispatched           { background: var(--blue-light);   color: var(--blue-text); }
.status-closed               { background: var(--green-light);  color: var(--green-text); }
.status-cancelled            { background: var(--red-light);    color: var(--red-text); }

/* ── Branding Badge ── */
.branding-badge { display: inline-block; font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px; background: var(--purple-light); color: var(--purple-text); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px;
  border-radius: var(--radius); font-size: 13px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn-primary   { background: var(--purple);     color: #fff;                border-color: var(--purple); }
.btn-primary:hover { background: var(--purple-dark); }
.btn-secondary { background: var(--white);      color: var(--text);         border-color: var(--border); }
.btn-secondary:hover { background: var(--gray-light); }
.btn-danger    { background: var(--red-light);  color: var(--red-text);     border-color: var(--red); }
.btn-success   { background: var(--green-light);color: var(--green-text);   border-color: var(--green); }
.btn-warning   { background: var(--amber-light);color: var(--amber-text);   border-color: var(--amber); }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-label .req { color: var(--red); margin-left: 2px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; color: var(--text); background: var(--white); transition: border-color .15s; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(127,119,221,0.15); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr;     gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-hint  { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red-text); margin-top: 4px; }

/* ── Login ── */
.login-page { min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: var(--bg); padding: 24px; }
.login-card { background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.login-brand-dot { width: 36px; height: 36px; border-radius: 50%; background: var(--purple); }
.login-title { font-size: 18px; font-weight: 700; }
.login-sub   { font-size: 12px; color: var(--text-3); }
.login-error { background: var(--red-light); color: var(--red-text); padding: 10px 14px;
  border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }

/* ── Item Block ── */
.item-block { border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; margin-bottom: 14px; background: var(--gray-light); }
.item-block-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.item-number { font-size: 13px; font-weight: 700; color: var(--purple-text); }
.remove-item-btn { background: none; border: none; color: var(--red); cursor: pointer;
  font-size: 18px; padding: 2px 6px; border-radius: 4px; }
.remove-item-btn:hover { background: var(--red-light); }

/* ── Image Upload ── */
.image-upload-box { border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; cursor: pointer; transition: border-color .15s; }
.image-upload-box:hover { border-color: var(--purple); }
.image-preview { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }

/* ── Attachments ── */
.attachment-list { display: flex; flex-direction: column; gap: 8px; }
.attachment-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--gray-light); border-radius: var(--radius); font-size: 12px; }
.attachment-icon { font-size: 20px; }
.attachment-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { color: var(--text-3); }
.attachment-remove { background: none; border: none; color: var(--red); cursor: pointer;
  padding: 2px 6px; border-radius: 4px; font-size: 16px; }

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-line { width: 2px; background: var(--border); position: absolute; left: 11px; top: 24px; bottom: 0; }
.timeline-item:last-child .timeline-line { display: none; }
.timeline-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--purple);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; z-index: 1; }
.timeline-dot-small { background: var(--gray-light); border: 2px solid var(--border); }
.timeline-content { flex: 1; padding-top: 2px; }
.timeline-action { font-size: 13px; font-weight: 600; color: var(--text); }
.timeline-by { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.timeline-notes { font-size: 12px; color: var(--text-2); margin-top: 4px;
  background: var(--gray-light); padding: 4px 8px; border-radius: 4px; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal { background: var(--white); border-radius: var(--radius-lg); padding: 28px;
  width: 100%; max-width: 480px; box-shadow: var(--shadow-md); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── PIN ── */
.pin-display { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); transition: background .15s; }
.pin-dot.filled { background: var(--purple); border-color: var(--purple); }
.pin-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-key { padding: 16px; font-size: 20px; font-weight: 500; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--white); cursor: pointer; text-align: center; transition: background .1s; }
.pin-key:hover { background: var(--purple-light); }
.pin-key:active { background: var(--purple); color: #fff; }
.pin-key.delete { font-size: 16px; }
.pin-error { text-align: center; color: var(--red-text); font-size: 13px; margin-top: 10px; }

/* ── Order Detail ── */
.order-detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.section-title { font-size: 14px; font-weight: 700; margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.info-row { display: flex; flex-direction: column; gap: 3px; }
.info-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; }
.info-value { font-size: 13px; font-weight: 500; }

/* ── Action Panel ── */
.action-panel { background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; position: sticky; top: 20px; }
.action-panel-title { font-size: 13px; font-weight: 700; margin-bottom: 14px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.4px; }
.action-btn-row { display: flex; flex-direction: column; gap: 8px; }
.action-btn-row .btn { width: 100%; justify-content: center; }

/* ── Item Detail ── */
.item-detail-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 12px; }
.item-detail-top { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; }
.item-detail-img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--border); flex-shrink: 0; cursor: zoom-in; display: block;
  transition: transform .15s, box-shadow .15s; }
.item-detail-img:hover { transform: scale(1.1); box-shadow: var(--shadow-md); }
.item-detail-img-placeholder { width: 64px; height: 64px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--gray-light);
  display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.item-detail-info { flex: 1; }
.item-detail-name { font-size: 14px; font-weight: 600; }
.item-detail-meta { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.item-qty-badge { display: inline-block; background: var(--purple-light); color: var(--purple-text);
  font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 20px; margin-top: 6px; }

/* ── Artwork ── */
.artwork-area { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--gray-light); }
.artwork-title { font-size: 11px; font-weight: 600; color: var(--text-2); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 0.4px; }
.artwork-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.artwork-thumb { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--border); cursor: pointer; }
.artwork-upload-btn { display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  border: 2px dashed var(--purple); border-radius: var(--radius);
  background: none; color: var(--purple-text); cursor: pointer; font-size: 12px; font-weight: 500; }
.artwork-upload-btn:hover { background: var(--purple-light); }

/* ── Filter Bar ── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-input { flex: 1; min-width: 180px; max-width: 300px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--white); }
.filter-select { padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; background: var(--white); }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-icon  { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-desc  { font-size: 13px; color: var(--text-3); }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md); animation: slideIn .2s ease; max-width: 300px; }
.toast-success { background: var(--green-light); color: var(--green-text); border: 1px solid var(--green); }
.toast-error   { background: var(--red-light);   color: var(--red-text);   border: 1px solid var(--red); }
.toast-info    { background: var(--blue-light);   color: var(--blue-text);  border: 1px solid var(--blue); }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border); background: var(--gray-light); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-light); }

/* ── Misc ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--purple); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center;
  padding: 60px; gap: 12px; color: var(--text-3); }
.error-banner { background: var(--red-light); color: var(--red-text); padding: 14px 18px;
  border-radius: var(--radius); font-size: 14px; margin: 16px 0; }
.hide-mobile { display: inline; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 10px; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill-retail    { background: var(--purple-light); color: var(--purple-text); }
.pill-wholesale { background: var(--green-light);  color: var(--green-text); }

/* ── Board ── */
.board-columns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; align-items: start; }
.board-column  { min-width: 0; }
.kanban-grid   { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; align-items: start; }

/* ── Mobile Nav ── */
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--white); border-top: 1px solid var(--border);
  z-index: 200; padding: 6px 0 env(safe-area-inset-bottom, 6px); }
.mobile-nav-items { display: flex; justify-content: space-around; }
.mobile-nav-item { display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 12px; border: none; background: none;
  cursor: pointer; font-size: 10px; color: var(--text-3); min-width: 56px; }
.mobile-nav-item.active { color: var(--purple); }
.mobile-nav-item .nav-icon { font-size: 20px; }
.mobile-nav-badge { position: relative; display: inline-block; }
.mobile-nav-badge-dot { position: absolute; top: -2px; right: -6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

/* ── Print ── */
@media print {
  .no-print, .sidebar, .page-header, .action-panel, .filter-bar, .btn,
  .mobile-nav, .toast-container { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ── Responsive ── */
@media (max-width: 1200px) { .kanban-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) { .board-columns { grid-template-columns: repeat(3, 1fr); } }

@media (max-width: 768px) {
  .hide-on-mobile, .hide-mobile { display: none !important; }
  .sidebar { display: none !important; }
  .mobile-nav { display: block; }
  .main-content { margin-left: 0 !important; padding-bottom: 70px; }
  .page-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .page-header h1 { font-size: 16px; }
  .page-body { padding: 12px 16px; }
  .order-detail-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 22px; }
  .card, .action-panel { padding: 14px; }
  .order-card-top { flex-wrap: wrap; gap: 6px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-input { max-width: 100%; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }
  .modal { width: 100%; max-width: 100% !important; margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .pin-key { padding: 18px; font-size: 22px; }
  .pin-display { gap: 14px; }
  .pin-dot { width: 18px; height: 18px; }
  .board-columns, .kanban-grid { grid-template-columns: 1fr !important; }
  .board-column:has(.board-empty) { display: none; }
  .toast-container { left: 16px; right: 16px; bottom: 80px; }
  .toast { max-width: 100%; }
  .flex-gap { gap: 6px; }
  .attachment-name { max-width: 140px; }
  .section-title { font-size: 13px; }
  .info-grid { grid-template-columns: 1fr; }
  .action-btn-row .btn { width: 100%; justify-content: center; }
  div[style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
}
