:root {
  --bg: #f6f7f3;
  --ink: #172026;
  --muted: #66717a;
  --line: #dfe4dd;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-2: #1d4ed8;
  --danger: #b42318;
  --soft: #e8f4f1;
  --shadow: 0 18px 45px rgba(23, 32, 38, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app-root {
  text-transform: uppercase;
}

.app-root input,
.app-root select,
.app-root textarea,
.app-root button,
.app-root input::placeholder,
.app-root textarea::placeholder {
  text-transform: uppercase;
}

.app-root input[type="email"],
.app-root input[type="password"] {
  text-transform: none;
}

.app-root[hidden],
.login-screen[hidden] {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3ef;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(22, 38, 33, 0.12);
}

.login-panel h1,
.login-panel p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button,
.file-button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.connection-badge {
  min-height: 42px;
  border-radius: 999px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  background: #fff4cf;
  color: #7a4b00;
  border: 1px solid #f3d47a;
  font-weight: 800;
  font-size: 0.84rem;
}

.connection-badge.online {
  background: #e8f4f1;
  border-color: #b7dcd5;
  color: var(--accent);
}

.local-mode-warning {
  border-color: #f0c15a;
  background: #fff8e6;
}

.local-mode-warning h2 {
  color: #805200;
}

.local-mode-warning p {
  margin: 0;
  color: #6a5b3a;
  font-weight: 800;
  line-height: 1.35;
}

button:hover,
.file-button:hover {
  filter: brightness(0.96);
}

.ghost {
  color: var(--ink);
  background: #edf1ea;
}

.secondary {
  background: var(--accent-2);
}

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

.file-button input {
  display: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 3;
}

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

h1 {
  font-size: clamp(1.7rem, 3vw, 2.7rem);
}

h2 {
  font-size: 1.05rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.small {
  color: var(--muted);
  line-height: 1.45;
  margin: 8px 0 14px;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 48px) 40px;
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.sidebar section,
.workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar section {
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  margin-top: 13px;
  color: #3d4850;
  font-size: 0.9rem;
  font-weight: 700;
}

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

.home-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.home-toggle input {
  width: 17px;
  min-height: 17px;
  margin: 0;
  accent-color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd7cf;
  border-radius: 7px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.17);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  line-height: 1.4;
}

.sidebar button {
  width: 100%;
  margin-top: 14px;
}

.user-form {
  margin-bottom: 12px;
}

.user-list {
  display: grid;
  gap: 8px;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 8px 8px 10px;
  background: #fbfcfa;
}

.user-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.user-row button {
  margin-top: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs button {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.tabs button.active {
  color: var(--ink);
  background: var(--soft);
  border-color: #cfe4de;
}

.tab-panel {
  display: none;
  padding: 20px;
}

.tab-panel.active {
  display: block;
}

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

.finance-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.finance-actions button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.78rem;
}

.day-planner {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  margin: 16px 0;
  padding: 16px;
}

.primary-planner {
  background: #f3fbf8;
  border-color: #bdded6;
  margin-top: 6px;
}

.panel-heading.compact {
  margin-bottom: 10px;
}

.stops-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.add-stop-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  grid-column: 1 / -1;
}

.add-stop-row button {
  margin-top: 13px;
  white-space: nowrap;
}

.stop-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.day-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.day-actions button {
  width: auto;
  margin-top: 0;
}

.day-total-km-field {
  grid-column: 1 / 2;
}

.day-total-km-field input {
  text-align: right;
}

.day-location-field {
  grid-column: 1 / -1;
}

.stop-card {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 10px;
  align-items: center;
  border: 1px solid #bdded6;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.stop-index {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 0.82rem;
}

.stop-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.stop-card small {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 2px;
}

.day-route-header td {
  padding: 14px 16px;
  background: #e7f2ee;
  border-top: 2px solid #9bc9bd;
}

.day-route-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  width: 100%;
}

.day-route-summary strong,
.day-route-summary b {
  white-space: nowrap;
}

.day-route-summary span {
  min-width: 0;
  word-break: normal;
  overflow-wrap: break-word;
  color: var(--muted);
  line-height: 1.35;
}

.route-calendar {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.calendar-weekdays,
.monthly-route-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(118px, 1fr));
  gap: 8px;
}

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

.monthly-route-grid {
  align-items: stretch;
}

.calendar-day {
  min-height: 132px;
  display: grid;
  align-content: start;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfa;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font-weight: 700;
}

.calendar-day.has-route {
  border-color: #9bc9bd;
  background: #eff8f5;
}

.calendar-day.day-off {
  border-color: #d9c48e;
  background: #fff8e5;
}

.calendar-day.has-note {
  border-color: #b7c7df;
  background: #f3f7ff;
}

.calendar-day.empty-day {
  border-style: dashed;
  background: transparent;
  cursor: default;
}

.calendar-day:not(.empty-day):hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
  filter: none;
}

