/* =====================================================
   QMS — Light Theme  |  Clean & Professional
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary:       #E53935;
  --primary-dark:  #C62828;
  --primary-light: #FFEBEE;
  --dark:          #1A1A1A;
  --gray-700:      #424242;
  --gray-600:      #616161;
  --gray-400:      #BDBDBD;
  --gray-200:      #EEEEEE;
  --gray-100:      #F5F5F5;
  --gray-50:       #FAFAFA;
  --white:         #FFFFFF;
  --text:          #212121;
  --text-muted:    #757575;
  --border:        #E0E0E0;
  --border-light:  #F0F0F0;
  --surface:       #FFFFFF;
  --surface-2:     #FAFAFA;
  --success:       #2E7D32;
  --success-bg:    #E8F5E9;
  --warning:       #E65100;
  --warning-bg:    #FFF3E0;
  --danger:        #C62828;
  --danger-bg:     #FFEBEE;
  --info:          #1565C0;
  --info-bg:       #E3F2FD;
  --sidebar-width: 240px;
  --topnav-height: 58px;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:        0 2px 8px rgba(0,0,0,0.09), 0 1px 4px rgba(0,0,0,0.05);
  --shadow-lg:     0 4px 16px rgba(0,0,0,0.11);
  --transition:    all 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #F2F2F2;
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==================== LAYOUT ==================== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 1000;
  overflow-y: auto;
  transition: transform 0.25s ease;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px; border-bottom: 1px solid var(--border-light);
  min-height: var(--topnav-height);
}

.brand-icon {
  width: 32px; height: 32px;
  background: var(--primary); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: white; flex-shrink: 0;
}

.brand-name { font-size: 14px; font-weight: 700; color: var(--text); display: block; }
.brand-sub { font-size: 10px; color: var(--text-muted); }
.sidebar-toggle-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; margin-left: auto; }

.sidebar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px; border-bottom: 1px solid var(--border-light);
  background: var(--gray-50);
}

.user-avatar {
  width: 30px; height: 30px; background: var(--primary); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: white; flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; color: var(--text); display: block; }
.user-role { font-size: 10px; color: var(--text-muted); text-transform: capitalize; }

.sidebar-nav { flex: 1; padding: 6px 0; }
.nav-section { margin-bottom: 2px; }

.nav-label {
  font-size: 10px; font-weight: 600; color: var(--gray-400);
  text-transform: uppercase; letter-spacing: 0.7px;
  padding: 10px 14px 3px; display: block;
}

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; color: var(--gray-600);
  text-decoration: none; border-radius: 6px;
  margin: 1px 8px; font-size: 13px; font-weight: 500;
  transition: var(--transition); cursor: pointer;
}
.nav-item:hover { background: var(--gray-100); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item.active i { color: var(--primary); }
.nav-item i { font-size: 14px; flex-shrink: 0; color: var(--gray-400); transition: var(--transition); }
.nav-item:hover i { color: var(--gray-700); }
.sidebar-footer { padding: 6px 0; border-top: 1px solid var(--border-light); }

/* ==================== MAIN ==================== */
.main-content { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }

/* ==================== TOPNAV ==================== */
.topnav {
  height: var(--topnav-height); background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}

.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; }

.search-wrapper { flex: 1; max-width: 420px; position: relative; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: 13px; }

.global-search {
  width: 100%; background: var(--gray-50); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px 7px 30px;
  color: var(--text); font-size: 13px; outline: none;
  transition: var(--transition); font-family: 'Inter', sans-serif;
}
.global-search:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px rgba(229,57,53,0.08); }
.global-search::placeholder { color: var(--gray-400); }

.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 320px; overflow-y: auto; z-index: 999; display: none;
}
.search-result-item {
  padding: 9px 12px; display: flex; align-items: center; gap: 9px;
  cursor: pointer; text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--border-light); font-size: 13px; transition: var(--transition);
}
.search-result-item:hover { background: var(--gray-50); }
.search-result-item:last-child { border-bottom: none; }

.topnav-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.action-btn {
  width: 32px; height: 32px; background: var(--gray-50); border: 1px solid var(--border);
  border-radius: 6px; color: var(--gray-600); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; transition: var(--transition); position: relative;
}
.action-btn:hover { background: var(--gray-100); color: var(--text); }
.topnav-avatar {
  width: 28px; height: 28px; background: var(--primary); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; color: white;
}
.notif-badge {
  position: absolute; top: -4px; right: -4px; background: var(--primary); color: white;
  font-size: 9px; font-weight: 700; min-width: 16px; height: 16px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* ==================== PAGE ==================== */
.page-content { flex: 1; padding: 20px 22px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 18px; font-weight: 700; color: var(--text); margin: 0; }
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ==================== CARDS ==================== */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { background: transparent; border-bottom: 1px solid var(--border-light); padding: 13px 16px; display: flex; align-items: center; }
.card-header h5, .card-header h6 { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; }
.card-body { padding: 16px; }

/* ==================== KPI ==================== */
.kpi-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  position: relative; overflow: hidden;
  transition: var(--transition); box-shadow: var(--shadow-sm);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--primary); }
