/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; background: #f0f2f5; color: #2d3748; }
a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a365d 0%, #2b6cb0 50%, #1a365d 100%);
}
.login-box {
  background: #fff; border-radius: 16px; padding: 40px; width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { text-align: center; margin-bottom: 30px; }
.logo-icon {
  width: 64px; height: 64px; background: linear-gradient(135deg, #2b6cb0, #63b3ed);
  border-radius: 16px; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; font-weight: 800; margin-bottom: 12px;
}
.login-logo h1 { font-size: 24px; font-weight: 700; color: #1a365d; }
.login-logo p { color: #718096; font-size: 13px; margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #4a5568; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid #e2e8f0; border-radius: 8px;
  transition: border-color 0.2s; outline: none; background: #f7fafc;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: #2b6cb0; background: #fff; box-shadow: 0 0 0 3px rgba(43,108,176,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.error-msg { color: #e53e3e; font-size: 13px; margin-bottom: 12px; text-align: center; }
.login-hint { margin-top: 20px; font-size: 11px; color: #a0aec0; text-align: center; line-height: 1.6; }

/* ===== BUTTONS ===== */
.btn-primary {
  padding: 10px 20px; background: linear-gradient(135deg, #2b6cb0, #3182ce);
  color: #fff; border: none; border-radius: 8px; cursor: pointer; font-weight: 600;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}
.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.btn-secondary {
  padding: 8px 16px; background: #edf2f7; color: #4a5568; border: 1.5px solid #e2e8f0;
  border-radius: 8px; cursor: pointer; font-weight: 500; transition: background 0.2s;
}
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger {
  padding: 8px 16px; background: #fff5f5; color: #e53e3e; border: 1.5px solid #fed7d7;
  border-radius: 8px; cursor: pointer; font-weight: 500;
}
.btn-danger:hover { background: #fed7d7; }
.btn-success {
  padding: 8px 16px; background: #f0fff4; color: #276749; border: 1.5px solid #9ae6b4;
  border-radius: 8px; cursor: pointer; font-weight: 500;
}
.btn-success:hover { background: #c6f6d5; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.full-width { width: 100%; padding: 12px; font-size: 15px; }

/* ===== APP SHELL ===== */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px; min-width: 240px; background: #1a365d; color: #e2e8f0;
  display: flex; flex-direction: column; transition: width 0.3s; overflow: hidden;
}
.sidebar.collapsed { width: 60px; min-width: 60px; }
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .brand-name,
.sidebar.collapsed .user-info > div,
.sidebar.collapsed .btn-logout { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.sidebar-header {
  display: flex; align-items: center; gap: 10px; padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo-sm {
  width: 36px; height: 36px; background: #2b6cb0; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff; flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 16px; color: #fff; }
.sidebar-toggle {
  margin-left: auto; background: none; border: none; color: #a0aec0;
  cursor: pointer; font-size: 18px; padding: 4px;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.nav-section { margin-bottom: 8px; }
.nav-label {
  display: block; font-size: 10px; font-weight: 700; color: #4a6fa5;
  padding: 8px 16px 4px; letter-spacing: 1px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  color: #a0aec0; border-radius: 0; transition: all 0.2s; cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(43,108,176,0.3); color: #63b3ed; border-left-color: #63b3ed; }
.nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 34px; height: 34px; background: #2b6cb0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 14px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11px; color: #718096; }
.btn-logout {
  width: 100%; padding: 8px; background: rgba(229,62,62,0.15); color: #fc8181;
  border: 1px solid rgba(229,62,62,0.3); border-radius: 6px; cursor: pointer;
  font-size: 12px; transition: background 0.2s;
}
.btn-logout:hover { background: rgba(229,62,62,0.25); }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: #fff; border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.page-title { font-size: 18px; font-weight: 700; color: #1a365d; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-date { font-size: 12px; color: #718096; }
.topbar-company { font-size: 12px; font-weight: 600; color: #2b6cb0; }
.module-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ===== CARDS & STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08); border-left: 4px solid transparent;
}
.stat-card.blue { border-left-color: #2b6cb0; }
.stat-card.green { border-left-color: #38a169; }
.stat-card.orange { border-left-color: #dd6b20; }
.stat-card.red { border-left-color: #e53e3e; }
.stat-card.purple { border-left-color: #805ad5; }
.stat-number { font-size: 28px; font-weight: 800; color: #1a365d; }
.stat-label { font-size: 12px; color: #718096; margin-top: 4px; font-weight: 500; }
.stat-trend { font-size: 11px; margin-top: 8px; }
.stat-trend.up { color: #38a169; }
.stat-trend.down { color: #e53e3e; }

/* ===== SECTION CARD ===== */
.section-card {
  background: #fff; border-radius: 12px; padding: 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08); margin-bottom: 20px;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0;
}
.section-title { font-size: 15px; font-weight: 700; color: #1a365d; }
.section-actions { display: flex; gap: 8px; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f7fafc; padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700; color: #4a5568; text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 1px solid #e2e8f0; white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
tbody tr:hover { background: #f7fafc; }
tbody tr:last-child td { border-bottom: none; }
.td-actions { display: flex; gap: 6px; }

/* ===== BADGES / STATUS ===== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-draft { background: #f0f2f5; color: #718096; }
.badge-pending { background: #fffaf0; color: #c05621; border: 1px solid #fbd38d; }
.badge-approved { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }
.badge-rejected { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }
.badge-ordered { background: #ebf8ff; color: #2c5282; border: 1px solid #bee3f8; }
.badge-received { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }
.badge-partial { background: #fff8e1; color: #b7791f; border: 1px solid #fae29f; }
.badge-closed { background: #e9d8fd; color: #553c9a; border: 1px solid #d6bcfa; }
.badge-cancelled { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }
.badge-paid { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }
.badge-unpaid { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }
.badge-inprogress { background: #ebf8ff; color: #2c5282; border: 1px solid #bee3f8; }
.badge-completed { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }

/* ===== FORM LAYOUT ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.required::after { content: ' *'; color: #e53e3e; }

/* ===== LINE ITEMS TABLE ===== */
.line-items-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.line-items-table th { background: #edf2f7; padding: 8px 10px; font-size: 12px; font-weight: 600; text-align: left; border: 1px solid #e2e8f0; }
.line-items-table td { padding: 6px 8px; border: 1px solid #e2e8f0; }
.line-items-table input, .line-items-table select {
  width: 100%; padding: 5px 8px; border: 1px solid #e2e8f0; border-radius: 4px;
  background: #f7fafc; outline: none;
}
.line-items-table input:focus, .line-items-table select:focus { border-color: #2b6cb0; background: #fff; }

/* ===== SEARCH & FILTERS ===== */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-input {
  padding: 8px 14px; border: 1.5px solid #e2e8f0; border-radius: 8px;
  outline: none; min-width: 200px; background: #f7fafc;
}
.search-input:focus { border-color: #2b6cb0; background: #fff; }
.filter-select {
  padding: 8px 14px; border: 1.5px solid #e2e8f0; border-radius: 8px; outline: none; background: #f7fafc;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: #fff; border-radius: 14px; width: 700px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-box.wide { width: 900px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: #1a365d; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #718096; line-height: 1; }
.modal-close:hover { color: #e53e3e; }
#modalBody { padding: 24px; }

/* ===== DASHBOARD QUICK ACTIONS ===== */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.qa-card {
  background: #fff; border-radius: 10px; padding: 16px; text-align: center;
  cursor: pointer; transition: all 0.2s; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1.5px solid #e2e8f0;
}
.qa-card:hover { border-color: #2b6cb0; box-shadow: 0 4px 12px rgba(43,108,176,0.15); transform: translateY(-2px); }
.qa-icon { font-size: 28px; margin-bottom: 8px; }
.qa-label { font-size: 12px; font-weight: 600; color: #4a5568; }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert-info { background: #ebf8ff; color: #2c5282; border: 1px solid #bee3f8; }
.alert-success { background: #f0fff4; color: #276749; border: 1px solid #9ae6b4; }
.alert-warning { background: #fffaf0; color: #744210; border: 1px solid #fbd38d; }
.alert-danger { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 24px; color: #a0aec0; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== DETAIL VIEW ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.detail-item label { display: block; font-size: 11px; font-weight: 700; color: #718096; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.detail-item span { font-size: 14px; font-weight: 500; color: #2d3748; }

/* ===== TALLY ===== */
.tally-section { background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.tally-code { background: #1a365d; color: #63b3ed; padding: 16px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 12px; white-space: pre; overflow-x: auto; max-height: 300px; overflow-y: auto; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: #718096; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all 0.2s;
}
.tab-btn.active { color: #2b6cb0; border-bottom-color: #2b6cb0; font-weight: 700; }
.tab-btn:hover:not(.active) { color: #4a5568; background: #f7fafc; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 100; height: 100vh; transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== PRINT ===== */
@media print {
  .sidebar, .topbar, .section-actions, .td-actions, .filter-bar, .modal-overlay { display: none !important; }
  .main-content { margin: 0; }
  .section-card { box-shadow: none; border: 1px solid #e2e8f0; }
}

/* ===== APPROVAL BADGE ===== */
.approval-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: #e53e3e; color: #fff; border-radius: 10px;
  font-size: 10px; font-weight: 700; margin-left: 4px;
  animation: pulse-badge 1.5s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.8; transform: scale(1.1); }
}

/* ===== PROJECT PRIORITY CHIPS ===== */
.priority-low      { color: #718096; }
.priority-normal   { color: #2b6cb0; }
.priority-high     { color: #dd6b20; }
.priority-critical { color: #e53e3e; font-weight: 700; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f0f2f5; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* ===== TOTALS ROW ===== */
.totals-section { background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px 18px; margin-top: 12px; }
.total-row { display: flex; justify-content: space-between; padding: 4px 0; }
.total-row.grand { border-top: 2px solid #2b6cb0; margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 16px; color: #1a365d; }

/* ===== NUMBER FORMATTING ===== */
.currency::before { content: '₹ '; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #718096; font-size: 12px; }
.fw-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
