/* Application styles on top of Tabler 1.7 (static/vendor/tabler).
   Tokens first, then the shell (sidebar, top bar, bottom bar), then the
   components under templates/components/. Light theme only in phase 1; the
   dark block at the end keeps the token names ready. */

/* --- Tokens ---------------------------------------------------------------- */

:root {
  --app-primary: #206e7a;          /* muted teal-blue, 5.9:1 on white */
  --app-primary-hover: #1a5f68;
  --app-primary-soft: #e6f1f2;
  --app-surface: #ffffff;
  --app-bg: #f4f6f8;
  --app-border: #dde3e8;
  --app-text: #1f2933;
  --app-muted: #5f6b76;
  --app-success: #2f7d4f;
  --app-danger: #b42318;
  --app-warning: #b54708;
  --app-radius: 8px;
  --app-sidebar-width: 15rem;
  --app-rail-width: 4rem;          /* collapsed sidebar (64 px) */
  --app-topbar-height: 3.5rem;
  --app-bottombar-height: 3.75rem;
  --app-touch: 44px;
  /* Part-condition map (galeri): never red, which stays for errors; every state
     also carries a letter (L, B, D), so colour is not the only signal. */
  --app-cond-original: #ffffff;
  --app-cond-local: #fde68a;
  --app-cond-painted: #f59e0b;
  --app-cond-replaced: #5b21b6;
  --app-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Tabler bridges: one place to recolour the whole framework. */
  --tblr-primary: var(--app-primary);
  --tblr-success: var(--app-success);
  --tblr-danger: var(--app-danger);
  --tblr-warning: var(--app-warning);
  --tblr-body-bg: var(--app-bg);
  --tblr-body-color: var(--app-text);
  --tblr-secondary: var(--app-muted);
  --tblr-border-color: var(--app-border);
  --tblr-font-sans-serif: var(--app-font);
  --tblr-body-font-family: var(--app-font);
  --tblr-border-radius: var(--app-radius);
  --tblr-link-color: var(--app-primary);
  --tblr-link-hover-color: var(--app-primary-hover);
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/InterVariable.2bf3d951bf9d.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/InterVariable-Italic.8d1dc86da258.woff2") format("woff2");
}

html {
  font-family: var(--app-font);
}

[x-cloak] {
  display: none !important;
}

/* x-show hides with an inline display:none, which Tabler's !important display
   utilities (d-flex, d-grid, ...) would otherwise override. */
[x-show][style*="display: none"] {
  display: none !important;
}

body {
  background: var(--app-bg);
  color: var(--app-text);
  font-feature-settings: "cv11", "ss01";
}

a {
  text-underline-offset: 0.15em;
}

/* Links inside running text stay distinguishable without relying on colour. */
.app-content p a,
.app-content dd a,
.app-content label a,
.app-content .form-check-label a,
.app-content .text-secondary a,
.standalone p a,
.app-notice a:not(.btn) {
  text-decoration: underline;
}

/* A quiet in-page notice (not an alert): readable text on the soft primary tint. */
.app-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: var(--app-primary-soft);
  border-left: 4px solid var(--app-primary);
  border-radius: var(--app-radius);
  color: var(--app-text);
}

/* Dashboard office setup checklist: each line is a link to the office card. */
.setup-step {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: var(--app-touch);
  padding: 0.375rem 0;
  color: var(--app-text);
  text-decoration: none;
}

.setup-step svg.icon {
  flex-shrink: 0;
  margin-top: 0.125rem;
  color: var(--app-muted);
}

.setup-step.is-done svg.icon {
  color: var(--app-success);
}

.setup-step:not(.is-done) span:first-child {
  font-weight: 600;
}

.setup-step:hover {
  color: var(--app-primary);
}

.app-notice svg.icon {
  color: var(--app-primary);
}

/* A notice with several actions: on narrow screens they move under the text
   instead of squeezing it. */
.app-notice.app-notice-wrap {
  flex-wrap: wrap;
}

.app-notice-wrap > .app-notice-text {
  flex: 1 1 0;
  min-width: 12rem;
}

.app-notice-wrap > .app-notice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

