:root {
  --bg: #f3f1ea;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --text: #1f2a24;
  --muted: #6a756d;
  --line: rgba(31, 42, 36, 0.12);
  --brand: #0f766e;
  --brand-strong: #0a5d57;
  --accent: #e7b85d;
  --danger: #b64c3b;
  --ok: #2f7d4c;
  --shadow: 0 18px 40px rgba(31, 42, 36, 0.08);
  --radius: 18px;
  --font-sans: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(231, 184, 93, 0.28), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.24), transparent 30%),
    linear-gradient(180deg, #f8f5ef 0%, #edeae1 100%);
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(255,255,255,0.35));
  backdrop-filter: blur(12px);
}

.brand-mark {
  margin-bottom: 30px;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 14px;
}

.brand-logo-compact {
  width: 84px;
  height: 84px;
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(47, 87, 217, 0.12));
}

.brand-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
  margin-bottom: 8px;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.35;
  max-width: 180px;
}

.nav-section {
  margin-top: 22px;
}

.nav-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  margin-bottom: 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--text);
  margin-bottom: 8px;
  transition: transform 140ms ease, background 140ms ease;
}

.nav-link:hover,
.nav-link.active {
  transform: translateX(4px);
  background: rgba(15, 118, 110, 0.1);
}

.main-panel {
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar-card,
.panel,
.metric-card,
.planner-board,
.table-card,
.login-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}

.topbar-card {
  padding: 14px 18px;
}

.top-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.top-tab {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(31, 42, 36, 0.1);
  color: var(--text);
  font-weight: 600;
}

.top-tab.active {
  background: rgba(15, 118, 110, 0.12);
  color: var(--brand-strong);
}

.tenant-pill,
.status-pill,
.event-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  background: rgba(15, 118, 110, 0.12);
}

.flash-banner {
  margin-bottom: 16px;
}

.flash-banner.is-error {
  background: rgba(182, 76, 59, 0.14);
  color: var(--danger);
}

.flash-banner.is-success {
  background: rgba(47, 125, 76, 0.14);
  color: var(--ok);
}

.content-grid {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 18px;
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 120px;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 3px solid rgba(15, 118, 110, 0.18);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.muted {
  color: var(--muted);
}

.actions,
.filters,
.form-grid,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.quick-create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.fleet-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

.inline-create-disclosure {
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.52);
  overflow: hidden;
}

.inline-create-disclosure-top {
  min-width: 180px;
}

.inline-create-summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
  color: var(--brand-strong);
}

.inline-create-summary::-webkit-details-marker {
  display: none;
}

.inline-create-summary::after {
  content: "+";
  float: right;
  font-size: 1rem;
}

.inline-create-disclosure[open] .inline-create-summary::after {
  content: "-";
}

.vehicle-form {
  display: grid;
  gap: 18px;
}

.vehicle-create-panel {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px;
}

.vehicle-create-header {
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(31, 42, 36, 0.08);
}

.vehicle-create-kicker {
  display: inline-flex;
  align-items: center;
  margin-bottom: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.vehicle-create-badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(31, 42, 36, 0.1);
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.vehicle-create-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-attention {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14), var(--shadow);
  transition: box-shadow 0.24s ease;
}

.fleet-form-section {
  padding: 18px 18px 16px;
  border: 1px solid rgba(31, 42, 36, 0.1);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.68));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.fleet-form-section-title {
  margin-bottom: 16px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--brand-strong);
}

.fleet-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.inline-create-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-top: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.85rem;
  color: var(--muted);
}

.field-required {
  margin-left: 3px;
  color: var(--danger);
  font-weight: 700;
}

.planner-checkbox {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.planner-checkbox input {
  width: 18px;
  height: 18px;
}

.planner-checkbox-compact {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: 54px;
  padding: 12px 14px;
  width: 100%;
}

.planner-checkbox-compact span {
  display: inline-flex;
  align-items: center;
  flex: 1 1 auto;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.2;
  white-space: normal;
}

.planner-checkbox-compact input {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 24px;
  margin: 0;
  border: 1px solid rgba(31, 42, 36, 0.14);
  border-radius: 999px;
  background: rgba(31, 42, 36, 0.12);
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
  flex: 0 0 auto;
}

.planner-checkbox-compact input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(31, 42, 36, 0.14);
  transition: transform 0.18s ease;
}

