:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #18202f;
  --muted: #6b7280;
  --border: #e5e7eb;
  --sidebar: #101827;
  --sidebar-soft: #1f2937;
  --primary: #2563eb;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

/* Sidebar */

.sidebar {
  width: 270px;
  min-height: 100vh;
  background: var(--sidebar);
  color: #fff;
  padding: 22px;
  flex-direction: column;
  position: sticky;
  top: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 28px;
}

.logo-icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.logo-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.logo-subtitle {
  color: #9ca3af;
  font-size: 13px;
  margin-top: 4px;
}

.sidebar-nav,
.mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link-custom {
  width: 100%;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  padding: 13px 14px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  text-align: left;
  transition: 0.15s ease;
}

.nav-link-custom i {
  font-size: 18px;
}

.nav-link-custom:hover {
  background: var(--sidebar-soft);
  color: #fff;
}

.nav-link-custom.active {
  background: #2563eb;
  color: #fff;
}

.mobile-nav .nav-link-custom {
  color: #111827;
}

.mobile-nav .nav-link-custom:hover {
  background: #eef2ff;
}

.mobile-nav .nav-link-custom.active {
  color: #fff;
}

/* Main */

.main-content {
  flex: 1;
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
}

.page-subtitle {
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-menu {
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 10px;
  padding: 7px 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  transition: 0.15s ease;
}

.user-menu:hover,
.user-menu:focus-visible {
  background: #eef2ff;
  color: var(--primary);
  outline: 0;
}

/* Authentication */

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.16), transparent 35%),
    var(--bg);
}

.auth-card {
  width: min(100%, 440px);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 28px;
}

.auth-brand .logo-title {
  color: var(--text);
}

.auth-subtitle,
.auth-intro {
  color: var(--muted);
}

.auth-subtitle {
  margin-top: 3px;
  font-size: 13px;
}

.auth-card h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
}

.auth-intro {
  margin: 7px 0 22px;
  font-size: 14px;
}

.auth-card .form-label {
  font-size: 13px;
  font-weight: 800;
}

.auth-card .form-control {
  min-height: 46px;
  border-radius: 12px;
}

/* Views */

.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

/* Cards */

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 23px;
  flex: 0 0 auto;
}

.stat-value {
  font-size: 25px;
  font-weight: 900;
  line-height: 1.1;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
}

.panel-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Toolbar */

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-box i {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  height: 45px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px 0 42px;
  outline: 0;
}

.search-box input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.toolbar .form-select {
  max-width: 220px;
  border-radius: 14px;
}

/* Vehicle list */

.vehicle-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vehicle-row,
.vehicle-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  transition: 0.15s ease;
}

.vehicle-row {
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

.vehicle-row:hover,
.vehicle-card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.08);
}

.vehicle-icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: #eff6ff;
  color: #2563eb;
  font-size: 22px;
  flex: 0 0 auto;
}

.vehicle-main {
  flex: 1;
  min-width: 0;
}

