:root {
  --bg: #f3f6ef;
  --paper: #ffffff;
  --paper-soft: #f9fbf6;
  --ink: #172019;
  --muted: #657166;
  --line: #dde7d8;
  --green: #27733a;
  --green-deep: #133f22;
  --lime: #bddc50;
  --amber: #b77a14;
  --amber-soft: #fff4d8;
  --danger: #a74438;
  --danger-soft: #ffe8e4;
  --graphite: #1e241f;
  --shadow: 0 18px 45px rgba(23, 32, 25, 0.13);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.app-hero {
  position: relative;
  isolation: isolate;
  min-height: 430px;
  padding: 22px clamp(18px, 4vw, 56px) 42px;
  color: #ffffff;
  background:
    linear-gradient(90deg, rgba(12, 22, 15, 0.94) 0%, rgba(12, 22, 15, 0.84) 38%, rgba(12, 22, 15, 0.42) 72%),
    url("assets/tractocamion-actros-dashboard.png") center right / cover;
}

.app-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  z-index: -1;
  height: 170px;
  background: linear-gradient(180deg, rgba(243, 246, 239, 0), var(--bg));
}

.topbar,
.hero-content,
.content-grid {
  width: min(1320px, 100%);
  margin-inline: auto;
}

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

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--lime);
  font-weight: 900;
  letter-spacing: 0;
}

.brand-lockup strong {
  display: block;
  font-size: 1.05rem;
}

.brand-kicker,
.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--lime);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.ghost-button,
.text-button,
.mini-button,
.icon-button,
.primary-button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  font-weight: 800;
}

.ghost-button {
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  backdrop-filter: blur(12px);
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.17);
}

.sync-pill,
.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.78rem;
  font-weight: 900;
}

.sync-pill[hidden],
.user-pill[hidden],
.ghost-button[hidden] {
  display: none;
}

.sync-pill.ok {
  color: var(--lime);
}

.sync-pill.warning {
  color: #ffe0a3;
}

.sync-pill.error {
  color: #ffd2cb;
}

.hero-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.95fr);
  gap: clamp(24px, 5vw, 60px);
  align-items: end;
  padding-top: 82px;
}

.hero-copy {
  max-width: 660px;
}

.hero-copy h1 {
  margin: 14px 0 14px;
  font-size: clamp(2.25rem, 6vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  margin: 0;
  max-width: 660px;
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  line-height: 1.55;
}

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

.stat-card {
  min-height: 126px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.11);
  backdrop-filter: blur(16px);
}

.stat-card span,
.stat-card small {
  display: block;
  color: rgba(255, 255, 255, 0.74);
}

.stat-card strong {
  display: block;
  margin: 8px 0 4px;
  color: #ffffff;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1;
}

.stat-card.accent strong {
  color: var(--lime);
}

.stat-card.warning strong {
  color: #ffe0a3;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.18fr);
  grid-template-areas:
    "auth auth"
    "entry workspace"
    "debtors workspace";
  gap: 22px;
  padding: 28px clamp(18px, 4vw, 56px) 56px;
}

.auth-panel {
  grid-area: auth;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 24px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 22px;
}

.auth-panel[hidden] {
  display: none;
}

.auth-panel h2 {
  margin: 6px 0 10px;
}

.auth-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 800;
}

.auth-locked .entry-panel,
.auth-locked .workspace,
.auth-locked .debtor-panel {
  display: none;
}

.entry-panel,
.workspace,
.debtor-panel {
  min-width: 0;
}

.entry-panel {
  grid-area: entry;
}

.workspace {
  grid-area: workspace;
}

.debtor-panel {
  grid-area: debtors;
}

.section-heading,
.line-heading,
.toolbar,
.form-total,
.trip-top,
.trip-actions,
.debtor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h2,
.line-heading h3 {
  margin: 4px 0 0;
}

.section-heading h2 {
  font-size: 1.45rem;
}

.line-heading h3 {
  font-size: 1rem;
}

.entry-panel,
.workspace,
.debtor-panel,
.trip-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(23, 32, 25, 0.03);
}

.entry-panel,
.workspace,
.debtor-panel {
  padding: 20px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--ink);
  min-height: 42px;
  padding: 10px 12px;
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39, 115, 58, 0.16);
}

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

.full-span {
  grid-column: 1 / -1;
}

.single-field {
  grid-template-columns: 1fr;
}

.form-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.line-editor {
  min-width: 0;
}

.line-heading {
  margin-bottom: 10px;
  align-items: center;
}

.line-list {
  display: grid;
  gap: 9px;
}

.money-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(116px, 0.45fr) 38px;
  gap: 8px;
  align-items: center;
}

.money-row input {
  min-width: 0;
}

.line-name {
  min-width: 180px;
}

.text-button {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--green);
}

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

.mini-button {
  min-height: 34px;
  padding: 7px 10px;
  background: var(--green-deep);
  color: #ffffff;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  min-height: 38px;
  place-items: center;
  background: var(--danger-soft);
  color: var(--danger);
}

.primary-button {
  width: 100%;
  padding: 12px 16px;
  background: var(--green);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(39, 115, 58, 0.22);
}

.secondary-button {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--green-deep);
}

