@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #f2f1ee;
  --bg-2: #e7e3dd;
  --ink: #1d1d1b;
  --muted: #6f6b65;
  --card: #ffffff;
  --line: #d7d2cb;
  --accent: #1f6f78;
  --accent-2: #d9783a;
  --danger: #b5453b;
  --success: #2f7a4f;
  --shadow: 0 18px 40px rgba(27, 23, 16, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 700px at 10% -10%, #f6ede2 0%, transparent 60%),
    radial-gradient(1200px 700px at 110% 10%, #e6f2f1 0%, transparent 55%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand .mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #134d53);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.select {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  background: #fff;
  min-width: 180px;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.button.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.danger {
  background: #fdf2f1;
  color: var(--danger);
  border: 1px solid #f1c0bc;
}

.button.ghost {
  background: transparent;
  color: var(--ink);
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding: 24px 28px 40px;
}

.sidebar {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  height: fit-content;
}

.nav-group {
  margin-bottom: 24px;
}

.nav-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}

.nav a {
  display: block;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 500;
  color: var(--muted);
}

.nav a.active,
.nav a:hover {
  color: var(--ink);
  background: #f5f1ec;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 22px;
}

.subtle {
  color: var(--muted);
  font-size: 14px;
}

.stats-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat {
  padding: 18px;
  border-radius: var(--radius-sm);
  background: #faf8f4;
  border: 1px solid var(--line);
}

.stat .label {
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.stat .value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
}

body[data-page="dashboard"] {
  background: linear-gradient(180deg, #f4f6fb 0%, #edf1f7 100%);
}

body[data-page="dashboard"] .topbar {
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.08);
  border-bottom: 0;
}

body[data-page="dashboard"] .shell {
  gap: 28px;
}

body[data-page="dashboard"] .dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
}

body[data-page="dashboard"] .dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

body[data-page="dashboard"] .dashboard-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

body[data-page="dashboard"] .dashboard-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

body[data-page="dashboard"] .dashboard-search {
  display: flex;
  align-items: center;
  gap: 8px;
}

body[data-page="dashboard"] .dashboard-search .input {
  border-radius: 12px;
  min-width: 220px;
}