.planner-checkbox-compact input:checked {
  background: linear-gradient(135deg, #57a5d6 0%, #2f89bf 100%);
  border-color: rgba(47, 137, 191, 0.32);
}

.planner-checkbox-compact input:checked::before {
  transform: translateX(18px);
}

.planner-checkbox-compact input:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.field input:not([type="checkbox"]),
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 11px 12px;
  min-height: 44px;
}

.vehicle-create-actions {
  position: sticky;
  bottom: 12px;
  z-index: 2;
  justify-content: flex-end;
  padding: 14px 16px;
  border: 1px solid rgba(31, 42, 36, 0.08);
  border-radius: 16px;
  background: rgba(248, 245, 239, 0.92);
  backdrop-filter: blur(10px);
}

.rental-form-shell {
  gap: 16px;
}

.rental-section {
  padding: 18px;
}

.rental-form-actions {
  justify-content: flex-end;
  padding: 14px 0 0;
}

.fleet-modal-page {
  position: relative;
}

.fleet-modal-shell {
  position: relative;
}

.fleet-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 42, 36, 0.24);
  backdrop-filter: blur(4px);
  z-index: 20;
}

.fleet-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100vw - 56px));
  max-height: calc(100vh - 72px);
  padding: 20px;
  border-radius: 24px;
  background: rgba(248, 245, 239, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 28px 70px rgba(31, 42, 36, 0.22);
  overflow: auto;
  z-index: 21;
}

.fleet-modal-wide {
  width: min(1120px, calc(100vw - 56px));
}

.fleet-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.fleet-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.fleet-modal-body {
  display: grid;
  gap: 16px;
}

.fleet-modal-panel,
.fleet-modal-table {
  box-shadow: none;
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  min-height: 44px;
  font-weight: 600;
  background: #e8e5db;
  color: var(--text);
}

.btn-small {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
}

.btn-secondary {
  background: rgba(15, 118, 110, 0.12);
  color: var(--brand-strong);
}

.btn-danger {
  background: rgba(182, 76, 59, 0.14);
  color: var(--danger);
}

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

.metric-card {
  padding: 18px;
}

