/* ============================================================
   Delco Chimney Sweeps — Admin Panel Styles
   ============================================================ */
:root {
  --charcoal: #201a17;
  --ember: #d9481f;
  --ember-dark: #b83a17;
  --cream: #f6f2ee;
  --paper: #fff;
  --ink: #2b2420;
  --muted: #6b6058;
  --border: #e6ddd4;
  --success: #2f8f5b;
  --success-bg: #e6f4ec;
  --warn: #b8860b;
  --warn-bg: #fdf3d8;
  --danger: #c23b2f;
  --danger-bg: #fdeceb;
  --radius: 10px;
  --shadow-sm: 0 2px 10px rgba(32,26,23,0.06);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--cream); }
a { color: var(--ember); text-decoration: none; }
h1, h2, h3 { font-family: Georgia, serif; margin: 0 0 .4em; }
p { margin: 0 0 1em; }

/* Login screen */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--charcoal); }
.login-box { background: #fff; padding: 40px; border-radius: var(--radius); width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { font-family: Georgia, serif; font-weight: 700; text-align: center; margin-bottom: 18px; color: var(--charcoal); }
.login-logo span { color: var(--ember); }
.login-box h1 { text-align: center; font-size: 20px; margin-bottom: 20px; }
.login-back { text-align: center; margin-top: 16px; font-size: 13px; }

/* Shell layout */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 230px; background: var(--charcoal); color: #cfc5bc; display: flex; flex-direction: column; padding: 22px 16px; flex-shrink: 0; }
.admin-logo { color: #fff; font-family: Georgia, serif; font-weight: 700; padding: 0 6px 20px; font-size: 16px; }
.admin-logo span { color: #f0783a; }
.admin-sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.admin-sidebar nav a { color: #cfc5bc; padding: 10px 12px; border-radius: 8px; font-size: 14.5px; font-weight: 500; }
.admin-sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-sidebar nav a.active { background: var(--ember); color: #fff; }
.admin-sidebar-footer { border-top: 1px solid #3a3129; padding-top: 16px; margin-top: 16px; }
.admin-user { font-size: 13.5px; color: #fff; margin-bottom: 10px; }
.admin-user span { display: block; font-size: 11.5px; color: #a89e94; text-transform: uppercase; letter-spacing: .04em; }
.view-site-link { display: block; text-align: center; margin-top: 10px; font-size: 12.5px; color: #a89e94; }
.view-site-link:hover { color: #fff; }

.admin-main { flex: 1; padding: 30px 36px; max-width: 1200px; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; flex-wrap: wrap; gap: 12px; }
.admin-topbar h1 { font-size: 24px; margin: 0; }

/* Cards / KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 30px; }
.kpi-card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.kpi-card .label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.kpi-card .value { font-size: 26px; font-weight: 700; color: var(--charcoal); }
.kpi-card.accent .value { color: var(--ember); }

.panel { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 24px; }
.panel h2 { font-size: 17px; margin-bottom: 16px; }

/* Buttons */
.btn { display: inline-block; padding: 10px 18px; border-radius: 7px; font-weight: 600; font-size: 14px; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--ember); color: #fff; }
.btn-primary:hover { background: var(--ember-dark); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--ember); color: var(--ember); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #f5c2bd; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th { text-align: left; padding: 10px 12px; background: #faf6f2; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); }
table.data-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover td { background: #fdf9f6; }
table.data-table .row-actions { display: flex; gap: 8px; }

/* Status badges */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-draft { background: #ece3db; color: #6b6058; }
.badge-sent { background: #dbe8fb; color: #1d5aa8; }
.badge-paid { background: var(--success-bg); color: var(--success); }
.badge-overdue { background: var(--danger-bg); color: var(--danger); }
.badge-void { background: #e6e0da; color: #857a6f; }
.badge-new { background: #dbe8fb; color: #1d5aa8; }
.badge-contacted { background: var(--warn-bg); color: var(--warn); }
.badge-scheduled { background: #e3ddfb; color: #5b3fa8; }
.badge-converted { background: var(--success-bg); color: var(--success); }
.badge-closed { background: #e6e0da; color: #857a6f; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 14.5px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ember); }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #b9e2c8; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f5c2bd; }
.alert-info { background: #dbe8fb; color: #1d5aa8; border: 1px solid #b9d3f5; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }

/* Line items table (invoice form) */
.line-items-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.line-items-table th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted); padding: 6px 8px; }
.line-items-table td { padding: 6px 8px; }
.line-items-table input { width: 100%; }
.line-items-table .qty-col { width: 80px; }
.line-items-table .price-col { width: 110px; }
.line-items-table .total-col { width: 110px; text-align: right; font-weight: 600; }
.line-items-table .remove-col { width: 36px; text-align: center; }

.totals-box { max-width: 320px; margin-left: auto; }
.totals-box .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14.5px; }
.totals-box .row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 17px; }

/* Printable invoice view */
.invoice-doc { background: #fff; max-width: 800px; margin: 0 auto; padding: 50px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.invoice-doc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; }
.invoice-doc-head h1 { font-size: 26px; margin: 0; }
.invoice-doc .co-name { font-weight: 700; font-size: 17px; color: var(--charcoal); }
.invoice-doc .meta-table { width: 100%; margin-bottom: 30px; }
.invoice-doc .meta-table td { padding: 3px 0; font-size: 14px; vertical-align: top; }
.invoice-doc table.items { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.invoice-doc table.items th { text-align: left; border-bottom: 2px solid var(--charcoal); padding: 8px; font-size: 12.5px; text-transform: uppercase; }
.invoice-doc table.items td { padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.invoice-doc table.items td.num, .invoice-doc table.items th.num { text-align: right; }
.invoice-actions { max-width: 800px; margin: 0 auto 20px; display: flex; gap: 10px; justify-content: flex-end; }

@media print {
  .admin-sidebar, .invoice-actions, .admin-topbar { display: none !important; }
  .admin-main { padding: 0; }
  body { background: #fff; }
  .invoice-doc { box-shadow: none; border: none; margin: 0; }
}

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .admin-sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .admin-sidebar-footer { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