body[data-page="dashboard"] .sidebar {
  background: linear-gradient(180deg, #2e3542 0%, #1c222c 100%);
  color: #eef2f7;
  box-shadow: 0 18px 40px rgba(8, 12, 18, 0.35);
}

body[data-page="dashboard"] .nav-title {
  color: rgba(255, 255, 255, 0.6);
}

body[data-page="dashboard"] .nav a {
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
}

body[data-page="dashboard"] .nav a.active,
body[data-page="dashboard"] .nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

body[data-page="dashboard"] .card {
  border-radius: 18px;
  box-shadow: 0 16px 30px rgba(17, 24, 39, 0.08);
}

body[data-page="dashboard"] .stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

body[data-page="dashboard"] .stat {
  padding: 18px 20px;
  border: 0;
  color: #fff;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  display: block;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

body[data-page="dashboard"] .stat .label {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}

body[data-page="dashboard"] .stat .value {
  font-size: 34px;
  margin-top: 10px;
}

body[data-page="dashboard"] .stat-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

body[data-page="dashboard"] .stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-weight: 700;
}

body[data-page="dashboard"] .stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

body[data-page="dashboard"] .stat--repairs {
  background: linear-gradient(135deg, #d9414f 0%, #b62537 100%);
}

body[data-page="dashboard"] .stat--customers {
  background: linear-gradient(135deg, #2c6dd6 0%, #1d4ea8 100%);
}

body[data-page="dashboard"] .stat--vehicles {
  background: linear-gradient(135deg, #39b86a 0%, #1f7f46 100%);
}

body[data-page="dashboard"] .stat--alerts {
  background: linear-gradient(135deg, #f39a32 0%, #d9701e 100%);
}

body[data-page="dashboard"] .stat--ca-day,
body[data-page="dashboard"] .stat--ca-month {
  background: linear-gradient(135deg, #3a4151 0%, #222a36 100%);
}

body[data-page="dashboard"] .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

body[data-page="dashboard"] .segmented {
  display: inline-flex;
  background: #f3f5f9;
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

body[data-page="dashboard"] .segmented-btn {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  color: #677086;
  cursor: pointer;
}

body[data-page="dashboard"] .segmented-btn.active {
  background: #fff;
  color: #1e2a39;
  box-shadow: 0 6px 10px rgba(30, 42, 57, 0.1);
}

body[data-page="dashboard"] .chart-wrapper {
  background: linear-gradient(180deg, rgba(111, 179, 255, 0.14), rgba(111, 179, 255, 0.02));
  border-radius: 14px;
  padding: 12px;
}

body[data-page="dashboard"] .chart-wrapper svg {
  width: 100%;
  height: 180px;
}

body[data-page="dashboard"] .mini-stats {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

body[data-page="dashboard"] .mini-stat {
  background: #f6f8fc;
  padding: 12px 14px;
  border-radius: 12px;
}

body[data-page="dashboard"] .mini-label {
  font-size: 12px;
  color: #7a8396;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

body[data-page="dashboard"] .mini-value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 6px;
}

body[data-page="dashboard"] .list-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body[data-page="dashboard"] .list-empty {
  color: #7a8396;
  font-size: 14px;
}

body[data-page="dashboard"] .calendar-card {
  background: #ffffff;
}

body[data-page="dashboard"] .calendar-mini {
  background: #f7f8fb;
  border-radius: 12px;
  padding: 12px;
}

body[data-page="dashboard"] .calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

body[data-page="dashboard"] .calendar-title {
  font-weight: 600;
  color: #2c3543;
}

body[data-page="dashboard"] .calendar-grid-mini {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  text-align: center;
  font-size: 12px;
}

body[data-page="dashboard"] .calendar-day {
  color: #7a8396;
  font-weight: 600;
}

body[data-page="dashboard"] .calendar-cell-mini {
  background: #fff;
  padding: 6px 0;
  border-radius: 8px;
  color: #2c3543;
}

body[data-page="dashboard"] .calendar-cell-mini.active {
  background: #6f7cf5;
  color: #fff;
}

body[data-page="dashboard"] .activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

body[data-page="dashboard"] .activity-item {
  display: flex;
  gap: 12px;
  align-items: center;
}

body[data-page="dashboard"] .activity-dot {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
}

body[data-page="dashboard"] .activity-dot.blue { background: #4f7ded; }
body[data-page="dashboard"] .activity-dot.purple { background: #b076f0; }
body[data-page="dashboard"] .activity-dot.teal { background: #38b2ac; }

body[data-page="dashboard"] .activity-title {
  font-weight: 600;
  color: #2c3543;
}

body[data-page="dashboard"] .top-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

body[data-page="dashboard"] .top-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

body[data-page="dashboard"] .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eef1f6;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #2c3543;
}

body[data-page="dashboard"] .top-name {
  font-weight: 600;
}

@media (max-width: 1100px) {
  body[data-page="dashboard"] .dashboard-layout {
    grid-template-columns: 1fr;
  }
  body[data-page="dashboard"] .dashboard-search {
    display: none;
  }
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.table th {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f0ede7;
  color: var(--muted);
}

.badge.ok { background: #e3f3ea; color: var(--success); }
.badge.warn { background: #f7ece3; color: var(--accent-2); }
.badge.danger { background: #f7e4e2; color: var(--danger); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

.split {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
}

.detail-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: #fbfaf7;
}

.detail-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
  font-size: 14px;
}

.detail-grid dt { color: var(--muted); }

.media-checks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.media-checks span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
}

.media-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  margin-top: 10px;
}

.media-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
  font-size: 12px;
  color: var(--muted);
}

.media-card img {
  width: 100%;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}

.notice {
  padding: 12px 16px;
  border-radius: 12px;
  background: #f5f1ec;
  border: 1px solid var(--line);
  font-size: 14px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 92vw);
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 12px;
}

.login-card .brand {
  margin-bottom: 16px;
}

.login-card form {
  display: grid;
  gap: 12px;
}

.helper {
  font-size: 13px;
  color: var(--muted);
}

.ai-chat {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 320px;
  max-width: calc(100vw - 36px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat.collapsed .ai-chat-body,
.ai-chat.collapsed .ai-chat-footer {
  display: none;
}

.ai-chat-header {
  padding: 10px 14px;
  background: #f5f1ec;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.ai-chat-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.ai-chat-msg {
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.3;
}

.ai-chat-msg.user {
  background: #e9f0ee;
  align-self: flex-end;
}

.ai-chat-msg.bot {
  background: #f3e9df;
  align-self: flex-start;
}

.ai-chat-footer {
  border-top: 1px solid var(--line);
  padding: 8px;
  display: flex;
  gap: 8px;
}

.ai-chat-footer input {
  flex: 1;
}

.print-sheet {
  background: #fff;
  padding: 28px;
  color: #111;
  font-family: 'Space Grotesk', sans-serif;
}

.print-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #222;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.print-title {
  font-size: 22px;
  font-weight: 700;
}

.print-section {
  margin: 18px 0;
}

.print-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 8px 12px;
  font-size: 14px;
}

.print-lines {
  display: grid;
  gap: 8px;
}

.print-line {
  border-bottom: 1px dashed #999;
  height: 18px;
}

.checkbox-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.checkbox-box {
  width: 16px;
  height: 16px;
  border: 1.5px solid #333;
  display: inline-block;
  margin-right: 6px;
}

@media print {
  body { background: #fff; }
  .topbar, .sidebar, .button.print-hide { display: none !important; }
  .shell { grid-template-columns: 1fr; padding: 0; }
  .card { box-shadow: none; padding: 0; }
  .print-sheet { padding: 0; }
}

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar-actions { width: 100%; justify-content: space-between; flex-wrap: wrap; }
}