.kpi-card.success::before { background: var(--success); }
.kpi-card.warning::before { background: var(--warning); }
.kpi-card.info::before { background: var(--info); }
.kpi-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 5px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.kpi-change { font-size: 12px; color: var(--text-muted); }
.kpi-change.up { color: var(--success); }
.kpi-icon { position: absolute; right: 14px; top: 14px; width: 38px; height: 38px; background: var(--primary-light); border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; color: var(--primary); }
.kpi-card.success .kpi-icon { background: var(--success-bg); color: var(--success); }
.kpi-card.warning .kpi-icon { background: var(--warning-bg); color: var(--warning); }
.kpi-card.info .kpi-icon { background: var(--info-bg); color: var(--info); }

/* ==================== BUTTONS ==================== */
.btn { font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500; border-radius: 6px; padding: 7px 13px; transition: var(--transition); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary); color: white; }
.btn-dark-custom { background: var(--white); border: 1px solid var(--border); color: var(--gray-600); }
.btn-dark-custom:hover { background: var(--gray-50); color: var(--text); border-color: var(--gray-400); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-danger:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; }
.btn-warning { background: #E65100; border-color: #E65100; color: white; }

/* ==================== TABLES ==================== */
.table { color: var(--text); font-size: 13px; }
.table > :not(caption) > * > * { background: transparent; border-color: var(--border-light); }
.table thead th { background: var(--gray-50); color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody td { padding: 10px 14px; vertical-align: middle; }

/* ==================== FORMS ==================== */
.form-control, .form-select {
  background: var(--white); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 7px 10px; font-size: 13px;
  font-family: 'Inter', sans-serif; transition: var(--transition);
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(229,57,53,0.08); background: var(--white); color: var(--text); }
.form-control::placeholder { color: var(--gray-400); }
.form-label { font-size: 12px; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }
.input-group-text { background: var(--gray-50); border-color: var(--border); color: var(--gray-600); font-size: 13px; }

/* ==================== MODALS ==================== */
.modal-content { background: var(--white); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-lg); }
.modal-header { border-color: var(--border-light); padding: 14px 18px; }
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-footer { border-color: var(--border-light); padding: 12px 18px; }
.modal-body { padding: 16px 18px; }
.btn-close { opacity: 0.5; }

/* ==================== BADGES ==================== */
.badge { font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 4px; }
.bg-primary { background-color: var(--primary) !important; }
.bg-success { background-color: #2E7D32 !important; }
.bg-warning { background-color: #E65100 !important; }
.bg-danger { background-color: var(--danger) !important; }
.bg-info { background-color: var(--info) !important; }
.bg-secondary { background-color: #757575 !important; }
.bg-dark { background-color: #424242 !important; }

/* ==================== ALERTS ==================== */
.alert { border-radius: var(--radius); font-size: 13px; padding: 10px 14px; }
.alert-success { background: var(--success-bg); border-color: #A5D6A7; color: var(--success); }
.alert-danger { background: var(--danger-bg); border-color: #EF9A9A; color: var(--danger); }
.alert-warning { background: var(--warning-bg); border-color: #FFCC80; color: var(--warning); }
.alert-info { background: var(--info-bg); border-color: #90CAF9; color: var(--info); }

/* ==================== DROPDOWN ==================== */
.dropdown-menu { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 13px; }
.dropdown-item { color: var(--text); padding: 7px 14px; font-size: 13px; }
.dropdown-item:hover { background: var(--gray-50); color: var(--text); }
.dropdown-divider { border-color: var(--border-light); }

/* ==================== PAGINATION ==================== */
.pagination .page-link { background: var(--white); border-color: var(--border); color: var(--gray-600); font-size: 13px; }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }
.pagination .page-link:hover { background: var(--gray-100); color: var(--text); }

/* ==================== PROGRESS ==================== */
.progress { background: var(--gray-100); height: 6px; border-radius: 3px; }
.progress-bar { background: var(--primary); }

/* ==================== KANBAN ==================== */
.kanban-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px; }
.kanban-col { min-width: 248px; width: 248px; flex-shrink: 0; }
.kanban-col-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: var(--radius) var(--radius) 0 0; background: var(--white); border: 1px solid var(--border); border-bottom: none; }
.kanban-col-title { font-size: 12px; font-weight: 600; color: var(--text); }
.kanban-count { background: var(--gray-100); border-radius: 10px; padding: 2px 7px; font-size: 11px; font-weight: 600; color: var(--gray-600); }
.kanban-cards { background: var(--gray-50); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); padding: 8px; min-height: 380px; }
.kanban-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 7px; cursor: grab; transition: var(--transition); box-shadow: var(--shadow-sm); }
.kanban-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card-client { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 3px; }
.kanban-card-amount { color: var(--primary); font-weight: 700; font-size: 13px; }
.kanban-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.kanban-col-header.col-given { border-left: 3px solid var(--info); }
.kanban-col-header.col-followup { border-left: 3px solid var(--warning); }
.kanban-col-header.col-hold { border-left: 3px solid var(--gray-400); }
.kanban-col-header.col-won { border-left: 3px solid var(--success); }
.kanban-col-header.col-lost { border-left: 3px solid var(--danger); }
.kanban-col-header.col-cancelled { border-left: 3px solid var(--gray-400); }

/* ==================== NOTIFICATIONS ==================== */
.notification-dropdown { width: 320px; }
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 11px 15px; border-bottom: 1px solid var(--border-light); }
.notif-header h6 { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; }
.notif-item { padding: 9px 15px; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.notif-item.unread { background: var(--primary-light); }
.notif-item:last-child { border-bottom: none; }

/* ==================== ACTIVITY ==================== */
.activity-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.activity-dot { width: 8px; height: 8px; background: var(--primary); border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ==================== MOBILE ==================== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 999; }
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .page-content { padding: 14px 16px; }
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ==================== UTILITIES ==================== */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-info { color: var(--info) !important; }
.text-muted { color: var(--text-muted) !important; }

/* ==================== LOGIN ==================== */
.login-page { min-height: 100vh; background: #F2F2F2; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--white); border: 1px solid var(--border); border-radius: 16px; padding: 36px 32px; box-shadow: var(--shadow-lg); }
.login-logo { width: 44px; height: 44px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; color: white; margin: 0 auto 20px; }

/* ==================== MISC ==================== */
.auto-calculated { background: var(--success-bg) !important; color: var(--success) !important; font-weight: 600; border-color: #A5D6A7 !important; }
.price-display { font-weight: 700; color: var(--primary); }
.remove-item-btn { background: none; border: none; color: var(--danger); font-size: 16px; cursor: pointer; padding: 2px; }
.target-pct { font-size: 28px; font-weight: 700; color: var(--primary); }

/* Permissions table */
.perm-table th, .perm-table td { padding: 8px 12px; vertical-align: middle; font-size: 13px; }
.perm-table thead th { background: var(--gray-50); font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.perm-check { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ==================== QUOTATION ITEM INPUTS ==================== */
.quote-item-row td { padding: 6px 8px !important; vertical-align: middle; }
.item-qty-input   { width: 70px  !important; min-width: 70px;  text-align: center; font-size: 14px !important; padding: 8px 6px !important; }
.item-price-input { width: 110px !important; min-width: 110px; font-size: 14px !important; padding: 8px 8px !important; font-weight: 600; }
.item-gst-input   { width: 72px  !important; min-width: 72px;  text-align: center; font-size: 14px !important; padding: 8px 6px !important; }
.item-disc-input  { width: 72px  !important; min-width: 72px;  text-align: center; font-size: 14px !important; padding: 8px 6px !important; }
.item-name-input  { font-size: 13px !important; padding: 8px 10px !important; }
.item-model-input { font-size: 12px !important; padding: 6px 10px !important; color: var(--text-muted); }
.item-total-cell  { font-weight: 700; color: var(--primary); font-size: 14px; min-width: 90px; white-space: nowrap; }

/* Wider columns in the items table */
.items-table th:nth-child(1) { min-width: 200px; }
.items-table th:nth-child(2) { width: 80px; }
.items-table th:nth-child(3) { width: 120px; }
.items-table th:nth-child(4) { width: 80px; }
.items-table th:nth-child(5) { width: 80px; }
.items-table th:nth-child(6) { width: 110px; }
.items-table th:nth-child(7) { width: 40px; }

/* Kanban drag-over highlight */
.kanban-cards.drag-over { background: #EEF6FF; border: 2px dashed #1565C0; }