/* A soft warning that never blocks (the sale form's expertise and cost checks). */
.app-notice.app-notice-warning {
  background: #fff4e5;
  border-left-color: var(--app-warning);
}

.app-notice.app-notice-warning svg.icon {
  color: var(--app-warning);
}

/* Icons come from static/icons/tabler-sprite.svg through {% icon %}. */
svg.icon {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.25em;
  flex-shrink: 0;
}

svg.icon-sm {
  width: 1rem;
  height: 1rem;
}

svg.icon-lg {
  width: 2rem;
  height: 2rem;
}

/* Visible focus everywhere (keyboard users), never removed. */
:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 2000;
  padding: 0.5rem 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
}

.skip-link:focus {
  top: 0.5rem;
}

/* --- Shell ----------------------------------------------------------------- */

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

.app-sidebar {
  display: none;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: var(--app-topbar-height);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
}

.app-topbar .app-office {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-topbar .app-office a {
  color: inherit;
  text-decoration: none;
}

.app-topbar .app-office .app-office-hint {
  font-weight: 400;
  color: var(--app-muted);
  font-size: 0.8125rem;
}

.app-content {
  flex: 1;
  padding: 1rem 1rem calc(var(--app-bottombar-height) + 1rem);
}

.app-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: var(--app-touch);
  min-height: var(--app-touch);
  border: 0;
  background: transparent;
  color: var(--app-text);
  border-radius: var(--app-radius);
}

.app-iconbtn:hover {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.app-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--app-danger);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.125rem;
  text-align: center;
}

/* A count next to a menu entry (NavItem.badge: the network's open requests),
   filled out of band by the bell's poll; hidden while zero. */
.app-nav-badge {
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: auto;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--app-primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.25rem;
  text-align: center;
}

.app-nav-badge[hidden] {
  display: none;
}

.app-nav a.active .app-nav-badge {
  background: #fff;
  color: var(--app-primary);
}

.app-bottombar a {
  position: relative;
}

.app-bottombar .app-nav-badge {
  position: absolute;
  top: 2px;
  left: calc(50% + 4px);
  margin: 0;
}

html[data-sidebar="collapsed"] .app-sidebar .app-nav a {
  position: relative;
}

html[data-sidebar="collapsed"] .app-sidebar .app-nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
}

/* Sidebar navigation (desktop) */
.app-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--app-touch);
  padding: 0.5rem 0.75rem;
  border-radius: var(--app-radius);
  color: var(--app-text);
  text-decoration: none;
}

.app-nav a:hover {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.app-nav a.active {
  background: var(--app-primary);
  color: #fff;
}

.app-nav .app-nav-soon {
  margin-left: auto;
  font-size: 0.6875rem;
  color: var(--app-muted);
}

.app-nav a.active .app-nav-soon {
  color: rgba(255, 255, 255, 0.8);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--app-primary);
  text-decoration: none;
}

/* Bottom bar (phone) */
.app-bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  height: calc(var(--app-bottombar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--app-surface);
  border-top: 1px solid var(--app-border);
}

.app-bottombar a,
.app-bottombar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--app-touch);
  padding: 0.25rem 0;
  border: 0;
  background: transparent;
  color: var(--app-muted);
  font-size: 0.6875rem;
  text-decoration: none;
}

.app-bottombar a.active {
  color: var(--app-primary);
}

.app-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--app-bottombar-height) + env(safe-area-inset-bottom));
  z-index: 1029;
  background: var(--app-surface);
  border-top: 1px solid var(--app-border);
  border-radius: var(--app-radius) var(--app-radius) 0 0;
  box-shadow: 0 -8px 24px rgba(31, 41, 51, 0.12);
  padding: 0.5rem;
}

.app-sheet .app-nav a {
  min-height: var(--app-touch);
}

/* The sidebar toggle exists only where the sidebar does (desktop). */
.app-topbar .app-sidebar-toggle {
  display: none;
}