.primary-button:hover,
.secondary-button:hover,
.mini-button:hover {
  filter: brightness(1.05);
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-hint {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.reminder-box {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf0;
}

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

.reminder-heading h3 {
  margin: 4px 0 0;
  font-size: 1rem;
}

.check-row {
  display: inline-flex;
  grid-template-columns: none;
  width: fit-content;
  align-items: center;
  gap: 8px;
  color: var(--green-deep);
  white-space: nowrap;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.helper-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.form-total {
  flex-wrap: wrap;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f7fbef, #ffffff);
}

.form-total span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.form-total strong {
  color: var(--green-deep);
  font-size: 1.15rem;
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.toolbar label {
  min-width: 170px;
  flex: 1 1 170px;
}

.search-field {
  flex: 2 1 280px;
}

.finance-bars {
  display: grid;
  gap: 9px;
  margin-bottom: 16px;
}

.finance-bars > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e5d5;
}

.bar-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--lime));
  transition: width 180ms ease;
}

.trip-list,
.debtor-list {
  display: grid;
  gap: 12px;
}

.trip-card {
  padding: 16px;
}

.trip-card.is-overdue {
  border-color: #efc2ba;
}

.trip-card.is-paid {
  background: linear-gradient(180deg, #ffffff, #f8fbf6);
}

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

.route-title h3 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.25;
}

.route-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green-deep);
  background: #e6f4df;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.status-pill.paid {
  color: var(--green-deep);
  background: #dff1df;
}

.status-pill.pending {
  color: #5c4b08;
  background: #fff2bf;
}

.status-pill.soon {
  color: #6d4300;
  background: var(--amber-soft);
}

.status-pill.overdue {
  color: var(--danger);
  background: var(--danger-soft);
}

.trip-numbers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.number-chip {
  min-width: 0;
  padding: 11px;
  border-radius: 8px;
  background: var(--paper-soft);
}

.number-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.number-chip strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.number-chip.profit.negative strong {
  color: var(--danger);
}

.number-chip.profit.positive strong {
  color: var(--green);
}

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

.mini-list {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-list h4 {
  margin: 0 0 8px;
  font-size: 0.86rem;
}

.mini-list ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.86rem;
}

.mini-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.mini-list strong {
  color: var(--ink);
}

.trip-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--lime);
  background: #f8fbf0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.trip-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.trip-actions button,
.debtor-row button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--green-deep);
  font-size: 0.84rem;
  font-weight: 900;
  padding: 8px 10px;
}

.trip-actions .danger-action {
  color: var(--danger);
}

.debtor-panel {
  align-self: start;
}

.debtor-row {
  align-items: flex-start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.debtor-row.overdue {
  border-color: #efc2ba;
  background: #fff8f7;
}

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

.debtor-main strong,
.debtor-main span,
.debtor-main small {
  display: block;
}

.debtor-main span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.debtor-main small {
  margin-top: 8px;
  color: var(--amber);
  font-weight: 900;
}

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

.empty-state strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

@media (max-width: 1120px) {
  .hero-content,
  .content-grid {
    grid-template-columns: 1fr;
  }

.content-grid {
    grid-template-areas:
      "auth"
      "entry"
      "workspace"
      "debtors";
  }

  .hero-content {
    padding-top: 58px;
  }
}

@media (max-width: 760px) {
  .app-hero {
    min-height: auto;
    padding: 16px 16px 36px;
    background:
      linear-gradient(180deg, rgba(12, 22, 15, 0.94), rgba(12, 22, 15, 0.76)),
      url("assets/tractocamion-actros-dashboard.png") center / cover;
  }

  .topbar,
  .topbar-actions,
  .section-heading,
  .line-heading,
  .debtor-row {
    align-items: stretch;
  }

  .topbar,
  .hero-content,
  .section-heading,
  .debtor-row {
    flex-direction: column;
  }

  .topbar,
  .section-heading,
  .debtor-row {
    display: flex;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .ghost-button,
  .topbar-actions button {
    flex: 1;
  }

  .hero-copy h1 {
    font-size: 2.55rem;
  }

  .summary-grid,
  .auth-panel,
  .field-grid,
  .form-columns,
  .trip-numbers,
  .line-breakdown {
    grid-template-columns: 1fr;
  }

  .content-grid {
    padding: 18px 14px 40px;
  }

  .entry-panel,
  .workspace,
  .debtor-panel {
    padding: 16px;
  }

  .money-row {
    grid-template-columns: minmax(0, 1fr) 108px 38px;
  }

  .line-name {
    min-width: 0;
  }

  .reminder-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 470px) {
  .money-row {
    grid-template-columns: 1fr 38px;
  }

  .money-row .line-amount {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .money-row .icon-button {
    grid-column: 2;
    grid-row: 1;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-hero {
    min-height: auto;
    color: #111111;
    background: #ffffff;
  }

  .app-hero::after,
  .topbar-actions,
  .entry-panel,
  .toolbar,
  .trip-actions,
  .debtor-row button {
    display: none;
  }

  .content-grid {
    display: block;
    padding: 0 24px 24px;
  }

  .workspace,
  .debtor-panel,
  .trip-card {
    break-inside: avoid;
    margin-bottom: 16px;
    box-shadow: none;
  }
}
