:root {
  --green-dark: #1a5632;
  --green-mid: #2d8a4e;
  --green-light: #e8f5e9;
  --green-accent: #4caf50;
  --gold: #c8a951;
  --bg: #f5f7f4;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #5a6a5e;
  --border: #d4ddd6;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* Sidebar layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; min-width: 240px; background: var(--green-dark);
  color: white; display: flex; flex-direction: column;
  box-shadow: 2px 0 12px rgba(0,0,0,0.15); z-index: 50;
}
.sidebar-header {
  padding: 20px 16px; text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header img { height: 60px; margin-bottom: 6px; }
.sidebar-header h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: 0.5px; }
.sidebar-header p { opacity: 0.7; font-size: 0.75rem; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; color: rgba(255,255,255,0.75);
  text-decoration: none; font-weight: 600; font-size: 0.9rem;
  transition: all 0.15s; border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: white; }
.sidebar-nav a.active {
  background: rgba(255,255,255,0.12); color: white;
  border-left-color: var(--gold);
}
.sidebar-nav a .nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.75rem; opacity: 0.5; text-align: center;
}

.main-content { flex: 1; min-width: 0; overflow-y: auto; }

.page-header {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  color: white; padding: 20px 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; }
.page-header p { opacity: 0.85; font-size: 0.85rem; margin-top: 2px; }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 60;
  background: var(--green-dark); color: white; border: none;
  padding: 10px 12px; border-radius: 6px; font-size: 1.2rem; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
@media (max-width: 768px) {
  .sidebar { position: fixed; top: 0; left: -260px; height: 100vh; transition: left 0.3s; z-index: 100; }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: block; }
  .sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 99; }
  .sidebar-overlay.open { display: block; }
}

/* Legacy header hidden when using sidebar layout */
header { display: none; }

.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 60px; }

.tabs {
  display: flex; gap: 0; margin-bottom: 24px; background: var(--card);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.tab {
  flex: 1; padding: 14px 20px; text-align: center; cursor: pointer;
  font-weight: 600; font-size: 0.95rem; border: none; background: var(--card);
  color: var(--text-muted); transition: all 0.2s;
}
.tab:hover { background: var(--green-light); }
.tab.active { background: var(--green-dark); color: white; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); margin-bottom: 20px;
}
.card h2 {
  font-size: 1.1rem; color: var(--green-dark); margin-bottom: 16px;
  padding-bottom: 8px; border-bottom: 2px solid var(--green-light);
  display: flex; align-items: center; gap: 8px;
}
.card h2 .icon { font-size: 1.2rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.field input, .field select {
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 6px;
  font-size: 0.95rem; background: #fafbfa; transition: border-color 0.2s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--green-accent); background: white;
  box-shadow: 0 0 0 3px rgba(76,175,80,0.1);
}

.pricing-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #eef2ef;
}
.pricing-row:last-child { border-bottom: none; }
.pricing-row .label { color: var(--text-muted); font-size: 0.9rem; }
.pricing-row .value { font-weight: 600; font-size: 0.95rem; }
.pricing-row.total {
  border-top: 2px solid var(--green-dark); border-bottom: none;
  margin-top: 8px; padding-top: 14px;
}
.pricing-row.total .label { font-size: 1.05rem; color: var(--text); font-weight: 700; }
.pricing-row.total .value { font-size: 1.3rem; color: var(--green-dark); font-weight: 800; }