@media (min-width: 992px) {
  .app {
    flex-direction: row;
  }

  .app-sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    width: var(--app-sidebar-width);
    flex-shrink: 0;
    padding: 0.5rem;
    background: var(--app-surface);
    border-right: 1px solid var(--app-border);
  }

  .app-sidebar .app-nav {
    flex: 1;
  }

  /* Collapsed sidebar: an icon rail; the labels become tooltips on hover and
     keyboard focus (they stay in the accessibility tree). */
  html[data-sidebar="collapsed"] .app-sidebar {
    width: var(--app-rail-width);
    padding: 0.5rem 0.375rem;
  }

  html[data-sidebar="collapsed"] .app-sidebar .app-brand,
  html[data-sidebar="collapsed"] .app-sidebar .app-nav a,
  html[data-sidebar="collapsed"] .app-sidebar .dropdown-toggle {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  html[data-sidebar="collapsed"] .app-sidebar .app-sidebar-label,
  html[data-sidebar="collapsed"] .app-sidebar .app-nav-soon,
  html[data-sidebar="collapsed"] .app-sidebar .dropdown-toggle::after {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  html[data-sidebar="collapsed"] .app-sidebar .app-nav a {
    position: relative;
  }

  html[data-sidebar="collapsed"] .app-sidebar .app-nav-label {
    position: absolute;
    left: calc(100% + 0.5rem);
    top: 50%;
    z-index: 1060;
    padding: 0.25rem 0.5rem;
    border-radius: var(--app-radius);
    background: var(--app-text);
    color: #fff;
    font-size: 0.8125rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity 0.1s;
  }

  html[data-sidebar="collapsed"] .app-sidebar .app-nav a:hover .app-nav-label,
  html[data-sidebar="collapsed"] .app-sidebar .app-nav a:focus-visible .app-nav-label {
    opacity: 1;
  }

  .app-bottombar,
  .app-sheet {
    display: none;
  }

  .app-topbar .app-sidebar-toggle {
    display: inline-flex;
  }

  .app-content {
    padding: 1.5rem 2rem 2rem;
  }
}

/* Loading indicator for HTMX requests */
.app-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 1040;
  background: var(--app-primary);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: opacity 0.2s, transform 0.4s;
}

.htmx-request .app-progress,
.htmx-request.app-progress {
  opacity: 1;
  transform: scaleX(0.7);
}

/* Toasts (Django messages and HTMX errors) */
.app-toasts {
  position: fixed;
  top: calc(var(--app-topbar-height) + 0.5rem);
  right: 0.75rem;
  left: 0.75rem;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--app-primary);
  border-radius: var(--app-radius);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.12);
}

.app-toast.app-toast-success {
  border-left-color: var(--app-success);
}

.app-toast.app-toast-danger {
  border-left-color: var(--app-danger);
}

.app-toast.app-toast-warning {
  border-left-color: var(--app-warning);
}

@media (min-width: 992px) {
  .app-toasts {
    left: auto;
    width: 22rem;
  }
}

/* --- Components ------------------------------------------------------------ */

/* page_header.html */
.page-header {
  margin-bottom: 1rem;
}

.page-header .page-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* list_table.html: a table on desktop, stacked cards on phone */
.list-table {
  width: 100%;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  border-collapse: separate;
  border-spacing: 0;
}

.list-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--app-muted);
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--app-border);
}

.list-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--app-border);
  vertical-align: middle;
}

.list-table tbody tr:last-child td {
  border-bottom: 0;
}

.list-table .list-primary a {
  font-weight: 600;
  color: var(--app-text);
  text-decoration: none;
}

.list-table .list-primary a:hover {
  color: var(--app-primary);
}

@media (max-width: 991.98px) {
  .list-table,
  .list-table tbody,
  .list-table tr,
  .list-table td {
    display: block;
  }

  .list-table thead {
    display: none;
  }

  .list-table {
    background: transparent;
    border: 0;
  }

  .list-table tr {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
  }

  .list-table td {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    padding: 0.375rem 0;
    border: 0;
  }

  .list-table td[data-label]::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--app-muted);
    font-size: 0.8125rem;
  }

  .list-table td.list-primary {
    font-size: 1rem;
  }

  .list-table td.list-actions {
    justify-content: flex-end;
  }
}

