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

:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --border: #e2e5ea;
  --text-primary: #1a1d23;
  --text-secondary: #5a6275;
  --text-muted: #9399a8;
  --accent: #e8430a;
  --accent-hover: #c73808;
  --navy: #1a1d23;
  --urgent: #e8430a;
  --normal: #f5a623;
  --low: #27ae60;
  --status-pending: #5a6275;
  --status-progress: #2980b9;
  --status-done: #27ae60;
  --sidebar-width: 260px;
}

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

a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--navy); display: flex; align-items: center; gap: 20px;
  padding: 0 20px; z-index: 100;
}
.topbar-logo {
  font-family: 'Space Grotesk', sans-serif; font-weight: 700;
  font-size: 1.2rem; color: #fff; letter-spacing: -0.02em;
}
.topbar-logo span { color: var(--accent); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; font-size: 0.875rem; font-weight: 500;
  border: none; transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: rgba(255,255,255,0.7); border: 1px solid rgba(255,255,255,0.2); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.8125rem; }

/* ── Layout ──────────────────────────────────────── */
.main { margin-left: var(--sidebar-width); margin-top: 56px; min-height: calc(100vh - 56px); padding: 24px; }

.sidebar {
  position: fixed; top: 56px; left: 0; bottom: 0; width: var(--sidebar-width);
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px; overflow-y: auto;
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-label {
  font-size: 0.6875rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 8px; padding: 0 4px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px; color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 500; transition: background 0.12s, color 0.12s;
}
.sidebar-link:hover { background: var(--bg); color: var(--text-primary); }
.sidebar-link.active { background: #fff3f0; color: var(--accent); }
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Page header ─────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.5rem; font-weight: 700; }
.page-subtitle { color: var(--text-secondary); font-size: 0.875rem; margin-top: 2px; }

/* ── Week nav ─────────────────────────────────────── */
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-nav-date { font-weight: 600; font-size: 0.9375rem; min-width: 140px; text-align: center; }
.week-nav-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.12s;
}
.week-nav-btn:hover { background: var(--bg); }

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}

/* ── Calendar grid ────────────────────────────────── */
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 24px;
}
.calendar-header { background: var(--navy); color: rgba(255,255,255,0.5); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.calendar-header-cell { padding: 10px 8px; text-align: center; }
.calendar-day {
  border-right: 1px solid var(--border); min-height: 100px; position: relative;
  background: var(--surface); transition: background 0.1s;
}
.calendar-day:last-child { border-right: none; }
.calendar-day.has-today { background: #fff9f7; }
.calendar-day-number { font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); padding: 6px 8px 4px; }
.calendar-day.today .calendar-day-number { color: var(--accent); }
.calendar-day-jobs { padding: 0 6px 6px; display: flex; flex-direction: column; gap: 3px; }
.calendar-job-chip {
  font-size: 0.6875rem; padding: 2px 5px; border-radius: 4px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
  cursor: pointer;
}
.chip-pending { background: #f0f1f5; color: var(--text-secondary); }
.chip-in-progress { background: #e8f4fb; color: #2980b9; }
.chip-completed { background: #e8f6ee; color: #27ae60; }

/* ── Jobs table ───────────────────────────────────── */
.jobs-table { width: 100%; border-collapse: collapse; }
.jobs-table th {
  text-align: left; padding: 10px 14px; font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.jobs-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.jobs-table tr:last-child td { border-bottom: none; }
.jobs-table tr:hover td { background: #fafafc; }

/* ── Status badge ─────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.75rem; font-weight: 600; padding: 3px 8px; border-radius: 20px;
}
.status-pending { background: #f0f1f5; color: var(--status-pending); }
.status-in-progress { background: #e8f4fb; color: var(--status-progress); }
.status-completed { background: #e8f6ee; color: var(--status-done); }

/* ── Urgency dot ──────────────────────────────────── */
.urgency-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.urgency-high { background: var(--urgent); }
.urgency-normal { background: var(--normal); }
.urgency-low { background: var(--low); }

/* ── New job form (modal) ─────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(26,29,35,0.55);
  z-index: 200; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 12px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: var(--bg); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Form ─────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 0.875rem; font-family: inherit;
  background: var(--surface); color: var(--text-primary); outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 72px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Quick stats ──────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 1.75rem; font-weight: 700; }
.stat-sub { font-size: 0.75rem; color: var(--text-secondary); }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .calendar-grid { grid-template-columns: repeat(7, 1fr); }
  .calendar-day { min-height: 70px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .calendar-header { display: none; }
  .calendar-grid { grid-template-columns: repeat(7, 1fr); }
  .calendar-day { min-height: 60px; }
  .calendar-day-jobs { display: none; }
  .jobs-table thead { display: none; }
  .jobs-table td { display: block; padding: 4px 12px; }
  .jobs-table td:first-child { padding-top: 12px; }
  .jobs-table td:last-child { padding-bottom: 12px; }
  .jobs-table tr { border: 1px solid var(--border); border-radius: 8px; display: block; margin-bottom: 8px; }
}

/* ── Toast / notification ────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--navy);
  color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 0.875rem;
  font-weight: 500; z-index: 300; opacity: 0; transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }