/**
 * Admin Panel Styles
 * Design system: CSS variables + base styles (Vaishnavi Printers)
 */

/* ========== DESIGN SYSTEM — CSS VARIABLES ========== */
:root {
  /* Primary & states */
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #EFF6FF;
  --success: #16A34A;
  --success-light: #F0FDF4;
  --warning: #D97706;
  --warning-light: #FFFBEB;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --info: #0891B2;
  --info-light: #ECFEFF;
  /* Text */
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  /* Borders & background */
  --border: #E5E7EB;
  --border-dark: #D1D5DB;
  --bg-page: #F3F4F6;
  --bg-card: #FFFFFF;
  --bg-sidebar: #1E293B;
  --sidebar-text: #CBD5E1;
  --sidebar-active: #2563EB;
  /* Shadows & radius */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  /* Legacy (existing admin.css) */
  --primary-color: #2563EB;
  --secondary-color: #1D4ED8;
  --success-color: #16A34A;
  --error-color: #DC2626;
  --warning-color: #D97706;
  --text-dark: #111827;
  --text-light: #6B7280;
  --bg-light: #F3F4F6;
  --border-color: #E5E7EB;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* ========== LAYOUT & PAGE ========== */
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg-page); color: var(--text-primary); font-size: 14px; line-height: 1.5; }
.page-content { width: 90%; max-width: 1280px; margin: 0 auto; padding: 24px; background: var(--bg-page); min-height: calc(100vh - 80px); box-sizing: border-box; }
.ui-main .page-content { width: 97%; max-width: 1440px; }
.dashboard { width: 97%; max-width: 1440px; margin: 0 auto; padding: 16px; box-sizing: border-box; }
.page-header h1 { font-size: 20px; font-weight: 600; color: var(--text-primary); }
@media (max-width: 768px) {
  .page-content, .dashboard { width: 100%; max-width: 100%; padding: 6px 8px; box-sizing: border-box; }
  .ui-main .page-content { width: 100%; max-width: 100%; }
}

/* ========== CARDS (design system) ========== */
.card,
.content-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.card-header {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ========== STAT CARDS (dashboard tiles) ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 1024px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}
.stat-content h3 { font-size: 28px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.stat-content p { font-size: 13px; color: var(--text-secondary); margin: 0; }

/* ========== BUTTONS (design system — keep existing .btn classes) ========== */
.btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
  min-height: 44px;
  box-sizing: border-box;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline {
  background: #fff;
  border: 1px solid var(--border-dark);
  color: var(--text-primary);
}
.btn-outline:hover { background: var(--bg-page); border-color: var(--border); }
.btn-sm { padding: 5px 12px; font-size: 12px; min-height: 32px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }

/* ========== BADGES & STATUS BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-pending, .status-order_received { background: var(--warning-light); color: var(--warning); }
.badge-confirmed, .status-order_confirmed { background: var(--info-light); color: var(--info); }
.badge-design, .status-design_in_progress, .status-waiting_for_approval { background: var(--info-light); color: var(--primary); }
.badge-design-done, .status-design_approved { background: var(--success-light); color: var(--success); }
.badge-printing, .status-printing_in_progress { background: var(--primary-light); color: var(--primary); }
.badge-printing-done, .status-printing_done { background: var(--success-light); color: var(--success); }
.badge-finishing, .status-finishing_in_progress { background: var(--warning-light); color: var(--warning); }
.badge-ready, .status-ready_for_delivery { background: var(--success-light); color: var(--success); }
.badge-out, .status-out_for_delivery { background: var(--primary-light); color: var(--primary); }
.badge-delivered, .status-delivered { background: var(--success); color: #fff; }
.badge-cancelled { background: var(--danger-light); color: var(--danger); }

/* ========== TABLES (design system enhancements) ========== */
.data-table thead th {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 16px;
  font-weight: 600;
}
.data-table tbody tr:hover { background: #F9FAFB; }
.data-table td { padding: 12px 16px; text-overflow: ellipsis; overflow: hidden; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table-container { overflow-x: auto; width: 100%; max-width: 100%; box-sizing: border-box; }

/* ========== USERS CARD GRID (business card style) ========== */
.users-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.user-card {
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.user-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.user-card-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: 0.02em;
}
.user-card-username {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: monospace;
}
.user-card-designation {
  margin: 0.15rem 0;
}
.user-card-designation .role-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-weight: 600;
}
.user-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.user-card-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  word-break: break-word;
}
.user-card-row i {
  width: 1rem;
  color: var(--primary);
}
.user-card-login {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.user-card-status {
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}
.user-card-status .user-status-btn { min-height: 36px; padding: 0.4rem 0.75rem; touch-action: manipulation; }
.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.user-action-btn {
  min-height: 38px;
  padding: 0.45rem 0.7rem;
  font-size: 0.8125rem;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.btn-outline-muted {
  background: var(--bg-page);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
@media (max-width: 640px) {
  .users-card-grid { grid-template-columns: 1fr; }
  .user-card-name { font-size: 1.2rem; }
  .user-card-actions { flex-wrap: wrap; }
  .user-action-btn { min-height: 44px; padding: 0.5rem 0.75rem; }
}

/* ========== FORMS (design system) ========== */
.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: block;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  outline: none;
}
.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
  background: #F3F4F6;
  cursor: not-allowed;
}
.filter-form .form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; align-items: flex-end; }
@media (max-width: 768px) { .filter-form .form-row { grid-template-columns: 1fr; } }

/* ========== VP MODAL (replace system alerts) ========== */
.vp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.vp-modal-overlay.active { display: flex; }
.vp-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: vpModalIn 0.2s ease;
}
@keyframes vpModalIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.vp-modal-icon { font-size: 48px; margin-bottom: 16px; }
.vp-modal-title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.vp-modal-message { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; line-height: 1.6; }
.vp-modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ========== VP TOAST ========== */
#vp-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.vp-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid;
  font-size: 14px;
  min-width: 280px;
  animation: vpToastIn 0.3s ease;
  color: var(--text-primary);
  pointer-events: auto;
}
.vp-toast.success { border-color: var(--success); }
.vp-toast.error { border-color: var(--danger); }
.vp-toast.warning { border-color: var(--warning); }
.vp-toast.info { border-color: var(--primary); }
@keyframes vpToastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== LOADING & EMPTY STATES ========== */
.loading { text-align: center; padding: 24px; color: var(--text-secondary); }
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; color: var(--border-dark); }

/* ========== SPACING & TYPOGRAPHY ========== */
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.content-card h2 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }
.order-number-mono {
  font-family: monospace;
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--primary);
}

/* Dashboard sections (design system) */
.dashboard-section {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.dashboard-section h2 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }
.dashboard-section-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }

/* Production queue — card-based list */
.prod-section { margin-bottom: 20px; }
.prod-section h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 12px; }
.prod-next {
  background: var(--success-light);
  border: 1px solid var(--success);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.prod-next .badge { background: var(--success); color: #fff; }
.prod-table th { background: var(--primary-light); color: var(--primary); padding: 10px 16px; font-size: 12px; text-transform: uppercase; }
.prod-table td { padding: 12px 16px; }
.prod-overdue { color: var(--danger); font-weight: 600; }

/* Orders type tabs */
.orders-type-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.orders-tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
  border: 1px solid transparent;
  margin-bottom: -1px;
}
.orders-tab:hover { color: var(--primary); background: var(--primary-light); }
.orders-tab.active { color: var(--primary); background: var(--bg-card); border-color: var(--border); border-bottom-color: var(--bg-card); }

/* Mobile: touch targets & single column */
@media (max-width: 768px) {
  .btn { min-height: 44px; }
  .stats-grid { gap: 16px; }
  .page-content { padding: 16px; }
  .filter-form .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn { width: 100%; max-width: 100%; }
}
@media (max-width: 480px) {
  .page-content { padding: 12px; }
  .content-card, .card { padding: 16px; }
  .stat-card { padding: 16px; }
  .stat-content h3 { font-size: 24px; }
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 2rem;
    width: 100%;
    max-width: 450px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.login-header h2 {
    color: var(--text-light);
    font-size: 1rem;
    font-weight: normal;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-form .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.login-form .form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.login-form .form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Password Toggle */
.password-input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 3.5rem;
    flex: 1;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: #6b7280;
    font-size: 1.1rem;
    transition: color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    width: auto;
    height: auto;
    min-width: 30px;
}

.password-toggle:hover {
    color: var(--primary-color);
}

.password-toggle:focus {
    outline: none;
    color: var(--primary-color);
}

.password-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.password-toggle i {
    pointer-events: none;
    display: block;
}

.login-form button[type="submit"],
.login-form .btn {
    width: 100%;
    margin-top: 1rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 0.5rem;
    background: var(--primary-color);
    color: #fff;
    transition: all 0.3s;
    display: block;
    text-align: center;
}

.login-form button[type="submit"]:hover,
.login-form .btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.login-form button[type="submit"]:active,
.login-form .btn:active {
    transform: translateY(0);
}

.login-form button[type="submit"]:disabled,
.login-form .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-form .btn-block {
    display: block;
    width: 100%;
}

/* Dashboard */
.dashboard {
    padding: 2rem;
    min-height: calc(100vh - 80px);
    background: var(--bg-light);
}

.page-content {
    padding: 2rem;
    min-height: calc(100vh - 80px);
    background: var(--bg-light);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.role-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.role-super_admin { background: #fee2e2; color: #991b1b; }
.role-admin { background: #fce7f3; color: #9d174d; }
.role-supervisor { background: #ede9fe; color: #5b21b6; }
.role-sales { background: #dbeafe; color: #1e40af; }
.role-designer { background: #fef3c7; color: #92400e; }
.role-printer { background: #e0e7ff; color: #3730a3; }
.role-finishing { background: #d1fae5; color: #065f46; }
.role-qc { background: #e0f2fe; color: #0369a1; }
.role-accounts { background: #fef9c3; color: #854d0e; }
.role-dispatch { background: #f3e8ff; color: #6b21a8; }
.role-delivery { background: #d1fae5; color: #065f46; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2rem;
}

.stat-content h3 {
    font-size: 1.75rem;
    margin-bottom: 0.2rem;
    color: var(--primary-color);
}

.stat-content p {
    color: var(--text-light);
    font-size: 0.875rem;
}

.dashboard-section {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.875rem 1rem;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.dashboard-section h2 {
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

/* Dashboard Section Header with Search - Universal Style */
.dashboard-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-section-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
}

/* Search Container - Universal Style */
.search-container {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-container input[type="text"] {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s;
    outline: none;
    box-sizing: border-box;
}

.search-container input[type="text"]:focus {
    border-color: #f97316;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.search-container input[type="text"]::placeholder {
    color: #9ca3af;
}

.search-container .fa-search {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    pointer-events: none;
    z-index: 1;
}

.search-container button {
    display: none;
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.3rem;
    font-size: 0.9rem;
    transition: color 0.2s;
    z-index: 2;
}

.search-container button:hover {
    color: #dc2626;
}

@media (max-width: 768px) {
    .dashboard-section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-container {
        max-width: 100%;
    }
}

/* Data Table */
.data-table-container {
    overflow-x: auto;
    width: 100%;
}

.orders-table-container {
    overflow-x: visible;
    width: 100%;
    max-width: 100%;
}

/* ============================================
   UNIVERSAL TABLE LAYOUT - FIXED COLUMN WIDTHS
   Applies to: Dashboard, Orders, Invoices
   ============================================ */

.data-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
    margin: 0;
    border-spacing: 0;
    box-sizing: border-box;
}

.data-table th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-dark);
}

.data-table tbody tr {
    height: auto;
    min-height: 0;
    display: table-row;
}

/* Payment history table rows - ensure no excessive height */
.payment-history-table-wrap .payment-history-table.data-table tbody tr {
    height: auto !important;
    min-height: 0 !important;
}

.data-table tbody tr:hover {
    background: var(--bg-light);
}

/* ============================================
   FIXED COLUMN WIDTHS - ORDERS & DASHBOARD
   Column order: Order Number | Customer | Mobile | Status | Amount | Date | Actions
   ============================================ */

/* Order Number: 160px */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
    width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Customer: 220px max-width - Proper wrapping */
.data-table th:nth-child(2),
.data-table td:nth-child(2),
.data-table .customer-col {
    max-width: 220px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

/* Customer name text wrapper */
.data-table .customer-col .customer-name,
.data-table td:nth-child(2) {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

/* Mobile: 150px */
.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    width: 150px;
    white-space: nowrap;
    text-align: center;
}

/* Status: 170px */
.data-table th:nth-child(4),
.data-table td:nth-child(4) {
    width: 170px;
    white-space: nowrap;
    text-align: center;
}

/* Amount: 130px */
.data-table th:nth-child(5),
.data-table td:nth-child(5) {
    width: 130px;
    white-space: nowrap;
    text-align: right;
}

/* Date: 130px */
.data-table th:nth-child(6),
.data-table td:nth-child(6) {
    width: 130px;
    white-space: nowrap;
    text-align: center;
}

/* Actions: 90px */
.data-table th:nth-child(7),
.data-table td:nth-child(7) {
    width: 90px;
    white-space: nowrap;
    text-align: center;
}

/* ============================================
   INVOICES TABLE - 8 COLUMNS
   Column order: Invoice Number | Order Number | Customer | Type | Date | Amount | Generated By | Actions
   ============================================ */

/* Invoice Number: 160px */
.orders-table-container .data-table th:nth-child(1),
.orders-table-container .data-table td:nth-child(1) {
    width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Order Number: 160px */
.orders-table-container .data-table th:nth-child(2),
.orders-table-container .data-table td:nth-child(2) {
    width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Customer: 220px max-width - Proper wrapping */
.orders-table-container .data-table th:nth-child(3),
.orders-table-container .data-table td:nth-child(3) {
    max-width: 220px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

/* Type: 120px */
.orders-table-container .data-table th:nth-child(4),
.orders-table-container .data-table td:nth-child(4) {
    width: 120px;
    white-space: nowrap;
    text-align: center;
}

/* Date: 130px */
.orders-table-container .data-table th:nth-child(5),
.orders-table-container .data-table td:nth-child(5) {
    width: 130px;
    white-space: nowrap;
    text-align: center;
}

/* Amount: 130px */
.orders-table-container .data-table th:nth-child(6),
.orders-table-container .data-table td:nth-child(6) {
    width: 130px;
    white-space: nowrap;
    text-align: right;
}

/* Generated By: 150px */
.orders-table-container .data-table th:nth-child(7),
.orders-table-container .data-table td:nth-child(7) {
    width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

/* Actions: 90px */
.orders-table-container .data-table th:nth-child(8),
.orders-table-container .data-table td:nth-child(8) {
    width: 90px;
    white-space: nowrap;
    text-align: center;
}

/* Mobile Card Layout for Orders Table */
.orders-card-container {
    display: none;
}

.order-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.625rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.order-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.order-card-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.order-card-status {
    margin-top: 0.25rem;
}

.order-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
}

.order-card-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.order-card-label {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.order-card-value {
    font-size: 0.95rem;
    color: var(--text-dark);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.order-card-customer {
    grid-column: 1 / -1;
}

.order-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive: Show cards on mobile, table on desktop */
@media (max-width: 768px) {
    .orders-table-container .data-table {
        display: none;
    }
    
    .orders-card-container {
        display: block;
    }

    .order-card-body {
        grid-template-columns: 1fr 1fr;
    }

    .order-card-customer {
        grid-column: 1 / -1;
    }

    .order-card-footer {
        flex-direction: row;
        justify-content: flex-end;
    }
}

/* ========== WORK QUEUE CARDS (my-printing, my-designs, my-finishing, dashboard) ========== */
.wq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}
.wq-grid-full {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.wq-card {
    background: #fff;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0.5rem;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
    border-left: 3px solid transparent;
}
.wq-card:hover { box-shadow: 0 3px 8px rgba(0,0,0,0.10); }
.wq-card-emergency { border-left-color: #dc2626; background: #fffaf9; }
.wq-card-high      { border-left-color: #ea580c; background: #fffbf7; }
.wq-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.wq-order {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary, #2563eb);
}
.wq-card-item {
    font-weight: 600;
    font-size: 0.92rem;
    color: #1f2937;
    line-height: 1.3;
}
.wq-qty {
    font-weight: 400;
    font-size: 0.82rem;
    color: #6b7280;
}
.wq-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 0.82rem;
    color: #4b5563;
}
.wq-customer { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wq-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    border-top: 1px solid #f3f4f6;
    padding-top: 6px;
    margin-top: 2px;
}
.wq-date { font-size: 0.77rem; color: #9ca3af; }
.wq-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.wq-badge-emergency { background: #fee2e2; color: #dc2626; }
.wq-badge-high      { background: #ffedd5; color: #ea580c; }
.wq-badge-normal    { background: #f1f5f9; color: #64748b; }
.wq-loading {
    text-align: center;
    padding: 20px;
    color: #6b7280;
    font-size: 0.9rem;
}
.wq-empty {
    text-align: center;
    padding: 24px 16px;
    color: #6b7280;
    font-size: 0.92rem;
    background: #f9fafb;
    border-radius: 0.5rem;
}

/* ── Hero card: "Available Next Task" ── */
.wq-hero-card {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 2px solid #3b82f6;
    border-radius: 0.75rem;
    padding: 16px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(59,130,246,0.15);
}
.wq-hero-card.wq-card-emergency {
    background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
    border-color: #dc2626;
    box-shadow: 0 4px 12px rgba(220,38,38,0.15);
}
.wq-hero-card.wq-card-high {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border-color: #ea580c;
    box-shadow: 0 4px 12px rgba(234,88,12,0.15);
}
.wq-hero-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #3b82f6;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.wq-hero-card.wq-card-emergency .wq-hero-label { color: #dc2626; }
.wq-hero-card.wq-card-high .wq-hero-label      { color: #ea580c; }
.wq-hero-order {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e40af;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.wq-hero-card.wq-card-emergency .wq-hero-order { color: #991b1b; }
.wq-hero-card.wq-card-high .wq-hero-order      { color: #9a3412; }
.wq-hero-name {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}
.wq-hero-item {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 8px;
}
.wq-hero-delivery {
    margin-bottom: 12px;
    font-size: 0.82rem;
}
.wq-hero-actions {
    margin-top: 4px;
}
.wq-hero-actions .wq-btn-takeover {
    width: 100%;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
}

/* ── Queue card actions row (View 35% | Takeover 65%) ── */
.wq-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
}
.wq-card-actions .wq-btn-view {
    flex: 0 0 35%;
    text-align: center;
    padding: 7px 4px;
    font-size: 0.82rem;
}
.wq-card-actions .wq-btn-takeover {
    flex: 0 0 calc(65% - 6px);
    text-align: center;
    padding: 7px 4px;
    font-size: 0.82rem;
    font-weight: 600;
}
.wq-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
    margin-bottom: 2px;
}
.wq-card-delivery {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 2px;
}
.wq-delivery {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.wq-delivery i { color: #9ca3af; font-size: 0.72rem; }
.wq-delivery-urgent { color: #dc2626 !important; font-weight: 600; }
.wq-delivery-soon   { color: #ea580c !important; }

@media (max-width: 480px) {
    .wq-grid, .wq-grid-full { grid-template-columns: 1fr; }
    .wq-hero-order { font-size: 1.3rem; }
}

@media (min-width: 769px) {
    .orders-card-container {
        display: none;
    }
    
    .orders-table-container .data-table {
        display: table;
    }
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.status-order-received { background: #dbeafe; color: #1e40af; }
.status-design-in-progress { background: #fef3c7; color: #92400e; }
.status-design-approved { background: #d1fae5; color: #065f46; }
.status-printing-in-progress { background: #e0e7ff; color: #3730a3; }
.status-printing-done { background: #ddd6fe; color: #5b21b6; }
.status-ready-for-delivery { background: #fed7aa; color: #9a3412; }
.status-delivered { background: #86efac; color: #166534; }

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 34px;
}

/* Action buttons - uniform width for table cells */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    gap: 0.5rem;
    align-items: stretch;
}
.action-buttons .btn,
.action-buttons .btn-sm {
    min-width: 118px;
    flex: 1 1 auto;
    white-space: nowrap;
    text-align: center;
    padding: 0.5rem 0.75rem;
}

.text-center {
    text-align: center;
}

/* Forms */
.page-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.content-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: var(--shadow);
}

/* Orders list: type tabs (All | Regular | Walk-in) */
.orders-type-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
}
.orders-tab {
    padding: 0.65rem 1.25rem;
    border-radius: 8px 8px 0 0;
    text-decoration: none;
    color: #6b7280;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    background: transparent;
    margin-bottom: -2px;
}
.orders-tab:hover {
    color: var(--primary-color, #2563eb);
    background: #f3f4f6;
}
.orders-tab.active {
    color: var(--primary-color, #2563eb);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-bottom-color: #fff;
}
@media (max-width: 600px) {
    .orders-type-tabs { gap: 0.25rem; }
    .orders-tab { padding: 0.5rem 0.75rem; font-size: 0.8rem; }
}

/* Responsive: tables and inputs - no overflow */
.data-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}
.data-table th,
.data-table td {
    padding: 12px;
    vertical-align: middle;
    text-align: left;
    white-space: normal;
    word-break: break-word;
}
@media (max-width: 768px) {
    .data-table { font-size: 0.85rem; }
    .data-table th, .data-table td { padding: 0.5rem; }
}
.filter-form input,
.filter-form select,
.filter-form button {
    max-width: 100%;
    box-sizing: border-box;
}

/* Enhanced Create Order Page */
.create-order-container {
    max-width: 1200px;
    margin: 0 auto;
}

.order-form-wrapper {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.page-subtitle {
    color: #6b7280;
    font-size: 0.95rem;
    margin-top: 0.5rem;
    font-weight: 400;
}

.form-section {
    margin-bottom: 0;
    padding: 0;
    border-bottom: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.form-section:last-child {
    border-bottom: none;
}

.form-section:hover {
    background: #fafafa;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 2px solid #e2e8f0;
}

.section-header h3 {
    margin: 0;
    color: #1e293b;
    font-size: 1.25rem;
    font-weight: 700;
    flex: 1;
}

.section-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 10px;
}

.section-content {
    padding: 2rem;
}

.item-count-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.customer-section .section-icon {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.items-section .section-icon {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.details-section .section-icon {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.summary-section {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-top: 3px solid #f59e0b;
}

.summary-section .section-header {
    background: transparent;
    border-bottom: 2px solid #fbbf24;
}

.summary-section .section-icon {
    background: rgba(245, 158, 11, 0.2);
    color: #d97706;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #fff;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #cbd5e1;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    background: #f8fafc;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
    font-weight: 600;
    color: #374151;
    font-size: 0.95rem;
}

.form-group label::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 2px;
    opacity: 0.6;
}

.order-item {
    background: #fff;
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    border: 2px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
    position: relative;
}

.order-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.order-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-color);
    border-radius: 10px 0 0 10px;
    opacity: 0;
    transition: opacity 0.3s;
}

.order-item:hover::before {
    opacity: 1;
}

/* File Upload Styles */
.file-upload-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.file-upload-area {
    position: relative;
}

.file-upload-placeholder {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-upload-placeholder:hover {
    border-color: var(--primary-color);
    background: #f0f9ff;
}

.file-upload-placeholder.drag-over {
    border-color: var(--primary-color);
    background: #dbeafe;
    transform: scale(1.02);
}

.file-upload-placeholder i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: block;
}

.file-upload-placeholder p {
    margin: 0.5rem 0;
    color: #374151;
    font-weight: 600;
}

.file-upload-placeholder small {
    color: #6b7280;
    font-size: 0.875rem;
}

.uploaded-files-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.uploaded-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.uploaded-file-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.file-info i {
    color: var(--primary-color);
    font-size: 1.25rem;
}

.file-name {
    font-weight: 600;
    color: #1e293b;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    color: #6b7280;
    font-size: 0.875rem;
}

.btn-remove-file {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-file:hover {
    background: #dc2626;
    color: white;
    transform: scale(1.1);
}

.btn-add-more-files {
    margin-top: 1rem;
    padding: 0.625rem 1rem;
    background: #f0f9ff;
    color: var(--primary-color);
    border: 1px dashed var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
}

.btn-add-more-files:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.item-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    align-items: end;
    margin-bottom: 1rem;
}

.order-form {
    max-width: 100%;
}

.order-summary {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 2px solid #fbbf24;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
    font-size: 1rem;
    color: #374151;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-total {
    font-weight: 800;
    font-size: 1.5rem;
    color: #1e293b;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    border: 2px solid #fbbf24;
}

.summary-total span:last-child {
    color: #d97706;
    font-size: 1.75rem;
}

/* Advance Received Input */
.order-summary .form-group {
    margin-bottom: 1rem;
}

.order-summary .form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #fbbf24;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.order-summary .form-group input[type="number"]:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

/* Due Amount Styling */
.summary-total.summary-due {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: #ef4444;
    color: #991b1b;
}

.summary-total.summary-due span:last-child {
    color: #dc2626;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding: 2rem;
    background: #f8fafc;
    border-top: 2px solid #e5e7eb;
    justify-content: flex-end;
}

.btn-create-order {
    padding: 0.875rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: all 0.3s ease;
}

.btn-create-order:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-add-item {
    width: 100%;
    margin-top: 1rem;
    padding: 0.875rem 1.5rem;
    border: 2px dashed var(--border-color);
    background: #f8fafc;
    color: var(--primary-color);
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-add-item:hover,
.btn-add-item:active,
.btn-add-item:focus {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    outline: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

@media (max-width: 768px) {
    .btn-add-item {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        min-height: 48px; /* Better touch target */
    }
}

.btn-remove-item {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-secondary {
    background: var(--text-light);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--text-dark);
}

.btn-danger {
    background: var(--error-color);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Order Details */
.order-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.order-section {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    height: auto;
    min-height: 0;
}

/* Payment section specific - ensure no excessive height */
#paymentSection {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
}

#paymentSection .payment-history-section {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
}

.order-section h2 {
    margin-bottom: 1rem;
    color: var(--text-dark);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.info-box {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: 0.5rem;
    word-wrap: normal;
    overflow-wrap: normal;
    word-break: normal;
}

/* Apply discount to pending — single column, one field per row */
.vp-post-discount-box .vp-post-discount-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: min(420px, 100%);
    box-sizing: border-box;
}
.vp-post-discount-box .vp-post-discount-field input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.vp-post-discount-box .vp-post-discount-actions .btn {
    width: 100%;
    box-sizing: border-box;
}

.info-row {
    padding: 0.5rem 0;
    word-wrap: normal !important;
    overflow-wrap: break-word !important;
    word-break: keep-all !important;
    white-space: normal;
    border-bottom: 1px solid var(--border-color);
    hyphens: none !important;
}

.info-row strong {
    display: inline-block;
    min-width: 80px;
    word-break: keep-all !important;
    white-space: nowrap;
    margin-right: 0.5rem;
}

.info-row:last-child {
    border-bottom: none;
}

.total-row {
    font-weight: bold;
    font-size: 1.125rem;
    color: var(--primary-color);
}

.status-form,
.invoice-form {
    margin-top: 1rem;
}

.filters {
    margin-bottom: 1.5rem;
}

.filter-form .form-row {
    margin-bottom: 0;
}

.filter-form .form-group {
    margin-bottom: 0;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.admin-nav {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    color: #fff;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-bottom: 3px solid var(--primary-color);
    position: relative;
}

.admin-nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.nav-menu-left,
.nav-menu-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.nav-menu-right {
    justify-content: flex-end;
}

.nav-brand-center {
    flex-shrink: 0;
    padding: 0 1rem;
    text-align: center;
}

.nav-brand-center h2,
.nav-brand h2 {
    color: #fff;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.nav-brand-center h2::before,
.nav-brand h2::before {
    content: '🖨️';
    font-size: 1.35rem;
}

/* Mobile dropdown menu - hidden on desktop */
@media (min-width: 969px) {
    .nav-menu-mobile {
        display: none !important;
    }
}

.nav-menu-mobile {
    display: none;
    flex-direction: column;
    gap: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #374151 0%, #1f2937 100%);
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 100;
}

.nav-menu-mobile.mobile-menu-open {
    max-height: 600px;
    padding: 0.75rem;
    overflow-y: auto;
}

.admin-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    position: relative;
    width: 100%;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 0;
    flex-shrink: 0;
    order: 1;
}

.nav-menu {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    flex: 0 0 auto;
    justify-content: flex-end;
    order: 2;
    margin-left: auto;
}

.nav-menu a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    position: relative;
    white-space: nowrap;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
}

.nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    position: relative;
    white-space: nowrap;
}

.nav-box {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
}

.nav-menu a i,
.nav-link i {
    font-size: 0.9rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.nav-menu a:hover,
.nav-box:hover {
    background: rgba(255,255,255,0.18);
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    border-color: rgba(255,255,255,0.25);
}

.nav-menu a.active,
.nav-box.active {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.5);
    border-color: rgba(255,255,255,0.4);
    transform: translateY(-2px);
}

.nav-menu a.active::before,
.nav-box.active::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 14px;
    z-index: -1;
    opacity: 0.6;
    filter: blur(10px);
}

/* Settings dropdown (desktop) */
.nav-settings-dropdown {
    position: relative;
}
.nav-settings-dropdown .nav-link.nav-box {
    cursor: pointer;
    border: none;
    font: inherit;
    display: inline-flex;
    align-items: center;
}
.nav-settings-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.35rem;
    min-width: 220px;
    max-height: min(380px, 70vh);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    padding: 0.5rem 0;
    z-index: 10002;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.nav-settings-dropdown.open .nav-settings-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.nav-settings-menu[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.nav-settings-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}
.nav-settings-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

/* More dropdown – keeps nav compact (e.g. 75% zoom); same pattern as Settings */
.nav-more-dropdown {
    position: relative;
}
.nav-more-dropdown .nav-more-btn {
    cursor: pointer;
    border: none;
    font: inherit;
    display: inline-flex;
    align-items: center;
    background: transparent;
    color: inherit;
    padding: inherit;
}
.nav-more-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.35rem;
    min-width: 200px;
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    padding: 0.5rem 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.nav-more-dropdown.open .nav-more-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.nav-more-menu[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.nav-more-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}
.nav-more-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}
.nav-more-item.active {
    background: rgba(59, 130, 246, 0.25);
    color: #fff;
}
.nav-settings-item i {
    width: 18px;
    text-align: center;
}

/* Mobile menu Settings group */
.nav-mobile-settings-wrap {
    width: 100%;
    position: relative;
    z-index: 2;
}
.nav-mobile-settings-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    cursor: pointer;
    background: transparent;
    border: none;
    color: inherit;
    font: inherit;
    text-align: left;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 0.95rem;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}
.nav-mobile-settings-btn:hover {
    background: rgba(255,255,255,0.1);
}
.nav-mobile-settings-btn i.fa-chevron-down {
    margin-left: auto;
    transition: transform 0.2s;
}
.nav-mobile-settings-wrap.open .nav-mobile-settings-btn i.fa-chevron-down {
    transform: rotate(180deg);
}
.nav-mobile-settings-sub {
    display: none;
    padding: 0.35rem 0 0 0.5rem;
    border-left: 2px solid rgba(255,255,255,0.15);
    margin-left: 0.75rem;
    visibility: visible;
    opacity: 1;
    min-height: 44px;
    max-height: min(320px, 55vh);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.nav-mobile-settings-wrap.open .nav-mobile-settings-sub {
    display: block;
    visibility: visible;
}
.nav-mobile-settings-sub a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 8px;
    margin-bottom: 0.25rem;
    min-height: 44px;
    box-sizing: border-box;
}
.nav-mobile-settings-sub a:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
.nav-mobile-settings-sub a:active {
    background: rgba(255,255,255,0.1);
}

/* Mobile: Settings panel opens from bottom (kinda), scrollable, visible in display */
@media (max-width: 992px) {
    .nav-settings-dropdown .nav-settings-menu {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        margin: 0;
        max-height: 65vh;
        border-radius: 16px 16px 0 0;
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
        overflow-x: hidden;
    }
    .nav-mobile-settings-sub {
        max-height: min(320px, 55vh);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    order: 3;
    margin-left: auto;
}

.mobile-menu-toggle span {
    width: 100%;
    height: 3px;
    background: #fff;
    border-radius: 3px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.nav-link-logout {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(220, 38, 38, 0.25));
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.4);
    margin-left: auto;
}

.nav-link-logout:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.35), rgba(220, 38, 38, 0.35));
    color: #fff;
    border-color: rgba(239, 68, 68, 0.6);
}

.nav-link-logout.active {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-color: rgba(255,255,255,0.4);
}

@media (max-width: 1200px) {
    .nav-menu {
        gap: 0.5rem;
    }
    
    .nav-menu a,
    .nav-link {
        padding: 0.55rem 0.9rem;
        font-size: 0.8rem;
    }
    
    .nav-menu a i,
    .nav-link i {
        font-size: 0.85rem;
        width: 16px;
    }
}

@media (max-width: 968px) {
    .mobile-menu-toggle {
        display: flex !important;
        flex-shrink: 0;
        min-width: 44px;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .nav-menu-left,
    .nav-menu-right {
        display: none !important;
    }
    
    .nav-menu-mobile {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(180deg, #374151 0%, #1f2937 100%);
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
        z-index: 1000;
    }
    
    .nav-menu-mobile.mobile-menu-open {
        max-height: min(600px, 75vh);
        padding: 0.75rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-menu-mobile a,
    .nav-menu-mobile .nav-link {
        width: 100%;
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
        justify-content: flex-start;
        border-radius: 8px;
    }
    
    .nav-brand-center {
        flex: 1;
        text-align: center;
    }
    
    .nav-brand-center h2 {
        font-size: 1rem;
        justify-content: center;
    }
    
    .admin-nav .container {
        padding: 1rem;
    }
    
    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        padding: 1rem;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
        z-index: 1000;
    }
    
    .nav-menu.mobile-menu-open {
        max-height: min(600px, 75vh);
        padding: 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-menu a,
    .nav-link {
        width: 100%;
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
        justify-content: flex-start;
        border-radius: 8px;
    }
    
    .nav-link span {
        display: inline;
    }
    
    .nav-link i {
        font-size: 1rem;
        width: 20px;
    }
    
    .nav-link-logout {
        margin-left: 0;
        margin-top: 0.5rem;
        order: 999;
    }
    
    .nav-brand h2 {
        font-size: 1rem;
    }
}

.admin-footer {
    background: var(--text-dark);
    color: #fff;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 4rem;
}

/* Orders Table Container */
.orders-table-container {
    overflow-x: visible;
    margin-top: 1rem;
    width: 100%;
    max-width: 100%;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

/* Alert Messages */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #86efac;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Filters */
.filters {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.filter-form .form-row {
    margin-bottom: 0;
    align-items: end;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.3s;
}

.pagination button:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.pagination span {
    color: var(--text-dark);
    font-weight: 500;
}

/* Admin Sidebar */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    background: var(--text-dark);
    color: #fff;
    padding: 1.5rem 0;
}

.admin-sidebar .logo {
    padding: 0 1.5rem;
    margin-bottom: 2rem;
}

.admin-sidebar .logo h2 {
    color: #fff;
    font-size: 1.25rem;
}

.admin-menu {
    list-style: none;
}

.admin-menu li {
    margin: 0;
}

.admin-menu a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: #fff;
    text-decoration: none;
    transition: background 0.3s;
}

.admin-menu a:hover,
.admin-menu a.active {
    background: rgba(255,255,255,0.1);
}

.admin-content {
    flex: 1;
    background: var(--bg-light);
}


/* Timeline Edit Notes Styles */
.timeline-item { position: relative; padding: 1rem; margin-bottom: 1rem; background: #fff; border: 1px solid var(--border-color); border-radius: 8px; transition: all 0.3s ease; }
.timeline-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.timeline-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.timeline-status { font-weight: 600; color: var(--primary-color); font-size: 1.1rem; margin-bottom: 0.25rem; }
.timeline-date { font-size: 0.875rem; color: var(--text-light); margin-bottom: 0.25rem; }
.timeline-user { font-size: 0.875rem; color: var(--text-light); }
.btn-edit-notes { background: var(--primary-color); color: white; border: none; border-radius: 6px; padding: 0.5rem 0.75rem; cursor: pointer; transition: all 0.3s ease; font-size: 0.875rem; display: flex; align-items: center; gap: 0.25rem; }
.btn-edit-notes:hover { background: var(--secondary-color); transform: translateY(-2px); box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3); }
.timeline-notes-display { margin-top: 0.75rem; }
.timeline-notes { background: #f0f9ff; padding: 0.75rem; border-radius: 6px; border-left: 3px solid var(--primary-color); color: var(--text-dark); line-height: 1.6; }
.timeline-notes-empty { color: var(--text-light); font-style: italic; font-size: 0.875rem; }
.timeline-notes-edit { margin-top: 0.75rem; }
.edit-notes-textarea { width: 100%; padding: 0.75rem; border: 2px solid var(--border-color); border-radius: 6px; font-family: inherit; font-size: 0.95rem; resize: vertical; transition: border-color 0.3s; }
.edit-notes-textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.edit-notes-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
.update-status-section { background: #fff; padding: 1.5rem; border-radius: 8px; border: 1px solid var(--border-color); margin-top: 1.5rem; }
.update-status-section h3 { margin-bottom: 1rem; color: var(--primary-color); display: flex; align-items: center; gap: 0.5rem; }
.status-form .form-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 1rem; align-items: end; }
.status-form .form-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: var(--text-dark); }
.status-form textarea { width: 100%; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 6px; font-family: inherit; resize: vertical; }
.status-form textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.status-form small { display: block; margin-top: 0.25rem; color: var(--text-light); font-size: 0.8rem; }
/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Status Form */
    .status-form .form-row {
        grid-template-columns: 1fr;
    }
    
    .timeline-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-edit-notes {
        align-self: flex-end;
    }
    
    /* Page Content */
    .page-content {
        padding: 0.75rem;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .page-header h1 {
        font-size: 1.25rem;
    }
    .page-header .btn {
        width: 100%;
    }
    .action-buttons {
        flex-direction: column;
    }
    .action-buttons .btn,
    .action-buttons .btn-sm {
        width: 100%;
        min-width: 100%;
    }
    
    /* Content Cards */
    .content-card {
        padding: 1rem;
        margin-bottom: 1rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Tables - Make scrollable */
    .data-table,
    .orders-table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
    }
    
    .data-table {
        min-width: 600px; /* Minimum width for table content */
    }
    
    .data-table thead,
    .data-table tbody,
    .data-table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
        font-size: 0.85rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Order Details Grid */
    .order-details-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Order Sections */
    .order-section {
        padding: 1rem;
        margin-bottom: 1rem;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    /* Items List - Prevent overflow */
    .order-items-list,
    .items-list {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .order-item {
        min-width: 100%;
        box-sizing: border-box;
        padding: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .item-row {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .item-row .form-group {
        width: 100%;
    }
    
    /* Status Invoice Grid */
    .status-invoice-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Filters */
    .filter-form .form-row {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .filter-form .form-group {
        width: 100%;
    }
    
    .filter-form button,
    .filter-form a {
        width: 100%;
    }
    
    /* Buttons */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 44px; /* Better touch target */
        width: auto;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-height: 36px;
    }
    
    /* Form Groups */
    .form-group {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Info Boxes */
    .info-box {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    .info-row {
        padding: 0.5rem 0;
        font-size: 0.9rem;
        word-wrap: break-word;
    }
    
    /* Timeline */
    .timeline-item {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Navigation Menu - Fix for mobile */
    .admin-nav {
        position: relative;
        z-index: 1000;
    }
    
    .admin-nav .container {
        position: relative;
        padding: 1rem;
        flex-wrap: wrap;
    }
    
    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        padding: 0;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
        z-index: 1001;
        margin: 0;
        order: 4;
    }
    
    .nav-menu.mobile-menu-open {
        max-height: 600px;
        padding: 1rem;
        overflow-y: auto;
    }
    
    .nav-link,
    .nav-menu a {
        width: 100%;
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
        justify-content: flex-start;
        border-radius: 8px;
        box-sizing: border-box;
        margin: 0;
    }
    
    .nav-link span {
        display: inline;
    }
    
    .nav-brand {
        flex: 1;
        min-width: 0;
    }
    
    .nav-brand h2 {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Ensure menu doesn't push content down */
    .page-content {
        margin-top: 0;
    }
    
    /* Modal Responsive */
    .modal-content {
        max-width: 100% !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    .modal-header {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .modal-header > div {
        width: 100%;
        justify-content: space-between;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 1rem 0;
    }
    
    .pagination span {
        width: 100%;
        text-align: center;
        order: -1;
    }
    
    /* Invoice Table Actions */
    .data-table td:last-child {
        white-space: nowrap;
    }
    
    .data-table td:last-child > div {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    /* Summary Cards */
    .summary-display-item {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
        width: 100%;
    }
    
    html {
        overflow-x: hidden;
    }
    
    * {
        max-width: 100%;
    }
    
    /* Fix for items going out of display */
    .items-section,
    .order-items-section {
        width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }
}

/* ============================================
   TABLE ALIGNMENT FIXES - ALL TABLES
   Ensures consistent professional layout
   ============================================ */

/* Apply to all tables: Orders, Invoices, Payment History, Order Items */
table.data-table,
.items-table-container table,
.payment-history-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

table.data-table th,
table.data-table td,
.items-table-container table th,
.items-table-container table td,
.payment-history-table th,
.payment-history-table td {
    padding: 12px;
    vertical-align: middle;
    text-align: left;
    white-space: normal;
    word-break: break-word;
}

/* Customer column - consistent wrapping */
table.data-table td.customer-col,
table.data-table th:nth-child(2),
table.data-table td:nth-child(2),
.items-table-container table td.customer-col,
.payment-history-table td.customer-col {
    max-width: 220px;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ============================================
   Order Details: Payment History & Order Items
   Any device: only table scrolls (horizontal);
   text never splits (no word in multiple rows)
   ============================================ */

/* Payment History - section stays fixed, only table scrolls horizontally */
.payment-history-section {
    width: 100%;
    overflow: visible;
    margin-top: 25px;
    margin-bottom: 0;
    padding-bottom: 0;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    display: block;
}

.payment-history-table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: #fff;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    display: block;
    -webkit-overflow-scrolling: touch;
}

/* Ensure table maintains minimum width based on column widths */
.payment-history-table-wrap .payment-history-table {
    min-width: 1240px; /* Sum of all column widths: 160+130+100+180+120+200+350 = 1240px */
}

.payment-history-table-wrap .payment-history-table {
    table-layout: fixed !important;
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    display: table !important;
}

/* Proper text wrapping - prevent letter-by-letter breaking, wrap whole words only */
.payment-history-table-wrap .payment-history-table th,
.payment-history-table-wrap .payment-history-table td {
    padding: 10px 12px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    line-height: 1.4;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
}

/* Header alignment */
.payment-history-table-wrap .payment-history-table th {
    text-align: left;
    font-weight: 600;
    background: var(--bg-light, #f9fafb);
    white-space: nowrap;
}

/* Column widths are now defined above with fixed pixel values */

.payment-history-table-wrap .payment-history-table tbody tr:last-child td {
    border-bottom: none;
}

.payment-history-table-wrap .payment-history-table thead {
    height: auto !important;
    min-height: 0 !important;
    display: table-header-group !important;
}

.payment-history-table-wrap .payment-history-table tbody {
    height: auto !important;
    min-height: 0 !important;
    display: table-row-group !important;
}

.payment-history-table-wrap .payment-history-table tbody tr {
    height: auto !important;
    min-height: 0 !important;
    display: table-row !important;
}

/* Ensure table cells don't have excessive height - CRITICAL */
.payment-history-table-wrap .payment-history-table th,
.payment-history-table-wrap .payment-history-table td {
    height: auto !important;
    min-height: 0 !important;
    max-height: fit-content !important;
    display: table-cell !important;
    vertical-align: top;
    padding: 10px 12px !important;
    line-height: 1.4 !important;
    box-sizing: border-box;
}

/* Prevent empty cells from expanding */
.payment-history-table-wrap .payment-history-table td:empty {
    height: auto !important;
    min-height: 0 !important;
    max-height: 1.4em !important;
    padding: 10px 12px !important;
}

/* Force payment history table to only take space of its content - CRITICAL FIX */
.payment-history-table-wrap .payment-history-table {
    height: auto !important;
    min-height: 0 !important;
    max-height: fit-content !important;
    table-layout: auto !important;
}

.payment-history-table-wrap .payment-history-table tbody {
    height: auto !important;
    min-height: 0 !important;
    max-height: fit-content !important;
}

.payment-history-table-wrap .payment-history-table tbody tr {
    height: auto !important;
    min-height: 0 !important;
    max-height: fit-content !important;
}

/* Ensure rows don't expand unnecessarily */
.payment-history-table-wrap .payment-history-table tbody tr td {
    height: auto !important;
    min-height: 0 !important;
    max-height: fit-content !important;
}

.payment-history-table-wrap .payment-history-table th {
    background: var(--bg-light, #f9fafb);
    font-weight: 600;
    white-space: nowrap;
}

/* Fixed column widths - similar to Orders table structure */
/* Date & Time: 160px */
.payment-history-table-wrap .payment-history-table th:nth-child(1),
.payment-history-table-wrap .payment-history-table td:nth-child(1) {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    white-space: nowrap;
    text-align: left;
}

/* Amount: 130px */
.payment-history-table-wrap .payment-history-table th:nth-child(2),
.payment-history-table-wrap .payment-history-table td:nth-child(2) {
    width: 130px;
    min-width: 130px;
    max-width: 130px;
    white-space: nowrap;
    text-align: right;
}

/* Mode: 100px */
.payment-history-table-wrap .payment-history-table th:nth-child(3),
.payment-history-table-wrap .payment-history-table td:nth-child(3) {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    white-space: nowrap;
    text-align: center;
}

/* Transaction ID: 180px */
.payment-history-table-wrap .payment-history-table th:nth-child(4),
.payment-history-table-wrap .payment-history-table td:nth-child(4) {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

/* Status: 120px */
.payment-history-table-wrap .payment-history-table th:nth-child(5),
.payment-history-table-wrap .payment-history-table td:nth-child(5) {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    white-space: nowrap;
    text-align: center;
}

/* Processed By: 200px */
.payment-history-table-wrap .payment-history-table th:nth-child(6),
.payment-history-table-wrap .payment-history-table td:nth-child(6) {
    width: 200px;
    min-width: 200px;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

/* Notes: 350px - wraps properly */
.payment-history-table-wrap .payment-history-table th:nth-child(7),
.payment-history-table-wrap .payment-history-table td:nth-child(7) {
    width: 350px;
    min-width: 350px;
    max-width: 350px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    text-align: left;
}

/* Order Items - responsive table, no horizontal scroll, proper wrapping */
.order-section .items-table-container {
    overflow-x: visible;
    overflow-y: visible;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: #fff;
}

.order-section .items-table-container table.data-table {
    table-layout: fixed;
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}

/* Proper text wrapping - allow wrapping for better fit */
.order-section .items-table-container table.data-table th,
.order-section .items-table-container table.data-table td {
    padding: 12px 14px;
    vertical-align: top;
    text-align: left;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.order-section .items-table-container table.data-table th {
    background: var(--bg-light, #f9fafb);
    font-weight: 600;
    white-space: nowrap;
}

/* Column widths (Order Items: S.No, Item Name, Status, Size, Paper Type, Color, Side, Binding, Qty, Rate, Amount) */
.order-section .items-table-container table.data-table th:nth-child(1),
.order-section .items-table-container table.data-table td:nth-child(1) { width: 5%; }  /* S.No */
.order-section .items-table-container table.data-table th:nth-child(2),
.order-section .items-table-container table.data-table td:nth-child(2) { width: 18%; } /* Item Name - wider for wrapping */
.order-section .items-table-container table.data-table th:nth-child(3),
.order-section .items-table-container table.data-table td:nth-child(3) { width: 15%; } /* Status - wider for badge + priority */
.order-section .items-table-container table.data-table th:nth-child(4),
.order-section .items-table-container table.data-table td:nth-child(4) { width: 8%; }   /* Size */
.order-section .items-table-container table.data-table th:nth-child(5),
.order-section .items-table-container table.data-table td:nth-child(5) { width: 10%; } /* Paper Type */
.order-section .items-table-container table.data-table th:nth-child(6),
.order-section .items-table-container table.data-table td:nth-child(6) { width: 7%; }  /* Color */
.order-section .items-table-container table.data-table th:nth-child(7),
.order-section .items-table-container table.data-table td:nth-child(7) { width: 8%; }  /* Side */
.order-section .items-table-container table.data-table th:nth-child(8),
.order-section .items-table-container table.data-table td:nth-child(8) { width: 8%; }  /* Binding */
.order-section .items-table-container table.data-table th:nth-child(9),
.order-section .items-table-container table.data-table td:nth-child(9) { width: 5%; }  /* Qty */
.order-section .items-table-container table.data-table th:nth-child(10),
.order-section .items-table-container table.data-table td:nth-child(10) { width: 5%; }  /* Ord */
.order-section .items-table-container table.data-table th:nth-child(11),
.order-section .items-table-container table.data-table td:nth-child(11) { width: 4%; }  /* Del */
.order-section .items-table-container table.data-table th:nth-child(12),
.order-section .items-table-container table.data-table td:nth-child(12) { width: 4%; }  /* Pend */
.order-section .items-table-container table.data-table th:nth-child(13),
.order-section .items-table-container table.data-table td:nth-child(13) { width: 9%; }  /* Physical delivery */
.order-section .items-table-container table.data-table th:nth-child(14),
.order-section .items-table-container table.data-table td:nth-child(14) { width: 6%; }  /* Mark */
.order-section .items-table-container table.data-table th:nth-child(15),
.order-section .items-table-container table.data-table td:nth-child(15) { width: 7%; }  /* Rate */
.order-section .items-table-container table.data-table th:nth-child(16),
.order-section .items-table-container table.data-table td:nth-child(16) { width: 8%; }  /* Amount */

/* Order items (order-details): allow natural column sizing + horizontal scroll — avoids crushed text / wrapped “Mark” */
.order-section .items-table-container table.order-items-table.data-table {
    table-layout: auto;
    min-width: 1180px;
}
.order-section .items-table-container table.order-items-table.data-table th,
.order-section .items-table-container table.order-items-table.data-table td {
    overflow: visible;
    text-overflow: clip;
}
.order-section .items-table-container table.order-items-table .item-status-select,
.order-section .items-table-container table.order-items-table .od-item-status-select {
    min-width: 10rem;
    max-width: min(16rem, 100%);
    box-sizing: border-box;
}
.order-section .items-table-container table.order-items-table .vp-pd-mark-btn {
    white-space: nowrap;
    min-width: 3.5rem;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
}
.order-section .items-table-container table.order-items-table td[data-label="Delivery"] {
    min-width: 7.5rem;
    vertical-align: middle;
}
.order-section .items-table-container table.order-items-table .vp-pd-badge {
    white-space: nowrap;
}

/* Undo generic nth-child % widths for this table so columns can size from content + min-width on table */
.order-section .od-items-table-container table.order-items-table thead th,
.order-section .od-items-table-container table.order-items-table tbody td {
    width: auto !important;
}

/* Override generic customer-col so these sections never wrap text */
.payment-history-table-wrap .payment-history-table td.customer-col,
.order-section .items-table-container table.data-table td.customer-col {
    max-width: none;
    word-break: keep-all;
    white-space: nowrap;
}

/* Small screens: compact padding, maintain proper wrapping */
@media (max-width: 768px) {
    .payment-history-table-wrap .payment-history-table th,
    .payment-history-table-wrap .payment-history-table td,
    .order-section .items-table-container table.data-table th,
    .order-section .items-table-container table.data-table td {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    /* Customer Information Section - Mobile Fixes */
    .info-row {
        word-break: keep-all !important;
        overflow-wrap: break-word !important;
        word-wrap: normal !important;
        white-space: normal !important;
        hyphens: none !important;
    }
    
    .info-row strong {
        word-break: keep-all !important;
        white-space: nowrap;
    }
    
    /* Mobile number - keep together */
    .info-row:has(strong:contains("Mobile")) {
        word-break: keep-all !important;
    }
    
    /* Buttons visibility on mobile */
    .page-header .btn,
    .page-header button {
        min-width: auto !important;
        white-space: nowrap !important;
        word-break: keep-all !important;
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
    }
    
    /* Payment History - Mobile */
    .payment-history-table-wrap {
        overflow-x: auto;
    }
    
    .payment-history-table-wrap .payment-history-table {
        min-width: 600px;
    }
    
    /* Ensure tables still fit without horizontal scroll */
    .payment-history-table-wrap,
    .order-section .items-table-container,
    .orders-table-container {
        overflow-x: visible;
    }
    
    /* Slightly adjust column widths on mobile for better fit */
    .order-section .items-table-container table.data-table th:nth-child(2),
    .order-section .items-table-container table.data-table td:nth-child(2) { width: 20%; } /* Item Name */
    .order-section .items-table-container table.data-table th:nth-child(3),
    .order-section .items-table-container table.data-table td:nth-child(3) { width: 18%; } /* Status */
    
    /* Customer Information Section - Mobile Fixes */
    .info-row {
        word-break: keep-all !important;
        overflow-wrap: break-word !important;
        word-wrap: normal !important;
        white-space: normal !important;
        hyphens: none !important;
    }
    
    .info-row strong {
        word-break: keep-all !important;
        white-space: nowrap;
        display: inline-block;
        min-width: 70px;
    }
    
    /* Mobile number - keep together, no letter breaking */
    .info-box .info-row {
        word-break: keep-all !important;
        overflow-wrap: break-word !important;
    }
    
    /* Buttons visibility on mobile */
    .page-header .btn,
    .page-header button,
    .page-header a.btn {
        min-width: auto !important;
        white-space: nowrap !important;
        word-break: keep-all !important;
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 0.25rem !important;
    }
    
    /* Payment History - Mobile responsive */
    .payment-history-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .payment-history-table-wrap .payment-history-table {
        min-width: 1240px; /* Maintain fixed column widths on mobile - horizontal scroll */
    }
}

    /* iPhone specific fixes */
@media (max-width: 480px) {
    .page-content {
        padding: 0.5rem;
    }
    
    .content-card {
        padding: 0.75rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.4rem;
        font-size: 0.8rem;
    }
    
    .btn {
        padding: 0.65rem 0.85rem;
        font-size: 0.85rem;
    }
    
    .modal-header h2 {
        font-size: 1rem;
    }
    
    .btn-text {
        display: none;
    }
    
    .btn i {
        margin: 0;
    }
}

/* Global mobile: reduce padding, fit to display, no content outside viewport */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        max-width: 100%;
        width: 100%;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }
    body {
        position: relative;
    }
    .ui-app-layout {
        max-width: 100%;
        overflow-x: hidden;
    }
    .page-content {
        padding: 6px 8px !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    .page-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 8px;
    }
    .page-header h1 {
        font-size: 1.15rem;
        word-break: break-word;
    }
    .content-card, .order-section, .card, .dashboard-section {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        padding: 8px 10px !important;
    }
    .data-table-wrapper, .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    /* Prevent truncation: allow wrap in table cells */
    .data-table td, .data-table th, .payment-history-table td, .payment-history-table th,
    table.data-table td, table.data-table th {
        word-break: break-word;
        overflow-wrap: break-word;
        min-width: 0;
    }
    .status-badge, .badge { white-space: normal !important; word-break: break-word; }
    /* Form and create order: full width on mobile */
    .form-group input, .form-group select, .form-group textarea,
    .order-form input, .order-form select, .order-form textarea,
    #loginForm input, #loginForm select, #loginForm textarea {
        max-width: 100%;
        box-sizing: border-box;
    }
    .order-form .content-card, .create-order .content-card, form.content-card {
        max-width: 100%;
        padding: 1rem;
    }
    /* Role badge / user label: don't cut off */
    .role-badge, .user-info .role-badge { max-width: 100%; overflow: visible; text-overflow: clip; }
}

@media (max-width: 480px) {
    .page-content { padding: 4px 6px !important; }
    .content-card, .order-section, .card, .dashboard-section { padding: 6px 8px !important; }
}

/* Mobile: force fit-to-display, no overflow (wins over other rules) */
@media (max-width: 768px) {
    body .ui-main,
    body .ui-main .page-content,
    body .ui-main .dashboard {
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    body .ui-main .dashboard .stat-card,
    body .ui-main .dashboard .dashboard-section,
    body .ui-main .content-card {
        max-width: 100% !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
    }
    body .ui-main .dashboard .data-table td,
    body .ui-main .dashboard .data-table th,
    body .ui-main .data-table td,
    body .ui-main .data-table th {
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }
}
