:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172019;
  background: #eef2ed;
  line-height: 1.5;
  --green: #1f5131;
  --green-dark: #173323;
  --green-soft: #e8eee8;
  --cream: #f4efe4;
  --line: #ccd5cd;
  --muted: #5b655e;
  --danger: #9d1d1d;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }

.shell {
  width: min(1500px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 5rem;
}

.app-header,
.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-brand { display: flex; align-items: center; gap: 1rem; }
.app-logo { width: 5.2rem; height: 5.2rem; object-fit: contain; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .78rem;
  font-weight: 750;
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
  margin: .35rem 0 1.5rem;
}

h2 { margin: 0 0 .4rem; }
h3 { margin-top: 0; }
.public-link { color: inherit; }

.panel,
.session-bar,
.accounting-workspace > .table-scroll,
.accounting-workspace > .entry-form,
.accounting-workspace > .compact-form,
.accounting-workspace > .mini-summary,
.accounting-workspace > .two-column-forms {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 8px 30px rgba(23, 32, 25, .05);
}

.panel { padding: 1.25rem; }
.panel + .panel { margin-top: 1rem; }
.session-bar { margin-bottom: 1rem; padding: .9rem 1.1rem; }

button {
  border: 0;
  border-radius: .7rem;
  padding: .75rem 1rem;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button.secondary { background: var(--green-soft); color: #172019; }
button.danger { background: #f8e9e8; color: var(--danger); }
button.small { padding: .45rem .65rem; font-size: .82rem; white-space: nowrap; }
button:disabled { opacity: .55; cursor: not-allowed; }

.role-badge {
  display: inline-block;
  margin-left: .55rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: var(--green-soft);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.business-tabs {
  display: flex;
  gap: .45rem;
  overflow-x: auto;
  padding: .5rem;
  margin-bottom: .55rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 8px 30px rgba(23, 32, 25, .05);
  scrollbar-width: thin;
}

.tab-button {
  flex: 0 0 auto;
  background: transparent;
  color: #273229;
  border: 1px solid transparent;
  padding: .62rem .85rem;
}
.tab-button:hover { background: #f3f6f3; }
.tab-button.active { background: var(--green); color: #fff; }

.accounting-status {
  min-height: 1.5em;
  margin: .35rem .2rem .75rem;
  color: var(--muted);
  font-size: .9rem;
}
.accounting-status[data-kind="success"] { color: var(--green); }
.accounting-status[data-kind="error"] { color: var(--danger); }

.accounting-workspace { display: grid; gap: 1rem; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: .2rem .15rem;
}
.section-heading p:last-child { margin: .25rem 0 0; color: var(--muted); max-width: 78ch; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: .75rem;
}
.summary-card {
  min-height: 112px;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 32, 25, .04);
}
.summary-card span,
.summary-card small { display: block; color: var(--muted); }
.summary-card strong { display: block; margin: .2rem 0; font-size: clamp(1.35rem, 3vw, 2rem); }
.summary-card small { font-size: .8rem; }

.entry-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem 1rem;
  padding: 1.1rem;
}
.entry-form .form-title { grid-column: 1 / -1; }
.entry-form h3 { margin-bottom: 0; }
.entry-form label,
.compact-form label {
  display: grid;
  gap: .3rem;
  font-size: .82rem;
  font-weight: 750;
  color: #3e4941;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #bfc9c0;
  border-radius: .6rem;
  padding: .68rem .72rem;
  background: #fff;
  color: #172019;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 81, 49, .18);
  border-color: var(--green);
}
textarea { min-height: 72px; resize: vertical; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .55rem; align-items: end; flex-wrap: wrap; }
.form-help { margin: .2rem 0 0; color: var(--muted); font-size: .88rem; }

.compact-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .75rem;
  padding: .9rem 1rem;
}
.compact-form label { min-width: 130px; }

.table-scroll { overflow-x: auto; padding: .1rem; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: .7rem .72rem; border-bottom: 1px solid #e0e6e1; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #f4f7f4; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #4d5a50; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfb; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.empty-cell { text-align: center; color: var(--muted); padding: 2rem; }
.row-actions { display: flex; gap: .35rem; }
.overdue { color: var(--danger); font-weight: 750; }

.two-column-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem;
}
.two-column-forms > .entry-form { border: 1px solid #dfe6df; box-shadow: none; }

.mini-summary { padding: 1rem; }
.mini-summary h3 { margin-bottom: .7rem; }
.mini-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: .5rem;
}
.mini-summary-grid > div {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem .7rem;
  border-radius: .6rem;
  background: #f5f7f5;
}
.mini-summary-grid span { color: var(--muted); }

.dashboard-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.inset-panel { margin: 0 !important; }
.migration-notes {
  padding: 1rem 1.15rem;
  border: 1px solid #e1d9c8;
  border-radius: .9rem;
  background: #fffaf0;
}
.migration-notes ul { margin-bottom: 0; }

.brand-assets-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 1.25rem;
  align-items: center;
  background: linear-gradient(135deg, #fff 0%, #faf6ee 100%);
}
.brand-assets-copy p { max-width: 58ch; }
.brand-note { color: var(--muted); font-size: .92rem; }
.brand-preview-card {
  display: grid;
  place-items: center;
  min-height: 300px;
  padding: 1rem;
  border: 1px solid #ddd3c2;
  border-radius: .9rem;
  background: var(--cream);
}
.brand-preview-card img { max-height: 320px; object-fit: contain; }
.brand-downloads {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
}
.brand-downloads button { background: var(--green-dark); }
.brand-download-status { grid-column: 1 / -1; min-height: 1.4em; margin: 0; color: #526057; }

/* Business Trip tracker */
.business-trip-heading { align-items: center; }
.trip-launch,
.trip-start-card,
.trip-active-card,
.trip-edit-card,
.trip-history,
.trip-rate-settings {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 8px 30px rgba(23, 32, 25, .05);
}
.trip-launch { display: grid; place-items: center; gap: .45rem; padding: 2rem 1rem; text-align: center; }
.trip-launch p { margin: 0; color: var(--muted); }
.trip-primary-button { min-height: 3.3rem; padding: .9rem 1.4rem; font-size: 1.05rem; }
.trip-start-button { min-width: min(100%, 320px); font-size: 1.2rem; }
.trip-start-card,
.trip-active-card,
.trip-edit-card { padding: 1rem; }
.trip-start-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.trip-start-top h3 { margin: .15rem 0 0; font-size: 1.55rem; }
.trip-field { display: grid; gap: .4rem; margin-top: .9rem; }
.trip-field-label { font-weight: 750; color: #374239; }
.trip-field-label small { font-weight: 500; color: var(--muted); }
.choice-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice-button { background: #edf2ed; color: #223126; border: 2px solid transparent; min-height: 2.8rem; }
.choice-button.selected { background: #dce9df; color: var(--green-dark); border-color: var(--green); box-shadow: inset 0 0 0 1px rgba(31,81,49,.08); }
.trip-help { margin: .75rem 0 0; color: var(--muted); font-size: .84rem; }
.trip-active-card { border-color: #8eb59a; background: linear-gradient(135deg, #f9fff9 0%, #edf7ef 100%); }
.trip-active-card h3 { margin: .25rem 0; }
.trip-active-card p { margin: .25rem 0; }
.trip-live-metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; margin: 1rem 0; }
.trip-live-metrics > div { padding: .9rem; border-radius: .8rem; background: #fff; border: 1px solid #cbdccc; }
.trip-live-metrics span { display: block; color: var(--muted); font-size: .8rem; }
.trip-live-metrics strong { display: block; font-size: 1.6rem; }
.trip-gps-status { color: var(--green-dark); font-size: .88rem; }
.trip-end-button { background: #9d2a24; }
.trip-end-large { width: 100%; min-height: 3.2rem; margin-top: .75rem; }
.trip-edit-grid { padding: .75rem 0 0; box-shadow: none; border: 0; }
.trip-edit-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .75rem; }
.trip-history { overflow: hidden; }
.trip-history .section-heading { padding: 1rem 1rem .25rem; }
.trip-history .table-scroll { border: 0; box-shadow: none; }
.trip-rate-settings { padding: .8rem 1rem; }
.trip-rate-settings summary { cursor: pointer; font-weight: 750; }
.trip-rate-settings .compact-form { margin-top: .7rem; padding: 0; box-shadow: none; border: 0; }
.business-trip-bar {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: .75rem;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 1rem));
  display: flex;
  gap: .6rem;
  align-items: stretch;
  padding: .55rem;
  border: 1px solid #6c9276;
  border-radius: 1rem;
  background: rgba(244, 250, 245, .97);
  box-shadow: 0 12px 40px rgba(16, 43, 25, .24);
  backdrop-filter: blur(10px);
}
.trip-bar-summary { flex: 1; display: flex; align-items: center; justify-content: flex-start; gap: .65rem; text-align: left; background: transparent; color: #173323; padding: .45rem .6rem; }
.trip-bar-summary span:last-child { display: grid; line-height: 1.25; }
.trip-bar-summary small { color: var(--muted); font-weight: 600; }
.trip-live-dot { width: .75rem; height: .75rem; border-radius: 50%; background: #2f8a48; box-shadow: 0 0 0 .3rem rgba(47,138,72,.13); flex: 0 0 auto; }
.business-trip-running .shell { padding-bottom: 7.5rem; }

.error { color: var(--danger); }
.technical { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .two-column-forms,
  .dashboard-actions { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .shell { width: min(100% - 1rem, 1500px); padding-top: .75rem; }
  .app-header,
  .session-bar { align-items: flex-start; flex-direction: column; }
  .app-brand { align-items: flex-start; }
  .app-logo { width: 4rem; height: 4rem; }
  h1 { margin-bottom: .85rem; }
  .entry-form { grid-template-columns: 1fr; padding: .85rem; }
  .entry-form .form-title,
  .span-2 { grid-column: 1; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-card { min-height: 98px; padding: .8rem; }
  .summary-card strong { font-size: 1.35rem; }
  .compact-form { align-items: stretch; }
  .compact-form label, .compact-form button { width: 100%; }
  .brand-assets-panel { grid-template-columns: 1fr; }
  .brand-downloads,
  .brand-download-status { grid-column: 1; }
  .brand-downloads button { width: 100%; }
  .row-actions { flex-direction: column; }
  .choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .choice-button { width: 100%; }
  .trip-primary-button { width: 100%; }
  .business-trip-bar { bottom: .35rem; }
  .business-trip-bar .trip-end-button { min-width: 92px; }
}

@media (max-width: 430px) {
  .summary-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .summary-card span { font-size: .78rem; }
  .summary-card small { display: none; }
  .trip-live-metrics { gap: .45rem; }
  .trip-live-metrics > div { padding: .7rem; }
  .trip-live-metrics strong { font-size: 1.35rem; }
  .trip-bar-summary small { font-size: .72rem; }
}