.vehicle-title {
  font-weight: 900;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vehicle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.vehicle-status {
  flex: 0 0 auto;
}

.vehicle-card {
  padding: 18px;
  height: 100%;
  cursor: pointer;
}

.vehicle-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.vehicle-card-title {
  font-size: 18px;
  font-weight: 900;
}

.vehicle-card-spz {
  display: inline-flex;
  align-items: center;
  border: 1px solid #111827;
  border-radius: 7px;
  padding: 3px 9px;
  font-weight: 700;
  letter-spacing: 1px;
  background: #2833ac;
  font-size: 13px;
  color: #fff;
}

.vehicle-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-mini {
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px;
}

.info-mini-label {
  color: var(--muted);
  font-size: 12px;
}

.info-mini-value {
  font-weight: 800;
  margin-top: 2px;
}

.deadline-warning {
  background: #fef3c7;
  color: #b45309;
}

.deadline-warning .info-mini-label,
.deadline-warning .detail-label {
  color: #b45309;
}

.deadline-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.deadline-danger .info-mini-label,
.deadline-danger .detail-label {
  color: #b91c1c;
}

/* Alerts */

.alert-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alert-item {
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 13px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff;
}

.alert-list.big .alert-item {
  padding: 16px;
}

.alert-icon {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.alert-title {
  font-weight: 900;
}

.alert-text {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.alert-danger .alert-icon {
  background: #fee2e2;
  color: #dc2626;
}

.alert-warning .alert-icon {
  background: #fef3c7;
  color: #d97706;
}

.alert-info .alert-icon {
  background: #dbeafe;
  color: #2563eb;
}

/* Parts */

.parts-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.part-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  background: #fff;
}

.part-title {
  font-weight: 900;
}

.part-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

/* Calendar */

.calendar-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.calendar-toolbar h2,
.calendar-toolbar p {
  margin: 0;
}

.calendar-toolbar h2 {
  font-size: 20px;
  font-weight: 900;
}

.calendar-toolbar p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}

.calendar-controls {
  display: flex;
  gap: 8px;
}

.calendar-month-title {
  margin: 24px 0 14px;
  font-size: 19px;
  font-weight: 900;
}

.calendar-scroll {
  overflow-x: auto;
}

.calendar-grid {
  min-width: 760px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.calendar-weekdays > div {
  padding: 8px;
}

.calendar-days {
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.calendar-day {
  min-height: 120px;
  padding: 9px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.calendar-day.is-empty {
  background: #f8fafc;
}

.calendar-day.is-today {
  background: #eff6ff;
  box-shadow: inset 0 0 0 2px #93c5fd;
}

.calendar-day-number {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
}

.calendar-day.is-today .calendar-day-number {
  background: var(--primary);
  color: #fff;
}

.calendar-day-events {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 7px;
}

.calendar-event {
  width: 100%;
  border-radius: 7px;
  padding: 6px 7px;
  overflow: hidden;
}

.calendar-event-spz {
  overflow: hidden;
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-event-label {
  margin-top: 1px;
  overflow: hidden;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
}

.calendar-event-danger { background: #fee2e2; color: #b91c1c; }
.calendar-event-warning { background: #fef3c7; color: #b45309; }
.calendar-event-info { background: #dbeafe; color: #1d4ed8; }

/* Modal */

.modal-content {
  border-radius: 20px;
  border: 0;
}

.modal-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
}

.detail-box {
  background: #f8fafc;
  border-radius: 15px;
  padding: 13px;
}

.detail-box-wide {
  grid-column: 1 / -1;
}

.copy-field {
  width: 100%;
  border: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
  transition: 0.15s ease;
}

.copy-field:hover,
.copy-field:focus-visible {
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: 0;
}

.copy-field-value {
  display: block;
  letter-spacing: 0.06em;
  word-break: break-all;
}

.copy-field-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.copy-field.is-copied .copy-field-action {
  color: #15803d;
}

.driver-call {
  color: var(--text);
  display: block;
  text-decoration: none;
  transition: 0.15s ease;
}

.driver-call:hover,
.driver-call:focus-visible {
  color: var(--text);
  background: #ecfdf5;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
  outline: 0;
}

.driver-call .detail-value {
  display: block;
}

.driver-phone {
  display: block;
  margin-top: 3px;
  color: #15803d;
  font-size: 11px;
  font-weight: 700;
}

.date-edit {
  cursor: pointer;
  transition: 0.15s ease;
}

.date-edit:hover,
.date-edit:focus-visible,
.date-edit.is-editing {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: 0;
}

.date-edit-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.date-edit-display .detail-value {
  display: block;
}

.date-edit-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.date-edit-form {
  display: none;
  margin-top: 10px;
}

.date-edit.is-editing .date-edit-form {
  display: block;
}

.date-edit.is-editing .date-edit-action {
  display: none;
}

.date-edit-input {
  min-height: 40px;
  border-radius: 10px;
}

.date-edit-buttons {
  display: flex;
  gap: 7px;
  margin-top: 8px;
}

.detail-label {
  font-size: 12px;
  color: var(--muted);
}

.detail-value {
  font-size: 17px;
  font-weight: 900;
  margin-top: 3px;
}

/* Badges */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-ok {
  background: #dcfce7;
  color: #15803d;
}

.status-warning {
  background: #fef3c7;
  color: #b45309;
}

.status-danger {
  background: #fee2e2;
  color: #b91c1c;
}

/* Responsive */

@media (max-width: 991px) {
  .main-content {
    padding: 16px;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .panel {
    padding: 16px;
  }
}

@media (max-width: 767px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-actions .btn {
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .toolbar {
    flex-direction: column;
  }

  .toolbar .form-select {
    max-width: none;
  }

  .vehicle-row {
    align-items: flex-start;
  }

  .vehicle-status {
    display: none;
  }

  .vehicle-info-grid,
  .parts-list,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .panel-header {
    flex-direction: column;
  }

  .calendar-toolbar {
    flex-direction: column;
  }

  .calendar-day {
    min-height: 105px;
  }
}