/* filters.html: inline, wraps on phone */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.filters .form-control,
.filters .form-select {
  min-height: var(--app-touch);
}

.filters .filters-search {
  flex: 1 1 14rem;
}

/* empty_state.html */
.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  background: var(--app-surface);
  border: 1px dashed var(--app-border);
  border-radius: var(--app-radius);
}

.empty-state svg.icon {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--app-muted);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--app-muted);
  margin-bottom: 1rem;
}

/* confirm_button.html: the inline confirm row */
.confirm-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.confirm-row .confirm-question {
  color: var(--app-danger);
  font-size: 0.875rem;
}

/* badge_status.html */
.badge-status {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.badge-status.tone-success {
  background: #e6f4ea;
  color: #1f6b3f; /* 5.7:1 on the soft green */
}

.badge-status.tone-danger {
  background: #fbeae9;
  color: var(--app-danger);
}

.badge-status.tone-warning {
  background: #fdf0e6;
  color: var(--app-warning);
}

.badge-status.tone-muted {
  background: #eef1f4;
  color: var(--app-muted);
}

/* timeline.html */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--app-border);
}

.timeline li:last-child {
  border-bottom: 0;
}

.timeline .timeline-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--app-primary-soft);
  color: var(--app-primary);
  flex-shrink: 0;
}

.timeline .timeline-when {
  color: var(--app-muted);
  font-size: 0.8125rem;
}

/* card_stat.html */
.card-stat {
  display: block;
  padding: 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  color: inherit;
  text-decoration: none;
}

a.card-stat:hover {
  border-color: var(--app-primary);
  color: inherit;
}

.card-stat .card-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.card-stat .card-stat-title {
  color: var(--app-muted);
  font-size: 0.875rem;
}

.card-stat .card-stat-note {
  color: var(--app-muted);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

/* Calendar: the day list is roomy, the week columns are compact */
.calendar-time {
  min-width: 3rem;
}

.calendar-week .calendar-entry.compact {
  flex-direction: column;
  gap: 0;
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.calendar-week .calendar-entry.compact .calendar-time {
  min-width: 0;
}

.calendar-week .calendar-entry.compact svg.icon {
  display: none;
}

/* Buttons: touch targets and the single primary colour */
.btn {
  min-height: 2.5rem;
}

.btn-primary {
  --tblr-btn-bg: var(--app-primary);
  --tblr-btn-border-color: var(--app-primary);
  --tblr-btn-hover-bg: var(--app-primary-hover);
  --tblr-btn-hover-border-color: var(--app-primary-hover);
  --tblr-btn-active-bg: var(--app-primary-hover);
  --tblr-btn-active-border-color: var(--app-primary-hover);
}

/* Tabler paints link buttons a lighter tone of the primary colour, which drops
   below 4.5:1 on the soft tint of .app-notice; keep the token. */
.btn-link {
  color: var(--app-primary);
}

@media (max-width: 991.98px) {
  .btn {
    min-height: var(--app-touch);
  }
}

/* Forms: one column, full width; errors under the field */
.form-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  padding: 1rem;
}

.form-card .form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
}

.form-control,
.form-select {
  min-height: 2.5rem;
}

/* Standalone pages (sign-in, invitation) */
.standalone {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.standalone .standalone-card {
  width: 100%;
  max-width: 26rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  padding: 1.5rem;
}

.standalone .app-brand {
  justify-content: center;
  margin-bottom: 1rem;
}

.standalone .standalone-footer {
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--app-muted);
}

/* --- Galeri: wizard, brand chips, condition map, photos ------------------- */

.wizard-steps ol {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  counter-reset: none;
}

.wizard-steps li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 3px solid var(--app-border);
  color: var(--app-muted);
  font-size: 0.875rem;
  min-width: 0;
}

.wizard-steps li.is-done {
  border-top-color: var(--app-primary-soft);
}

.wizard-steps li.is-current {
  border-top-color: var(--app-primary);
  color: var(--app-text);
  font-weight: 600;
}

.wizard-steps .wizard-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  font-size: 0.75rem;
}

.wizard-steps li.is-current .wizard-number {
  background: var(--app-primary);
  border-color: var(--app-primary);
  color: #fff;
}

.wizard-steps .wizard-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .wizard-steps li.is-current {
    flex: 3;
  }

  .wizard-steps li:not(.is-current) .wizard-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

.brand-chip {
  min-height: var(--app-touch);
}

.condition-map {
  display: grid;
  grid-template-columns: minmax(10rem, 15rem) 1fr;
  gap: 0.5rem 1.25rem;
  align-items: start;
}

.condition-map-svg {
  width: 100%;
  max-width: 15rem;
  grid-row: span 3;
}

.condition-map .condition-car {
  fill: var(--app-bg);
  stroke: var(--app-border);
  stroke-width: 1.5;
}

.condition-map .condition-glass {
  fill: #e3e8ed;
}

.condition-part rect,
.condition-swatch {
  fill: var(--app-cond-original);
  background: var(--app-cond-original);
  stroke: #8896a4;
  stroke-width: 1.5;
}

.condition-part[data-state="local_paint"] rect,
.condition-swatch[data-state="local_paint"] {
  fill: var(--app-cond-local);
  background: var(--app-cond-local);
}

.condition-part[data-state="painted"] rect,
.condition-swatch[data-state="painted"] {
  fill: var(--app-cond-painted);
  background: var(--app-cond-painted);
}

.condition-part[data-state="replaced"] rect,
.condition-swatch[data-state="replaced"] {
  fill: var(--app-cond-replaced);
  background: var(--app-cond-replaced);
  color: #fff;
}

.condition-part text {
  font-size: 15px;
  font-weight: 700;
  fill: var(--app-text);
  pointer-events: none;
}

.condition-part[data-state="replaced"] text {
  fill: #fff;
}

.condition-map.is-editable .condition-part {
  cursor: pointer;
}

.condition-map.is-editable .condition-part:focus {
  outline: none;
}

.condition-map.is-editable .condition-part:focus-visible rect {
  stroke: var(--app-primary);
  stroke-width: 4;
}

.condition-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.375rem;
}

.condition-legend li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.condition-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1.5px solid #8896a4;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

@media (max-width: 575.98px) {
  .condition-map {
    grid-template-columns: 1fr;
  }

  .condition-map-svg {
    max-width: 13rem;
    margin: 0 auto;
    grid-row: auto;
  }
}

.photo-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.75rem;
}

.photo-card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  overflow: hidden;
}

.photo-card[draggable="true"] {
  cursor: grab;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-bg);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-badge {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--app-primary);
  color: #fff;
  font-size: 0.75rem;
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.375rem;
}

.photo-actions .btn-icon {
  min-width: 2.25rem;
}

/* "Ağda: Açık / Kapalı" on a photo card: a switch on its own row. */
.photo-share {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  min-height: var(--app-touch);
}

/* A styled button over a visually hidden file input; keyboard focus on the
   input shows on the button. */
.file-picker {
  display: inline-block;
}

.file-picker input:focus-visible + label {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

.vehicle-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 4rem;
  height: 3rem;
  border-radius: var(--app-radius);
  background: var(--app-bg);
  color: var(--app-muted);
  overflow: hidden;
}

.vehicle-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Vehicle entry: body · fuel · transmission from the variant, as one line. */
.spec-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--app-touch);
  margin-bottom: 1rem;
  padding: 0.25rem 0.75rem;
  background: var(--app-bg);
  border-radius: var(--app-radius);
}

/* Stock list (list_table with table_class="vehicle-list"). */
.vehicle-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.vehicle-text {
  min-width: 0;
}

@media (max-width: 991.98px) {
  /* The first cell is the whole card: cover left, three lines right. */
  .vehicle-list tr {
    position: relative;
    padding: 0.5rem;
  }

  .vehicle-list td.list-primary {
    display: block;
    padding: 0;
  }

  .vehicle-list td.list-primary::before {
    content: none;
  }

  .vehicle-list .vehicle-cell {
    gap: 0.75rem;
  }

  .vehicle-list .vehicle-thumb {
    width: 96px;
    height: 72px;
  }

  .vehicle-list .vehicle-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.125rem;
  }

  .vehicle-list .vehicle-link {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The title link covers the card, so a tap anywhere opens the vehicle. */
  .vehicle-list .vehicle-link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--app-radius);
  }

  .vehicle-list .vehicle-link:focus-visible {
    outline: none;
  }

  .vehicle-list .vehicle-link:focus-visible::after {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
  }

  .vehicle-facts {
    font-size: 0.875rem;
    color: var(--app-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .vehicle-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
  }

  .vehicle-shared {
    display: inline-flex;
    color: var(--app-primary);
  }
}

