/* ── AppApp CSS · Light Theme ────────────────────────────────────────────── */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f5;
  --border: #e2e5ed;
  --accent: #4f7df9;
  --accent-hover: #3b65d6;
  --accent-light: rgba(79,125,249,0.08);
  --accent-2: #7c6fcd;
  --success: #22c55e;
  --success-light: rgba(34,197,94,0.1);
  --warning: #f59e0b;
  --warning-light: rgba(245,158,11,0.1);
  --danger: #ef4444;
  --danger-light: rgba(239,68,68,0.08);
  --text: #1e293b;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --sidebar-w: 240px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  box-shadow: 1px 0 8px rgba(0,0,0,0.04);
}

.sidebar-brand {
  padding: 24px 20px 20px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 22px; color: var(--accent); }
.brand-logo { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.3px; color: var(--text); }

.sidebar-user {
  padding: 16px 20px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; flex-shrink: 0;
  color: #fff;
}
.user-name { font-weight: 500; font-size: 13px; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.nav-list { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; }
.nav-section {
  padding: 16px 20px 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--text-dim);
  text-decoration: none; transition: all 0.15s;
  border-left: 3px solid transparent;
  font-size: 13.5px;
}
.nav-link:hover, .nav-link.active {
  color: var(--accent);
  background: var(--accent-light);
  border-left-color: var(--accent);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.logout-btn {
  width: 100%; padding: 8px; background: transparent;
  border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 6px; cursor: pointer; font-family: inherit;
  font-size: 13px; transition: all 0.15s;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 32px;
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px;
}
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ── STAT CARDS ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 600; letter-spacing: -1px; }
.stat-value.blue { color: var(--accent); }
.stat-value.green { color: var(--success); }
.stat-value.yellow { color: var(--warning); }
.stat-value.purple { color: var(--accent-2); }