.metric-label {
  color: var(--muted);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.table-card {
  overflow: hidden;
}

.vehicle-row {
  cursor: pointer;
}

.vehicle-row:hover td {
  background: rgba(15, 118, 110, 0.04);
}

.reservation-row {
  cursor: pointer;
}

.reservation-row:hover td {
  background: rgba(15, 118, 110, 0.04);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

tr:last-child td {
  border-bottom: none;
}

.table-link {
  font-weight: 700;
}

.pagination-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

@media (max-width: 1280px) {
  .vehicle-create-sections {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .vehicle-create-panel {
    padding: 18px;
  }

  .vehicle-create-header {
    flex-direction: column;
  }

  .fleet-form-grid {
    grid-template-columns: 1fr;
  }

  .vehicle-create-actions {
    position: static;
  }

  .fleet-modal {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 16px;
  }

  .fleet-modal-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

.planner-board {
  overflow: visible;
}

.planner-page-maximized {
  min-height: calc(100vh - 44px);
}

.planner-shell {
  display: grid;
  gap: 16px;
}

.planner-shell.is-maximized {
  position: fixed;
  inset: 12px;
  z-index: 30;
  overflow: auto;
  background: rgba(248, 245, 239, 0.98);
}

.planner-shell:fullscreen {
  padding: 18px;
  background: rgba(248, 245, 239, 0.98);
}

.planner-collapsible {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
}

.planner-collapsible.is-collapsed {
  display: none;
}

.planner-collapsible.is-collapsed form {
  display: none;
}

.planner-collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.planner-board-scroll {
  overflow: auto;
  padding-top: 6px;
  padding-bottom: 40px;
}

.planner-grid {
  display: grid;
  grid-template-columns: 220px repeat(var(--days), minmax(78px, 1fr));
  min-width: max-content;
}

.planner-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-height: 28px;
  background: rgba(255, 255, 255, 0.55);
}

.planner-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(247, 244, 236, 0.95);
}

.planner-vehicle-cell {
  padding: 4px 6px;
  background: rgba(245, 242, 233, 0.92);
  font-size: 0.74rem;
  line-height: 1.05;
}

.planner-day-cell {
  padding: 5px 6px;
  font-size: 0.68rem;
}

.planner-vehicle-grid {
  display: grid;
  grid-template-columns: 82px 1fr 20px;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.planner-vehicle-grid-header {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text);
}

.planner-vehicle-code {
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planner-vehicle-type {
  font-size: 0.68rem;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planner-category-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 2px;
  background: #f0b000;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
}

.planner-row {
  position: relative;
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: subgrid;
}

.planner-lane {
  grid-column: 2 / -1;
  position: relative;
  min-height: 28px;
  background-image: linear-gradient(to right, rgba(31,42,36,0.06) 1px, transparent 1px);
  background-size: calc(100% / var(--days)) 100%;
}

.planner-lane.drag-target {
  background-color: rgba(15, 118, 110, 0.09);
 }

.planner-event {
  position: absolute;
  top: 3px;
  height: 22px;
  border-radius: 8px;
  padding: 2px 8px;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.14);
  border: 0;
  text-align: left;
  cursor: pointer;
  overflow: visible;
}

.planner-event.is-dragging {
  opacity: 0.55;
}

.planner-event.is-resizing {
  opacity: 0.9;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 14px 28px rgba(0, 0, 0, 0.18);
}

.planner-event.reservation { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.planner-event.rental { background: linear-gradient(135deg, #0f766e, #0a5d57); }
.planner-event.maintenance { background: linear-gradient(135deg, #b45309, #92400e); }
.planner-event.blocked { background: linear-gradient(135deg, #7c3aed, #5b21b6); }

.planner-event-title {
  font-weight: 700;
  font-size: 0.68rem;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planner-event-meta {
  display: none;
}

.planner-tooltip-title {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 0.92rem;
}

.planner-tooltip-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  padding: 2px 0;
}

.planner-tooltip-label {
  color: rgba(31, 42, 36, 0.62);
  font-size: 0.78rem;
}

.planner-tooltip-value {
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text);
}

.planner-hover-card[hidden] {
  display: none;
}

.planner-hover-card {
  position: fixed;
  width: min(320px, calc(100vw - 24px));
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(251, 248, 240, 0.98);
  color: var(--text);
  border: 1px solid rgba(31, 42, 36, 0.12);
  box-shadow: 0 16px 30px rgba(31, 42, 36, 0.14);
  pointer-events: none;
  z-index: 200;
}

.planner-hover-card::after {
  content: "";
  position: absolute;
  left: 18px;
  top: -14px;
  border: 7px solid transparent;
  border-bottom-color: rgba(251, 248, 240, 0.98);
}

.planner-hover-card.is-above::after {
  top: auto;
  bottom: -14px;
  border-bottom-color: transparent;
  border-top-color: rgba(251, 248, 240, 0.98);
}

.planner-resize-handle {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  cursor: ew-resize;
}

.planner-resize-handle.left {
  left: 2px;
}

.planner-resize-handle.right {
  right: 2px;
}

.planner-modal[hidden] {
  display: none;
}

.planner-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.planner-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 42, 36, 0.36);
}

.planner-modal-card {
  position: relative;
  width: min(820px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 20px;
  border-radius: 20px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.planner-context-menu[hidden] {
  display: none;
}

.planner-context-menu {
  position: fixed;
  z-index: 210;
  min-width: 190px;
  padding: 6px 0;
  border-radius: 12px;
  background: rgba(251, 248, 240, 0.99);
  border: 1px solid rgba(31, 42, 36, 0.12);
  box-shadow: 0 12px 28px rgba(31, 42, 36, 0.14);
}

.planner-context-action {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 0.92rem;
}

.planner-context-action:hover {
  background: rgba(15, 118, 110, 0.08);
}

.planner-shift-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.login-card {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  overflow: hidden;
}

.login-hero,
.login-form {
  padding: 34px;
}

.login-logo {
  width: min(240px, 65%);
  height: auto;
  display: block;
  margin-bottom: 20px;
  object-fit: contain;
}

.login-hero {
  background: linear-gradient(155deg, rgba(15, 118, 110, 0.97), rgba(12, 75, 70, 0.92));
  color: #fff;
}

.login-kicker {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.78rem;
  opacity: 0.8;
}

.login-title {
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  margin: 18px 0;
}

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

.stack {
  display: grid;
  gap: 18px;
}

.mono {
  font-family: var(--font-mono);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .login-card {
    grid-template-columns: 1fr;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