.calendar-day header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.calendar-day header strong {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.calendar-day header span,
.calendar-day b {
  white-space: nowrap;
  font-size: 0.76rem;
  font-weight: 900;
}

.calendar-day p {
  margin: 0;
  color: var(--muted);
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.calendar-segments {
  display: grid;
  gap: 5px;
}

.calendar-details {
  margin-top: 2px;
}

.calendar-details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 900;
}

.calendar-segment {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 44px 24px 24px;
  gap: 5px;
  align-items: center;
  margin-top: 5px;
}

.calendar-segment span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
}

.calendar-segment strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-segment .km-input {
  min-height: 30px;
  padding: 3px 5px;
  font-size: 0.72rem;
}

.calendar-segment button {
  min-height: 24px;
  border: 0;
  border-radius: 6px;
  background: #e8eee6;
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 900;
}

.route-detail-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.route-detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.route-detail-card summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  padding: 12px 14px;
  color: var(--ink);
  font-weight: 900;
}

.route-detail-card summary span {
  color: var(--muted);
}

.day-total-editor {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.day-total-editor label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.day-total-editor input {
  width: 96px;
  min-height: 38px;
  padding: 6px 10px;
  text-align: right;
}

.day-total-editor b {
  min-width: 128px;
  color: var(--ink);
  text-align: right;
}

.route-detail-row {
  display: grid;
  grid-template-columns: 36px minmax(220px, 1fr) 110px 120px 42px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

.route-detail-row strong {
  overflow-wrap: anywhere;
}

.route-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.route-day-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.route-day-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 2px solid #9bc9bd;
  background: #e7f2ee;
}

.route-day-head strong,
.route-day-head b {
  font-size: 1rem;
  font-weight: 900;
}

.route-day-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.route-segments {
  display: grid;
}

.route-segment-row {
  display: grid;
  grid-template-columns: 42px minmax(120px, 0.8fr) 22px minmax(180px, 1.3fr) 112px 132px auto;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.route-segment-row:first-child {
  border-top: 0;
}

.route-place {
  min-width: 0;
}

.route-place span,
.route-destination {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.route-place small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
}

.route-arrow {
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.route-km-cell {
  display: grid;
  gap: 3px;
}

.route-money {
  white-space: nowrap;
}

.segment-number {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.divider-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 4px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.divider-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.status-line {
  min-height: 24px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.download-ready {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 0 12px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

.download-tray {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  align-items: center;
  gap: 8px 10px;
  max-width: min(520px, calc(100vw - 36px));
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.18);
}

.download-tray strong,
.download-tray span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-tray strong {
  grid-column: 1 / 2;
  font-size: 0.86rem;
}

.download-tray span {
  grid-column: 1 / 2;
  color: var(--muted);
  font-size: 0.75rem;
}

.download-tray .download-ready {
  grid-row: 1 / 3;
  grid-column: 2 / 3;
  margin-left: 0;
}

.download-tray button {
  grid-row: 1 / 3;
  grid-column: 3 / 4;
}

.api-note {
  margin: -8px 0 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: #f8faf7;
  color: #4b5962;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td input,
td select {
  min-height: 36px;
}

.km-input {
  max-width: 92px;
}

.km-input.needs-km {
  border-color: #d98b00;
  background: #fff8e5;
}

.km-warning {
  display: block;
  margin-top: 4px;
  color: #9a5b00;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.resolved-place {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
}

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

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 7px;
}

.drop-zone {
  border: 1px dashed #9fb7ae;
  border-radius: 8px;
  background: #f7faf8;
  min-height: 104px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 22px;
  color: var(--muted);
  margin-bottom: 16px;
}

.drop-zone strong {
  color: var(--ink);
  display: block;
  margin-bottom: 6px;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--soft);
}

.documents-toolbar {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.documents-toolbar > span:first-child {
  margin-right: auto;
  color: var(--ink);
}

.status-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 6px;
  background: #d98b00;
}

.status-dot.identified {
  background: var(--accent);
}

.status-dot.processing {
  background: var(--accent-2);
}

.documents-list {
  display: grid;
  gap: 8px;
}

.documents-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.document-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-left: 3px solid #d98b00;
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.document-item.identified {
  border-left-color: var(--accent);
}

.document-item.processing {
  border-left-color: var(--accent-2);
}

.document-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #edf3ef;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 900;
}

.document-main {
  min-width: 0;
}

.document-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.document-title-row strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.document-source {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.source-badge {
  display: inline-block;
  margin-top: 4px;
  color: #6b747c;
  font-size: 0.62rem;
  font-weight: 800;
}

.document-status {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  color: #8b5700;
  font-size: 0.68rem;
  font-weight: 900;
}

.document-status.identified {
  color: var(--accent);
}

.document-status.processing {
  color: var(--accent-2);
}

.document-fields {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(145px, 0.7fr) minmax(100px, 0.5fr) minmax(210px, 1.4fr);
  gap: 8px;
  margin-top: 10px;
}

.document-fields label {
  margin-top: 0;
  gap: 4px;
  color: var(--muted);
  font-size: 0.64rem;
}

.document-fields input,
.document-fields select {
  min-height: 36px;
  padding: 7px 9px;
  font-size: 0.78rem;
}

.document-actions {
  display: flex;
  gap: 6px;
}

.text-icon {
  width: auto;
  min-width: 42px;
  padding: 0 9px;
  font-size: 0.62rem;
  letter-spacing: 0;
}

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

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 21, 27, 0.58);
}

.preview-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(960px, 100%);
  height: min(760px, 88vh);
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 30, 36, 0.28);
}