/* ── CARDS & PANELS ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 500; background: var(--surface-2);
}
.card-body { padding: 20px; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 10px 16px; text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  font-weight: 600; background: var(--surface-2);
}
td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-light); }

/* ── BADGES ── */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-pending { background: var(--warning-light); color: #b45309; }
.badge-confirmed { background: rgba(79,125,249,0.1); color: var(--accent); }
.badge-in_progress { background: rgba(124,111,205,0.12); color: var(--accent-2); }
.badge-done { background: var(--success-light); color: #16a34a; }
.badge-cancelled { background: var(--danger-light); color: var(--danger); }
.badge-admin { background: var(--danger-light); color: var(--danger); }
.badge-team { background: rgba(79,125,249,0.1); color: var(--accent); }
.badge-customer { background: var(--success-light); color: #16a34a; }
.badge-standard { background: var(--surface-2); color: var(--text-dim); }
.badge-high { background: var(--danger-light); color: var(--danger); }
.badge-urgent { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-low { background: var(--surface-2); color: var(--text-muted); }
.badge-normal { background: var(--surface-2); color: var(--text-dim); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500;
  text-decoration: none; transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--danger-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.form-control, .form-select {
  width: 100%; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: inherit; font-size: 14px;
  transition: border-color 0.15s;
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,125,249,0.12);
}
textarea.form-control { resize: vertical; min-height: 100px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.error-msg {
  background: var(--danger-light); border: 1px solid rgba(239,68,68,0.2);
  color: var(--danger); padding: 12px 16px; border-radius: 8px;
  margin-bottom: 20px; font-size: 13px;
}

/* ── ALERTS ── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 13px; }
.alert-danger { background: var(--danger-light); border: 1px solid rgba(239,68,68,0.2); color: var(--danger); }
.alert-success { background: var(--success-light); border: 1px solid rgba(34,197,94,0.2); color: #16a34a; }

/* ── LOGIN PAGE ── */
body.role-guest {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf8 50%, #f5f0ff 100%);
}
.login-box {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 44px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo .icon { font-size: 36px; color: var(--accent); display: block; }
.login-logo h1 { font-size: 24px; font-weight: 600; margin-top: 8px; color: var(--text); }
.login-logo p { color: var(--text-muted); font-size: 13px; }

/* ── FILTERS ── */
.filter-bar {
  display: flex; gap: 10px; align-items: flex-end;
  margin-bottom: 20px; flex-wrap: wrap;
}
.filter-bar .form-group { margin-bottom: 0; }

/* ── JOB CARDS ── */
.job-cards { display: grid; gap: 10px; }
.job-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
  text-decoration: none; color: var(--text);
  transition: all 0.15s;
  box-shadow: var(--shadow);
}
.job-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(79,125,249,0.12); transform: translateY(-1px); }
.job-card-date {
  min-width: 52px; text-align: center;
  background: var(--surface-2); border-radius: 8px; padding: 8px 4px;
}
.job-card-day { font-size: 22px; font-weight: 600; line-height: 1; color: var(--accent); }
.job-card-month { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.job-card-info { flex: 1; }
.job-card-title { font-weight: 500; margin-bottom: 2px; color: var(--text); }
.job-card-sub { font-size: 12px; color: var(--text-muted); }
.job-card-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* ── PROPERTY CARDS ── */
.property-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.property-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  text-decoration: none; color: var(--text);
  transition: all 0.15s; display: block;
  box-shadow: var(--shadow);
}
.property-card:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(79,125,249,0.12); transform: translateY(-2px); }
.property-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.property-card .address { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.property-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-dim); }

/* ── DETAIL VIEWS ── */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
.detail-field { margin-bottom: 16px; }
.detail-field label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.detail-field p { font-size: 14px; color: var(--text); }

/* ── CALENDAR ── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.cal-head {
  background: var(--surface-2);
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cal-day {
  background: var(--surface);
  min-height: 90px;
  padding: 6px;
  position: relative;
  display: flex;
  flex-direction: column;
}
.cal-empty { background: var(--surface-2); opacity: 0.5; }
.cal-today { background: rgba(79,125,249,0.05); }
.cal-today .cal-day-num { color: #fff; background: var(--accent); border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.cal-day-num {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 4px;
  padding: 2px 4px;
}
.cal-event {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 6px; border-radius: 4px;
  font-size: 10px; text-decoration: none; color: var(--text);
  margin-bottom: 2px; transition: background 0.15s; overflow: hidden;
}
.cal-event:hover { background: var(--accent-light); }
.cal-event-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.cal-event-pending .cal-event-dot { background: var(--warning); }
.cal-event-confirmed .cal-event-dot { background: var(--accent); }
.cal-event-in_progress .cal-event-dot { background: var(--accent-2); }
.cal-event-done .cal-event-dot { background: var(--success); }
.cal-event-cancelled .cal-event-dot { background: var(--text-muted); }
.cal-event-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event-more { font-size: 10px; color: var(--text-muted); padding: 1px 6px; }
.cal-add {
  position: absolute; bottom: 4px; right: 4px;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 14px; color: var(--text-muted); text-decoration: none;
  opacity: 0; transition: all 0.15s;
}
.cal-day:hover .cal-add { opacity: 1; }
.cal-add:hover { background: var(--accent); color: #fff; opacity: 1; }
.cal-has-jobs { border-left: 2px solid var(--accent); }

/* ── TIMELINE ── */
.timeline { position: relative; }
.timeline-item {
  display: flex; gap: 12px; position: relative;
  padding-bottom: 16px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 12px; top: 28px; bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-dot {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  z-index: 1;
}
.timeline-content { flex: 1; padding-top: 3px; }
.timeline-text { font-size: 13px; font-weight: 500; color: var(--text); }
.timeline-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .cal-day { min-height: 60px; }
  .cal-event-text { display: none; }
}

/* ── MONO ── */
.mono { font-family: 'DM Mono', monospace; }

/* ── DIVIDER ── */
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ── SECTION TITLE ── */
.section-title { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 14px; }

/* ── ACTIONS INLINE ── */
.actions { display: flex; gap: 6px; }