.network-thumb {
  width: 5.5rem;
  height: 4rem;
  object-fit: cover;
  border-radius: var(--app-radius);
}

.vehicle-filters {
  flex-wrap: wrap;
}

.vehicle-filters-more {
  flex-basis: 100%;
}

.vehicle-filters-more > summary {
  list-style: none;
}

.vehicle-filters-more > summary::-webkit-details-marker {
  display: none;
}

.confirm-row .confirm-reason {
  margin: 0;
}

details.card > summary {
  cursor: pointer;
}

/* Masraflar: the running total under the list */
.expense-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem 0;
}

/* Customer page (/v/<token>/): a wider standalone card with a swipeable gallery */
.standalone .standalone-card.standalone-wide {
  max-width: 48rem;
}

.public-office {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.public-logo {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: contain;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-surface);
}

.public-gallery {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  border-radius: var(--app-radius);
}

.public-gallery img {
  flex: 0 0 100%;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  scroll-snap-align: center;
  border-radius: var(--app-radius);
  background: var(--app-bg);
}

.public-price {
  font-size: 1.75rem;
  font-weight: 700;
}

.public-specs dt {
  font-weight: 400;
  color: var(--app-muted);
}

/* Criteria chips (demand form): real checkboxes drawn as pills */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.chip-scroll {
  max-height: 14rem;
  overflow-y: auto;
  padding: 0.125rem;
}

.chip-check {
  position: relative;
  display: inline-flex;
  margin: 0;
}

.chip-check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.chip-check span {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.25rem 0.875rem;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: var(--app-surface);
  cursor: pointer;
  user-select: none;
}

.chip-check input:checked + span {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
  color: var(--app-primary);
  font-weight: 600;
}

.chip-check input:focus-visible + span {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
}

@media (max-width: 991.98px) {
  .chip-check span {
    min-height: var(--app-touch);
  }
}

.criteria-block {
  margin: 1rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
}

/* Match reasons: one short line each */
.match-reasons {
  margin: 0;
  padding-left: 1rem;
  font-size: 0.875rem;
}

/* Expense categories: one row per category, actions on the right */
.category-list .list-group-item {
  min-height: var(--app-touch);
}

/* Detail tabs scroll sideways on phones instead of wrapping into two rows. */
@media (max-width: 767.98px) {
  #vehicle-tabs > .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  #vehicle-tabs > .nav-tabs .nav-link {
    white-space: nowrap;
  }
}

/* --- Network (opa) ---------------------------------------------------------- */

/* The network's figures under the list's header. */
.network-stats {
  margin: -0.5rem 0 0.75rem;
  color: var(--app-muted);
  font-size: 0.875rem;
}

/* The section's pages as pills under the page header. */
.network-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.network-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: var(--app-touch);
  padding: 0 0.875rem;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: var(--app-surface);
  color: var(--app-text);
  white-space: nowrap;
  text-decoration: none;
}

.network-nav-link:hover {
  color: var(--app-primary);
}

.network-nav-link.active {
  border-color: var(--app-primary);
  background: var(--app-primary-soft);
  color: var(--app-primary);
  font-weight: 600;
}

/* Filters: inline on desktop, behind "Filtreler" on phones. */
.network-filters {
  margin-bottom: 1rem;
}

.network-filters-top {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.network-filters-top .filters-search {
  flex: 1;
}

.network-filters-panel {
  display: none;
  padding: 0.5rem 0.75rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
}

.network-filters-panel.is-open {
  display: block;
}

@media (min-width: 992px) {
  .network-filters-panel {
    display: block;
  }
}

/* Cards: one column on phones, a grid on wider screens. */
.network-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}