.visit-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 12px; }
.visit-table th {
  background: var(--green-dark); color: white; padding: 10px 8px;
  text-align: left; font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.visit-table td { padding: 10px 8px; border-bottom: 1px solid #eef2ef; }
.visit-table tr:hover { background: var(--green-light); }
.visit-table .amount { font-weight: 700; color: var(--green-dark); }

.quote-output {
  background: linear-gradient(135deg, #f8fdf8 0%, #eef5ee 100%);
  border: 2px solid var(--green-accent); border-radius: var(--radius);
  padding: 28px; margin-top: 20px;
}
.quote-output h3 {
  font-size: 1.15rem; color: var(--green-dark); margin-bottom: 16px;
  text-align: center;
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; border: none; border-radius: 8px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.btn-primary { background: var(--green-dark); color: white; }
.btn-primary:hover { background: var(--green-mid); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn-outline { background: transparent; color: var(--green-dark); border: 2px solid var(--green-dark); }
.btn-outline:hover { background: var(--green-light); }
.btn-danger { background: #c62828; color: white; }
.btn-danger:hover { background: #b71c1c; }

.actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.badge-green { background: #c8e6c9; color: #2e7d32; }
.badge-yellow { background: #fff9c4; color: #f9a825; }
.badge-red { background: #ffcdd2; color: #c62828; }
.badge-blue { background: #bbdefb; color: #1565c0; }

.tab-content { display: none; }
.tab-content.active { display: block; }

.discount-tag {
  display: inline-block; background: var(--gold); color: white;
  padding: 2px 8px; border-radius: 4px; font-size: 0.7rem;
  font-weight: 700; margin-left: 6px; vertical-align: middle;
}

.note {
  background: #fff8e1; border-left: 4px solid var(--gold);
  padding: 12px 16px; border-radius: 0 6px 6px 0;
  font-size: 0.85rem; color: #6d5c1e; margin-top: 16px;
}

.hidden { display: none; }

/* Customer search dropdown */
.customer-search-wrap { position: relative; }
.customer-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--card); border: 1.5px solid var(--border);
  border-top: none; border-radius: 0 0 6px 6px;
  max-height: 240px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.customer-dropdown .dd-item {
  padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
}
.customer-dropdown .dd-item:hover, .customer-dropdown .dd-item.active {
  background: var(--green-light);
}
.customer-dropdown .dd-item .dd-name { font-weight: 600; }
.customer-dropdown .dd-item .dd-detail { font-size: 0.78rem; color: var(--text-muted); }
.customer-dropdown .dd-item.dd-new {
  color: var(--green-dark); font-weight: 600;
  border-top: 2px solid var(--green-light);
}

.selected-customer {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--green-light); border-radius: 6px; margin-bottom: 12px;
}
.selected-customer .sc-info { flex: 1; }
.selected-customer .sc-name { font-weight: 700; color: var(--green-dark); }
.selected-customer .sc-detail { font-size: 0.8rem; color: var(--text-muted); }

/* Quote history */
.history-panel { margin-top: 20px; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--card); border-radius: 6px;
  margin-bottom: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  cursor: pointer; transition: all 0.15s;
}
.history-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); transform: translateY(-1px); }
.history-item .hi-left .hi-type { font-weight: 600; font-size: 0.9rem; }
.history-item .hi-left .hi-date { font-size: 0.78rem; color: var(--text-muted); }
.history-item .hi-right { text-align: right; }
.history-item .hi-total { font-weight: 700; color: var(--green-dark); }
.history-item .hi-status { font-size: 0.7rem; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1000; display: flex;
  align-items: center; justify-content: center;
}
.modal {
  background: var(--card); border-radius: var(--radius); padding: 28px;
  width: 90%; max-width: 500px; box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.modal h3 { color: var(--green-dark); margin-bottom: 16px; }
.modal .field { margin-bottom: 12px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  padding: 14px 24px; border-radius: 8px; color: white;
  font-weight: 600; font-size: 0.9rem; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}
.toast-success { background: var(--green-dark); }
.toast-error { background: #c62828; }
.toast-info { background: #1565c0; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }

/* Customer management table */
.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.toolbar .search-box {
  flex: 1; min-width: 200px; max-width: 400px;
  padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 6px;
  font-size: 0.95rem; background: #fafbfa;
}
.toolbar .search-box:focus { outline: none; border-color: var(--green-accent); box-shadow: 0 0 0 3px rgba(76,175,80,0.1); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--green-dark); color: white; padding: 12px 14px;
  text-align: left; font-weight: 600; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.data-table th:first-child { border-radius: 6px 0 0 0; }
.data-table th:last-child { border-radius: 0 6px 0 0; }
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid #eef2ef; font-size: 0.9rem;
}
.data-table tr:hover { background: var(--green-light); }
.data-table .actions-cell { white-space: nowrap; }
.data-table .actions-cell button {
  padding: 6px 10px; font-size: 0.78rem; margin-left: 4px;
}
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

.customer-stats {
  display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.stat-card {
  flex: 1; min-width: 140px; background: var(--card); border-radius: var(--radius);
  padding: 16px 20px; box-shadow: var(--shadow); text-align: center;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; color: var(--green-dark); }
.stat-card .stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px; }

/* Schedule calendar */
.view-toggle {
  display: flex; gap: 0; background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); margin-bottom: 20px;
}
.view-toggle .vt-btn {
  flex: 1; padding: 10px 16px; text-align: center; cursor: pointer;
  font-weight: 600; font-size: 0.85rem; border: none; background: var(--card);
  color: var(--text-muted); transition: all 0.2s;
}
.view-toggle .vt-btn:hover { background: var(--green-light); }
.view-toggle .vt-btn.active { background: var(--green-dark); color: white; }

.cal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.cal-header h2 { font-size: 1.15rem; color: var(--green-dark); }
.cal-header button {
  background: none; border: 1.5px solid var(--border); border-radius: 6px;
  padding: 6px 14px; cursor: pointer; font-size: 1rem; color: var(--text);
  transition: all 0.15s;
}
.cal-header button:hover { background: var(--green-light); border-color: var(--green-accent); }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  background: var(--border); border-radius: var(--radius); overflow: hidden;
}
.cal-day-header {
  background: var(--green-dark); color: white; padding: 8px 4px;
  text-align: center; font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.cal-day {
  background: var(--card); min-height: 80px; padding: 6px;
  cursor: pointer; transition: background 0.15s; position: relative;
}
.cal-day:hover { background: var(--green-light); }
.cal-day.other-month { background: #f0f2ef; color: #bbb; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--green-accent); }
.cal-day.selected { background: var(--green-light); box-shadow: inset 0 0 0 2px var(--green-dark); }
.cal-day .day-num {
  font-size: 0.8rem; font-weight: 600; margin-bottom: 4px;
}
.cal-day .day-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.cal-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.cal-dot.scheduled { background: var(--green-accent); }
.cal-dot.completed { background: #9e9e9e; }
.cal-dot.cancelled { background: #e57373; }

.cal-day-detail {
  margin-top: 16px;
}
.cal-day-detail h3 { font-size: 1rem; color: var(--green-dark); margin-bottom: 12px; }

.appt-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--card); border-radius: 6px;
  margin-bottom: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  border-left: 4px solid var(--green-accent);
}
.appt-card.status-completed { border-left-color: #9e9e9e; }
.appt-card.status-cancelled { border-left-color: #e57373; opacity: 0.7; }
.appt-card .appt-info { flex: 1; }
.appt-card .appt-customer { font-weight: 700; font-size: 0.9rem; }
.appt-card .appt-detail { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.appt-card .appt-actions { display: flex; gap: 4px; }

@media (max-width: 600px) {
  .cal-day { min-height: 50px; padding: 4px; }
  .cal-day .day-num { font-size: 0.7rem; }
}

@media print {
  .sidebar, .sidebar-toggle, .sidebar-overlay, .page-header, .tabs, .card:not(.quote-output), .actions, .note, .selected-customer, .history-panel, .toast, .toolbar { display: none !important; }
  .main-content { margin: 0; }
  .quote-output { border: 1px solid #ccc; box-shadow: none; margin: 0; }
  body { background: white; }
}
