:root {
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f6f8fa;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #b7791f;
  --danger: #b42318;
  --ok: #28765f;
  --shadow: 0 16px 42px rgba(23, 32, 42, 0.11);
  font-family: "Segoe UI", Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  grid-column: 1 / -1;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  margin-bottom: 22px;
}

.login-status {
  margin: 0 0 14px;
  color: var(--danger);
  font-weight: 700;
}

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

button {
  cursor: pointer;
}

.sidebar {
  min-height: 100vh;
  background: #16212b;
  color: #f7fafc;
  padding: 24px 18px;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #eab308;
  color: #17202a;
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #b9c4cf;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #e9eef3;
  background: transparent;
  text-align: left;
  padding: 0 14px;
}

.nav-button:hover,
.nav-button.active {
  background: #233241;
  border-color: #33485c;
}

.app {
  min-width: 0;
  padding: 26px;
  width: 100%;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

p {
  margin: 7px 0 0;
  color: var(--muted);
}

.topbar-actions,
.user-actions,
.panel-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-actions {
  justify-content: flex-end;
}

.user-actions span {
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 650;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.danger-button {
  background: #fff5f5;
  border-color: #f4c7c3;
  color: var(--danger);
}

.icon-button {
  width: 38px;
  padding: 0;
  background: transparent;
  border-color: var(--line);
  font-size: 22px;
  line-height: 1;
}

.file-button {
  display: inline-grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.backup-status {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.backup-status.warn {
  background: #fff8e1;
  border-color: #f0d48a;
  color: #8a5a00;
}

.backup-status.ok {
  background: #e8f6ef;
  border-color: #acd9c2;
  color: #176447;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 18px;
  min-height: 104px;
}

.stat span {
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
}

.stat strong {
  font-size: 28px;
  line-height: 1.1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.dashboard-service-alerts {
  margin-top: 18px;
}

.panel {
  overflow: hidden;
}

.panel-heading {
  min-height: 64px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.import-status {
  margin: 0;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  padding: 10px 11px;
  background: #ffffff;
  color: var(--ink);
}

input[readonly] {
  background: #f8fafc;
  color: #475467;
  cursor: default;
}

textarea {
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

th {
  background: #fbfcfd;
  color: #475467;
  font-size: 13px;
  font-weight: 750;
}

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

.fleet-table {
  min-width: 780px;
}

.fleet-table th,
.fleet-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fleet-table th:nth-child(1),
.fleet-table td:nth-child(1) {
  width: 230px;
}

.fleet-table th:nth-child(2),
.fleet-table td:nth-child(2) {
  width: 110px;
}

.fleet-table th:nth-child(3),
.fleet-table td:nth-child(3) {
  width: 140px;
}

.fleet-table th:nth-child(4),
.fleet-table td:nth-child(4) {
  width: 150px;
}

.fleet-table th:nth-child(5),
.fleet-table td:nth-child(5) {
  width: 92px;
}

.fleet-table th:nth-child(6),
.fleet-table td:nth-child(6) {
  width: 96px;
}

.vehicle-table-row {
  cursor: pointer;
}

.vehicle-table-row:hover,
.vehicle-table-row.expanded {
  background: #f8fbfc;
}

.vehicle-table-row td:first-child span {
  display: block;
  margin-top: 3px;
  color: #475467;
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vehicle-detail-row td {
  height: auto;
  padding: 0 14px 12px;
  white-space: normal;
  overflow: visible;
}

.vehicle-detail-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 10px 14px;
  align-items: end;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: #243447;
}

.vehicle-detail-panel span {
  display: block;
  margin-bottom: 4px;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.vehicle-detail-panel p {
  margin: 0;
  color: #243447;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.vehicle-detail-actions {
  justify-self: end;
  grid-row: span 2;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
  min-width: max-content;
}

.repair-list {
  display: grid;
}

.repair-table-wrap {
  overflow-x: hidden;
}

.compact-repairs-table {
  min-width: 0;
}

.compact-repairs-table th,
.compact-repairs-table td {
  padding: 9px 12px;
  height: 48px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-repairs-table th:nth-child(1),
.compact-repairs-table td:nth-child(1) {
  width: 88px;
}

.compact-repairs-table th:nth-child(2),
.compact-repairs-table td:nth-child(2) {
  width: 25%;
}

.compact-repairs-table th:nth-child(3),
.compact-repairs-table td:nth-child(3) {
  width: 118px;
}

.compact-repairs-table th:nth-child(4),
.compact-repairs-table td:nth-child(4) {
  width: 15%;
}

.compact-repairs-table th:nth-child(5),
.compact-repairs-table td:nth-child(5) {
  width: 126px;
}

.compact-repairs-table th:nth-child(6),
.compact-repairs-table td:nth-child(6) {
  width: 108px;
}

.compact-repairs-table th:nth-child(7),
.compact-repairs-table td:nth-child(7) {
  width: 146px;
}

.repair-table-row {
  cursor: pointer;
}

.repair-table-row:hover,
.repair-table-row.expanded {
  background: #f8fbfc;
}

.repair-detail-row td {
  height: auto;
  padding: 0 14px 12px 106px;
  white-space: normal;
  overflow: visible;
}

.repair-detail-panel {
  display: grid;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: #243447;
}

.repair-detail-panel span {
  display: block;
  margin-bottom: 4px;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.repair-detail-panel p {
  margin: 0;
  color: #243447;
  line-height: 1.45;
  white-space: pre-wrap;
}

.repair-row {
  display: grid;
  grid-template-columns: 92px minmax(320px, 1fr) minmax(150px, 210px) max-content;
  gap: 12px;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  min-height: 72px;
}

.repair-row:last-child {
  border-bottom: 0;
}

.repair-date,
.repair-main,
.repair-summary {
  display: grid;
  min-width: 0;
}

.repair-date strong {
  font-size: 14px;
  line-height: 1.2;
}

.repair-main {
  gap: 5px;
}

.repair-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.repair-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repair-title span {
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}

.repair-scope {
  min-width: 0;
  line-height: 1.35;
  color: #243447;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repair-summary {
  gap: 5px;
  align-content: center;
  justify-items: start;
}

.repair-summary span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repair-row .actions {
  justify-content: flex-end;
}

.description-cell {
  line-height: 1.35;
  color: #243447;
}

.mini-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 0 10px;
}

.mini-button.danger {
  color: var(--danger);
  border-color: #f0b7b1;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1849a9;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.ok {
  background: #eaf7ef;
  color: var(--ok);
}

.badge.warn {
  background: #fff5dc;
  color: var(--warn);
}

.badge.danger {
  background: #fff1f0;
  color: var(--danger);
}

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

.modal {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: min(980px, calc(100vw - 28px));
  padding: 0;
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.48);
}

.modal-body {
  padding: 20px;
}

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

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

.extract-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 2px 0 14px;
}

.extract-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.extract-heading h3 {
  margin: 0;
  font-size: 15px;
}

.extract-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.extract-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.invoice-review {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 14px;
  padding: 14px;
  background: #ffffff;
}

.invoice-items-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

.invoice-items-table {
  min-width: 880px;
  table-layout: auto;
}

.invoice-items-table th,
.invoice-items-table td {
  padding: 8px;
  white-space: normal;
}

.invoice-items-table select,
.invoice-items-table input {
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 7px;
}

.invoice-items-table .item-type {
  min-width: 118px;
}

.invoice-items-table .item-code {
  min-width: 130px;
}

.invoice-items-table .item-name {
  min-width: 300px;
}

.invoice-items-table .item-unit {
  min-width: 86px;
}

.invoice-items-table .item-price {
  min-width: 110px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 650;
  margin-bottom: 14px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #17202a;
  color: #ffffff;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1280px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
  }

  .nav-button {
    text-align: center;
    width: auto;
    min-width: 112px;
  }

  .app {
    padding: 18px;
  }

  .stats-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 760px;
  }

  .vehicle-detail-panel {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .vehicle-detail-actions {
    justify-self: start;
    grid-row: auto;
  }

  .repair-row {
    grid-template-columns: 86px minmax(220px, 1fr) 124px;
  }

  .repair-summary {
    grid-column: 2 / 3;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .repair-row .actions {
    grid-column: 3 / 4;
    grid-row: 1 / 3;
  }
}

@media (max-width: 920px) {
  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .panel-actions {
    justify-content: flex-start;
  }

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

  .extract-heading {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .topbar-actions,
  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    width: 100%;
  }

  h1 {
    font-size: 24px;
  }

  .repair-row {
    grid-template-columns: 1fr;
  }

  .repair-summary,
  .repair-row .actions {
    grid-column: auto;
    grid-row: auto;
  }

  .repair-row .actions {
    justify-content: flex-start;
  }
}
