:root {
  --primary: #1e3468;
  --primary-light: #2c4a8c;
  --bg: #f4f6f5;
  --panel-bg: #ffffff;
  --border: #e2e5e4;
  --text: #1f2a24;
  --text-muted: #6b7770;
  --danger: #b3261e;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Layout */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
}
.sidebar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 12px;
}
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.sidebar nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 12px 20px;
  font-size: 0.95rem;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-weight: 600;
}
.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 0.85rem;
}
.sidebar-footer .user-name { margin-bottom: 6px; color: #fff; }
.sidebar-footer .logout-link { color: rgba(255,255,255,0.75); text-decoration: none; }
.sidebar-footer .logout-link:hover { text-decoration: underline; }

.main-content { flex: 1; padding: 32px 40px; max-width: 1200px; }

/* Page head */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 1.5rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f0f0f0; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

/* Panels */
.panel { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.panel-head a { color: var(--primary); text-decoration: none; font-size: 0.9rem; }
.section-title { font-size: 1rem; margin: 0 0 16px; color: var(--text); }
.section-heading { font-size: 1rem; margin: 24px 0 8px; color: var(--primary); }
.section-heading.small { font-size: 0.9rem; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.empty-row { text-align: center; color: var(--text-muted); padding: 24px; }
.row-actions a { margin-right: 10px; color: var(--primary); text-decoration: none; font-size: 0.85rem; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-draft { background: #eee; color: #555; }
.badge-sent { background: #fff3cd; color: #8a6300; }
.badge-accepted { background: #dbe3f2; color: #1e3468; }
.badge-declined { background: #f8d7da; color: #842029; }

/* Filter bar */
.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.filter-bar input, .filter-bar select { padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; }
.filter-bar input { flex: 1; }

/* Forms */
.form-panel { max-width: 900px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 8px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.form-field input, .form-field select, .form-field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
}
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* Line items table */
.line-items-table { width: 100%; border-collapse: collapse; margin-top: 12px; margin-bottom: 12px; }
.line-items-table th { text-align: left; font-size: 0.8rem; color: var(--text-muted); padding: 6px 8px; text-transform: uppercase; }
.line-items-table td { padding: 6px 8px; }
.line-items-table input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.88rem; }
.qty-input, .rate-input { width: 90px !important; }
.line-total-cell { font-weight: 600; white-space: nowrap; }
.btn-remove-row { background: none; border: none; color: var(--danger); font-size: 1.2rem; cursor: pointer; line-height: 1; }
.grand-total-row { text-align: right; font-size: 1.1rem; font-weight: 700; margin-top: 8px; color: var(--primary); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem; }
.alert-error { background: #f8d7da; color: #842029; }
.alert-success { background: #dbe3f2; color: #1e3468; }

.link-btn-danger { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.85rem; padding: 0; text-decoration: underline; }

/* Login page */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3468, #2c4a8c);
}
.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-box h1 { margin: 0 0 4px; font-size: 1.3rem; color: var(--primary); }
.login-sub { color: var(--text-muted); margin: 0 0 20px; font-size: 0.9rem; }
.login-box label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.login-box input { width: 100%; padding: 11px 12px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; }
.login-box button { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 0.95rem; }
.login-box button:hover { background: var(--primary-light); }

/* Quotation print view */
.quote-view-body { background: #eee; }
.toolbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 40px; background: #fff; border-bottom: 1px solid var(--border); }
.toolbar a { color: var(--primary); text-decoration: none; font-weight: 600; }
.quote-sheet {
  background: #fff;
  max-width: 800px;
  margin: 30px auto;
  padding: 50px 60px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.quote-logo { max-height: 70px; margin-bottom: 10px; }
.quote-header { text-align: center; border-bottom: 3px solid var(--primary); padding-bottom: 16px; margin-bottom: 20px; }
.quote-letterhead { width: 100%; height: auto; display: block; }
.quote-address { font-size: 0.85rem; color: var(--text-muted); }
.quote-title { text-align: center; font-weight: 700; font-size: 1rem; letter-spacing: 1px; margin: 4px 0; }
.quote-title.sub { color: var(--primary); }
.quote-meta { width: 100%; margin: 20px 0; font-size: 0.9rem; }
.quote-meta td { padding: 4px 0; }
.quote-greeting { font-size: 0.92rem; line-height: 1.6; }
.quote-items-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.quote-items-table th, .quote-items-table td { border: 1px solid var(--border); padding: 8px 10px; font-size: 0.88rem; text-align: left; }
.quote-items-table th { background: #f7f7f7; }
.quote-notes { font-size: 0.88rem; background: #f7f7f7; padding: 14px 16px; border-radius: 6px; line-height: 1.7; }
.quote-summary-table { width: 100%; max-width: 380px; margin-left: auto; border-collapse: collapse; margin-top: 10px; }
.quote-summary-table td { padding: 8px 10px; font-size: 0.9rem; border-bottom: 1px solid var(--border); }
.quote-summary-table td:last-child { text-align: right; }
.quote-summary-table .summary-grand-row td { border-top: 2px solid var(--primary); border-bottom: none; font-size: 1rem; padding-top: 10px; color: var(--primary); }
.quote-terms-list { font-size: 0.85rem; line-height: 1.7; padding-left: 22px; margin: 10px 0; }
.quote-terms-list li { margin-bottom: 8px; }
.quote-package-subhead { font-size: 0.9rem; font-weight: 600; margin: 4px 0 8px; }
.quote-package-list { font-size: 0.88rem; line-height: 1.7; padding-left: 22px; margin: 0 0 10px; }
.quote-package-list li { margin-bottom: 4px; }
.page-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: var(--text-muted); margin-top: 40px; padding-top: 10px; border-top: 1px solid var(--border); }
.quote-signature { margin-top: 30px; font-size: 0.9rem; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .main-content { padding: 20px; }
  .stat-grid, .form-grid { grid-template-columns: 1fr; }
  .quote-sheet { padding: 24px; margin: 0; }
}