.network-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  overflow: hidden;
}

.network-card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--app-text);
  text-decoration: none;
}

.network-card-link:hover .network-card-title {
  color: var(--app-primary);
}

.network-card-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  background: var(--app-bg);
  color: var(--app-muted);
}

.network-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.network-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.625rem 0.75rem 0.75rem;
}

.network-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.network-card-title {
  font-weight: 600;
}

.network-card-price,
.network-price {
  font-size: 1.125rem;
  font-weight: 700;
}

.network-price {
  font-size: 1.5rem;
}

.network-card-facts,
.network-card-meta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--app-muted);
  font-size: 0.875rem;
}

.network-card-tag {
  align-self: flex-start;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--app-bg);
  color: var(--app-text);
  font-size: 0.75rem;
}

.network-card-star {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
}

.network-card-star .favorite-star {
  background: var(--app-surface);
  border-radius: 999px;
}

.network-card.is-gone {
  opacity: 0.8;
}

.network-card.is-gone .network-card-star {
  position: static;
  padding: 0 0.75rem 0.75rem;
}

.favorite-star {
  min-width: var(--app-touch);
  min-height: var(--app-touch);
  color: var(--app-muted);
}

.favorite-star.is-on,
.favorite-form .is-on svg.icon {
  color: var(--app-warning);
  fill: currentColor;
}

/* "Benzer araçlar": a horizontal strip of cards. */
.network-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 17rem;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

@media (max-width: 991.98px) {
  .network-strip {
    grid-auto-columns: 80%;
  }
}

/* Listing page: a swipeable photo strip with thumbnails on desktop. */
.network-gallery-track {
  position: relative;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  border-radius: var(--app-radius);
}

.network-gallery-track img {
  flex: 0 0 100%;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  scroll-snap-align: center;
  border-radius: var(--app-radius);
  background: var(--app-bg);
}

.network-gallery-thumbs {
  gap: 0.5rem;
  margin-top: 0.5rem;
  overflow-x: auto;
}

.network-gallery-thumb {
  flex: 0 0 5.5rem;
  height: 4rem;
  padding: 0;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-bg);
  overflow: hidden;
}

.network-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.network-gallery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  aspect-ratio: 4 / 3;
  border-radius: var(--app-radius);
  background: var(--app-bg);
  color: var(--app-muted);
}

/* A gallery's identity and contact buttons (opa/partials/gallery_card.html). */
.gallery-card {
  padding: 0.75rem 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
}

.gallery-card-name {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.gallery-card-phone {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.gallery-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Shared demands ("Aranan araçlar"). */
.wanted-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 0.75rem;
}

.wanted-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
}

.wanted-card-title {
  font-weight: 600;
  color: var(--app-text);
}

.wanted-preview {
  padding: 0.75rem 1rem;
  border-radius: var(--app-radius);
  background: var(--app-bg);
}

/* Collaborations (requests page, collaborations page, the vehicle's Ağ tab). */
.collaboration-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.collaboration-card {
  padding: 0.75rem 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
}

.collaboration-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.collaboration-card-title {
  font-weight: 600;
  color: var(--app-text);
}

.collaboration-actions {
  margin-top: 0.5rem;
}

.price-history li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--app-border);
}

.network-matches {
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--app-primary);
  border-radius: var(--app-radius);
  background: var(--app-primary-soft);
}

.network-specs dt {
  font-weight: 400;
  color: var(--app-muted);
}

.mine-price {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.mine-price input {
  width: 9rem;
}

.network-filters-panel .mb-3 {
  margin-bottom: 0.5rem !important;
}

/* --- Dark mode tokens (phase 2; not enabled by any markup yet) ------------- */

@media (prefers-color-scheme: dark) {
  :root[data-theme="dark"] {
    --app-surface: #1b232b;
    --app-bg: #11171d;
    --app-border: #2c3844;
    --app-text: #e6ebf0;
    --app-muted: #9aa7b3;
    --app-primary-soft: #16343a;
  }
}

/* The web push banner (notifications/partials/push_banner.html). */
.push-banner .app-notice {
  margin-bottom: 1rem;
}