.preview-dialog header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.preview-dialog h2 {
  margin: 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.preview-body {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 16px;
  background: #f6f8f5;
}

.preview-body img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  object-fit: contain;
}

.preview-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 6px;
  background: #fff;
}

.preview-table-wrap {
  width: 100%;
  max-height: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-table-wrap table {
  min-width: 820px;
}

.preview-table-wrap td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  vertical-align: top;
}

.preview-body pre,
.preview-fallback,
.preview-loading {
  width: 100%;
  max-width: 720px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
  color: var(--ink);
  white-space: pre-wrap;
}

.preview-fallback span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.preview-fallback button {
  margin-top: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
}

.report-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  overflow-x: auto;
}

.report-preview h3 {
  margin: 0 0 12px;
}

.report-preview table {
  min-width: 860px;
}

.report-preview dl {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 8px 16px;
  margin: 0 0 18px;
}

.report-preview dt {
  color: var(--muted);
  font-weight: 800;
}

.muted-line {
  color: var(--muted);
  font-weight: 700;
}

.finance-matrix-wrap {
  overflow-x: auto;
  margin-bottom: 18px;
}

.finance-matrix {
  min-width: 980px;
}

.finance-matrix th,
.finance-matrix td {
  padding: 10px 12px;
  text-align: right;
}

.finance-matrix th:first-child,
.finance-matrix td:first-child {
  text-align: left;
}

.finance-matrix tbody tr:nth-child(odd) {
  background: #f7faf7;
}

.finance-doc-list {
  display: grid;
  gap: 8px;
}

.finance-doc-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(180px, 1fr) 110px 104px auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 4px solid #d59000;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.finance-doc-row.identified {
  border-left-color: var(--accent);
}

.finance-doc-row.processing {
  border-left-color: var(--accent-2);
}

.finance-doc-row strong,
.finance-doc-row span,
.finance-doc-row b {
  overflow-wrap: anywhere;
}

.finance-doc-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 800;
}

.finance-doc-list.compact .finance-doc-row {
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) 96px 78px auto;
  padding: 8px 10px;
}

.finance-doc-list.compact .finance-doc-row span,
.finance-doc-list.compact .finance-doc-row small {
  font-size: 0.72rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 800;
}

.file-origin {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 8px;
  border-radius: 999px;
  padding: 0 8px;
  background: #edf1ea;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

.compact-empty {
  border: 1px dashed #bdded6;
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
}

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

  .stops-form,
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stops-form .wide {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .add-stop-row {
    grid-column: 1 / -1;
  }

  .document-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-weekdays {
    display: none;
  }

  .monthly-route-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-day.empty-day {
    display: none;
  }

  .route-segment-row {
    grid-template-columns: 42px minmax(120px, 1fr) 22px minmax(160px, 1fr);
  }

  .route-km-cell,
  .route-money,
  .route-segment-row .row-actions {
    grid-column: 2 / -1;
  }

  .finance-doc-row {
    grid-template-columns: minmax(160px, 1fr) minmax(150px, 1fr);
  }

  .finance-doc-list.compact .finance-doc-row {
    grid-template-columns: minmax(160px, 1fr) minmax(150px, 1fr);
  }

  .route-detail-row {
    grid-template-columns: 36px minmax(0, 1fr) 110px;
  }

  .route-detail-row b,
  .route-detail-row .icon-button {
    grid-column: auto;
  }
}

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

  .route-form,
  .stops-form,
  .add-stop-row,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .day-total-km-field {
    grid-column: 1 / -1;
  }

  .document-item {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .document-icon {
    width: 36px;
    height: 36px;
  }

  .document-actions {
    grid-column: 2;
    justify-content: flex-end;
  }

  .document-fields {
    grid-template-columns: 1fr;
  }

  .documents-toolbar span:not(:first-child) {
    display: none;
  }

  .route-day-head,
  .route-segment-row {
    grid-template-columns: 1fr;
  }

  .route-day-head b,
  .route-money {
    justify-self: start;
  }

  .route-segment-row {
    gap: 8px;
  }

  .route-arrow {
    display: none;
  }

  .route-km-cell,
  .route-money,
  .route-segment-row .row-actions {
    grid-column: auto;
  }

  .preview-modal {
    padding: 10px;
  }

  .preview-dialog {
    height: 92vh;
  }

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

  .monthly-route-grid {
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: 0;
  }

  .route-detail-card summary,
  .route-detail-row {
    grid-template-columns: 1fr;
  }

  .route-detail-card summary {
    display: grid;
  }

  .day-total-editor {
    justify-content: flex-start;
  }

  .day-total-editor b {
    min-width: auto;
    text-align: left;
  }

  .finance-doc-list.compact .finance-doc-row {
    grid-template-columns: 1fr;
  }

  .tabs button,
  .header-actions button {
    flex: 1 0 auto;
  }

  .day-route-summary {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .day-route-summary span {
    max-width: 100%;
  }
}
