:root {
  --ink: #20242a;
  --muted: #667085;
  --line: #d9e0e7;
  --paper: #ffffff;
  --wash: #f5f7f8;
  --nav: #263238;
  --nav-soft: #34454d;
  --green: #2d7d5f;
  --blue: #2f6f9f;
  --amber: #ae6d13;
  --red: #b54747;
  --teal: #24756a;
  --shadow: 0 18px 45px rgba(21, 31, 40, 0.08);
}

* {
  box-sizing: border-box;
}

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

body.booting .app-shell,
body.booting .mobile-nav,
body.booting dialog,
body.booting #receipt-upload-input {
  display: none;
}

.no-script-screen {
  align-items: center;
  background: var(--wash);
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--nav);
  color: #f6fbfc;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-mark {
  align-items: center;
  background: #e8f6f2;
  border-radius: 8px;
  color: var(--teal);
  display: grid;
  font-weight: 800;
  height: 44px;
  place-items: center;
  width: 44px;
}

.brand span,
.auth-card span {
  color: #bad1d5;
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item,
.mobile-item {
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
}

.nav-item {
  border-radius: 8px;
  color: #d8e5e8;
  padding: 12px 14px;
}

.nav-item.active,
.nav-item:hover {
  background: var(--nav-soft);
  color: #ffffff;
}

.auth-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  margin-top: auto;
  padding: 16px;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.filters,
.section-header,
.modal-header,
.modal-actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

h2 {
  font-size: 22px;
}

h3 {
  font-size: 16px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.primary-button,
.secondary-button,
.icon-button {
  border-radius: 8px;
  min-height: 40px;
}

.primary-button {
  background: var(--teal);
  border: 1px solid var(--teal);
  color: white;
  font-weight: 700;
  padding: 0 16px;
}

.secondary-button {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0 14px;
}

.auth-card .secondary-button {
  background: transparent;
  color: white;
  margin-top: 14px;
  width: 100%;
}

.auth-card .secondary-button + .secondary-button {
  margin-top: 8px;
}

.auth-screen {
  align-items: center;
  background: var(--wash);
  display: flex;
  flex-direction: column;
  gap: 14px;
  inset: 0;
  min-height: 100vh;
  padding: 24px;
  justify-content: center;
  position: fixed;
  z-index: 20;
}

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

.auth-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  max-width: 440px;
  padding: 26px;
  width: 100%;
}

.auth-message {
  background: #fdeaea;
  border: 1px solid #f4b7b7;
  border-radius: 8px;
  color: var(--red);
  max-width: 440px;
  padding: 12px 14px;
  width: 100%;
}

.row-select {
  background: #fbfcfd;
  min-height: 34px;
  padding: 5px 8px;
}

.icon-button {
  background: transparent;
  border: 1px solid var(--line);
  font-size: 22px;
  height: 40px;
  line-height: 1;
  width: 40px;
}

.filters {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(8, minmax(130px, 1fr));
  margin-bottom: 22px;
  padding: 16px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

input,
select,
textarea {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid,
.category-grid,
.trip-grid,
.report-grid,
.user-grid {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.category-grid,
.trip-grid,
.report-grid,
.user-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card,
.table-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card {
  padding: 18px;
}

.metric-value {
  display: block;
  font-size: 28px;
  font-weight: 800;
  margin-top: 8px;
}

.metric-note {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.split-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
}

.compact-insights {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.8fr);
  margin-top: 14px;
}

.compact-card {
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 14px;
  min-height: 54px;
  padding: 12px 14px;
}

.compact-card .eyebrow {
  flex: 0 0 auto;
}

.inline-list {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-width: 0;
}

.inline-list span {
  white-space: nowrap;
}

.table-card {
  overflow: hidden;
}

.table-header {
  padding: 16px 18px;
}

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

th,
td {
  border-top: 1px solid var(--line);
  padding: 13px 18px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.status.good {
  background: #e5f5ec;
  color: var(--green);
}

.status.warn {
  background: #fff3dc;
  color: var(--amber);
}

.status.danger {
  background: #fdeaea;
  color: var(--red);
}

.category-card {
  border-left: 4px solid var(--teal);
}

.category-card.gas {
  border-left-color: var(--blue);
}

.category-card.food {
  border-left-color: var(--green);
}

.category-card.lodging {
  border-left-color: var(--amber);
}

.category-card.mileage {
  border-left-color: var(--teal);
}

.stack {
  display: grid;
  gap: 14px;
}

.timeline-item {
  border-left: 3px solid var(--line);
  padding-left: 12px;
}

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

.receipt-tile {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  padding: 13px 0 0;
}

.passkey-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
}

.file-icon {
  align-items: center;
  background: #edf4f4;
  border-radius: 8px;
  color: var(--teal);
  display: grid;
  font-weight: 900;
  height: 42px;
  place-items: center;
  width: 42px;
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(22, 32, 38, 0.28);
  max-width: 720px;
  padding: 0;
  width: calc(100% - 32px);
}

dialog::backdrop {
  background: rgba(18, 27, 31, 0.52);
}

.modal-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

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

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-button {
  align-items: center;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: inline-grid;
  font-size: 12px;
  font-weight: 800;
  height: 34px;
  min-height: 32px;
  place-items: center;
  padding: 0 9px;
}

.icon-action {
  font-size: 17px;
  padding: 0;
  width: 34px;
}

.icon-action.pdf {
  font-size: 12px;
  position: relative;
}

.icon-action.pdf::after {
  content: "PDF";
  font-size: 9px;
  font-weight: 900;
  position: absolute;
}

.mini-button:disabled {
  color: #a5afb8;
  cursor: not-allowed;
  opacity: 0.55;
}

.mobile-nav {
  display: none;
}

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

  .sidebar {
    display: none;
  }

  .workspace {
    padding: 18px 16px 82px;
  }

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

  .filters,
  .metric-grid,
  .category-grid,
  .trip-grid,
  .report-grid,
  .user-grid,
  .compact-insights,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .compact-card {
    align-items: flex-start;
    flex-direction: column;
  }

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

  table {
    min-width: 980px;
  }

  .mobile-nav {
    background: var(--paper);
    border-top: 1px solid var(--line);
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    left: 0;
    position: fixed;
    right: 0;
    z-index: 5;
  }

  .mobile-item {
    color: var(--muted);
    min-height: 58px;
    text-align: center;
  }

  .mobile-item.active {
    color: var(--teal);
    font-weight: 800;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 26px;
  }

  .top-actions,
  .top-actions button,
  .form-grid {
    width: 100%;
  }

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