:root {
  --sage: #7fb0d4;
  --sage-deep: #4c6070;
  --olive-deep: #3a4d5c;
  --teal: #6fa8c9;
  --blush: #f1c9a7;
  --mint: #dceaf5;
  --soft-green: #cfe2f0;
  --beige: #d4e5f0;
  --sand: #e3eef6;
  --ink: #1b1b1b;
  --muted: #64707a;
  --card: #ffffff;
  --border: #b8d4e8;
  --border-soft: #d4e5f0;
  --danger: #c0564b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 27, 27, 0.05), 0 10px 28px rgba(27, 27, 27, 0.08);
  --shadow-lift: 0 2px 4px rgba(27, 27, 27, 0.06), 0 16px 40px rgba(27, 27, 27, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--ink);
  background: linear-gradient(160deg, #d4e5f0 0%, #c8dce8 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--sage-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Lighter display/heading weights for an airy, modern feel. */
h1, h2, h3, h4 { font-weight: 500; letter-spacing: -0.01em; }

/* Floating solid pill nav */
.site-header {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  width: calc(100% - 2rem);
  max-width: 780px;
  padding: 0.55rem 1.25rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.site-header:not(.is-auth) { justify-content: center; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 1.05rem; color: var(--sage-deep); }
.brand:hover { text-decoration: none; }
.brand-mark { display: block; flex: none; width: 28px; height: 28px; border-radius: 6px; filter: drop-shadow(0 1px 1px rgba(27, 27, 27, 0.12)); }
.site-header nav { display: flex; align-items: center; gap: 0.3rem; }

/* Nav items render as clean pill tabs with hover + active states. */
.site-header nav a,
.site-header nav .link-button {
  color: var(--ink); font-weight: 500; line-height: 1;
  padding: 0.42rem 0.85rem; border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.site-header nav a:hover,
.site-header nav .link-button:hover {
  background: rgba(127, 176, 212, 0.22); color: var(--sage-deep); text-decoration: none;
}
.site-header nav a.active { background: var(--sage-deep); color: #fff; }
.site-header nav a.active:hover { background: var(--olive-deep); color: #fff; }
.inline-form { display: inline; margin: 0; }
.link-button {
  background: none; border: none; color: var(--ink); cursor: pointer;
  font: inherit; font-weight: 500; padding: 0;
}
.link-button:hover { color: var(--sage-deep); }

/* Mobile menu toggle (hidden on desktop). */
.nav-toggle {
  display: none;
  flex-direction: column; justify-content: center; gap: 4px;
  width: 40px; height: 40px; padding: 0;
  background: none; border: none; cursor: pointer;
}
.nav-toggle-bar {
  display: block; width: 20px; height: 2px; margin: 0 auto;
  background: var(--ink); border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.open .nav-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.open .nav-toggle-bar:nth-child(2) { opacity: 0; }
.open .nav-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Dim/blur the page behind the mobile nav while it's open (shown on phones). */
.nav-backdrop { display: none; }

.container { max-width: 820px; margin: 0 auto; padding: 6rem 1.5rem 3rem; }

.hero { text-align: center; padding: 3rem 1rem 2rem; }
.hero h1 { font-size: 2.7rem; font-weight: 300; margin: 0 0 0.75rem; color: var(--ink); letter-spacing: -0.5px; }
.tagline { font-size: 1.25rem; font-weight: 300; color: var(--muted); max-width: 42ch; margin: 0 auto; }

/* Soft entrance: fade + rise on load, gently staggered via --d. */
.reveal { animation: reveal-up 0.6s ease-out both; animation-delay: calc(var(--d, 0) * 90ms); }
@keyframes reveal-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Keyboard focus rings — visible for keyboard users, not on mouse click. */
a:focus-visible, .btn:focus-visible, button:focus-visible,
summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--sage-deep);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
}

/* Button system (Apple HIG / Material: 44px min touch target, clear hierarchy). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.2rem; min-height: 44px;
  border: 1px solid transparent; border-radius: 999px;
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 0.45rem 0.95rem; min-height: 40px; font-size: 0.9rem; }
.btn-primary { background: var(--sage-deep); color: #fff; }
.btn-primary:hover { background: var(--olive-deep); }
.btn-secondary { background: #fff; color: var(--sage-deep); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--sage); }
.btn-danger { background: none; color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: #fbecea; }
.btn-block { width: 100%; }

.offline { text-align: center; max-width: 420px; margin: 4rem auto; }
.offline h1 { margin-bottom: 0.5rem; }
.offline p { color: var(--muted); margin-bottom: 1.5rem; }

.pwa-install {
  position: fixed; z-index: 200;
  left: 50%; bottom: 1rem; transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.6rem;
  width: max-content; max-width: min(340px, calc(100% - 2rem));
  padding: 0.7rem 0.85rem;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
}
.pwa-install[hidden] { display: none; }
.pwa-install-hint { margin: 0; flex: 1; font-size: 0.9rem; line-height: 1.35; color: var(--muted); }
.pwa-install-close {
  align-self: flex-start; flex: none;
  border: none; background: none; cursor: pointer;
  font-size: 1.25rem; line-height: 1; color: var(--muted); padding: 0 0.15rem;
}
.pwa-install-close:hover { color: var(--ink); }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 0.5rem; }

.invoice-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem 1.5rem; margin-bottom: 1.25rem;
}
.invoice-meta > div { display: flex; flex-direction: column; }
.meta-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.15rem; }

.invoice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--border-soft); }
.status-form { display: flex; align-items: center; gap: 0.5rem; margin: 0; }
.status-form select {
  padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 16px; min-height: 40px; background: #fff;
}

.status-badge { display: inline-block; padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.85rem; font-weight: 500; width: fit-content; }
.status-draft { background: #c8e0f5; color: #2a4a6a; }
.status-sent { background: #b8d4e8; color: #2d5570; }
.status-paid { background: var(--mint); color: var(--sage-deep); }

.card-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }
@media (max-width: 640px) {
  .card-actions { justify-content: stretch; }
  .card-actions .btn { flex: 1 1 calc(50% - 0.5rem); text-align: center; justify-content: center; }
}

/* Totals report */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--card); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 0.35rem; }
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 500; color: var(--ink); }

.range-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; margin-bottom: 0.9rem; }
.range-select-label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.range-select {
  padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 16px; min-height: 44px; min-width: 200px; background: #fff;
}
.range-custom { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.range-custom[hidden] { display: none; }
.range-custom label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.range-custom input[type="date"] { padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 10px; font: inherit; font-size: 16px; min-height: 44px; background: #fff; }
.range-label { margin: 0; color: var(--muted); font-size: 0.9rem; }

.collapsible > summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 1.15rem; font-weight: 500; color: var(--ink);
}
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary::after {
  content: "›"; font-size: 1.4rem; line-height: 1; color: var(--muted);
  transform: rotate(90deg); transition: transform 0.15s ease;
}
.collapsible[open] > summary::after { transform: rotate(-90deg); }
.collapsible[open] > summary { margin-bottom: 1.1rem; }

#totals-results { transition: opacity 0.15s ease; }
#totals-results.is-loading { opacity: 0.5; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; margin: 2.5rem 0; }
.feature { background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); transition: box-shadow 0.18s ease, transform 0.18s ease; }
.feature:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.feature h2 { margin-top: 0; font-size: 1.15rem; color: var(--ink); }
.feature:nth-child(1),
.feature:nth-child(2),
.feature:nth-child(3) { border-top: 5px solid #8d99a6; }

.card { background: var(--card); border-radius: var(--radius); padding: 1.75rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.card.narrow { max-width: 420px; margin: 2rem auto; }
.card h2 { margin-top: 0; color: var(--ink); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; color: var(--ink); }
.page-head div { display: flex; align-items: center; gap: 1rem; }

.stacked-form p { margin: 0 0 1rem; display: flex; flex-direction: column; }
.stacked-form label { font-weight: 500; margin-bottom: 0.3rem; }
/* 16px min font-size keeps iOS Safari from auto-zooming on focus. */
.stacked-form input, .stacked-form textarea, .stacked-form select {
  padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 16px; min-height: 44px; background: #fff;
}
.stacked-form input:focus, .stacked-form textarea:focus, .stacked-form select:focus {
  outline: none; border-color: var(--sage); box-shadow: 0 0 0 3px rgba(127, 176, 212, 0.4);
}
.helptext { font-size: 0.8rem; color: var(--muted); }

/* Inline info tooltip: hover on desktop, tap/focus on touch. */
.info-tip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: 0.35rem; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  font-size: 0.7rem; font-weight: 700; font-style: normal; line-height: 1;
  cursor: help; vertical-align: middle; user-select: none; -webkit-user-select: none;
}
.info-tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 240px;
  background: #2b3a47; color: #fff; text-align: left;
  padding: 0.5rem 0.65rem; border-radius: 8px;
  font-size: 0.8rem; font-weight: 400; line-height: 1.35; white-space: normal;
  box-shadow: var(--shadow); opacity: 0; visibility: hidden; transition: opacity 0.15s ease;
  z-index: 30;
}
.info-tip::before {
  content: ""; position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #2b3a47;
  opacity: 0; visibility: hidden; transition: opacity 0.15s ease; z-index: 30;
}
.info-tip:hover::after, .info-tip:focus::after,
.info-tip:hover::before, .info-tip:focus::before { opacity: 1; visibility: visible; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Recent entries: horizontal snap strip ("cards passing by"). */
.entry-strip {
  display: flex; gap: 0.9rem; overflow-x: auto;
  padding: 0.25rem 0.15rem 0.9rem;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  scroll-padding-left: 0.15rem;
}
.entry-card {
  scroll-snap-align: start; flex: 0 0 220px; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 0.5rem;
  background: var(--card); border-radius: 14px;
  padding: 0.9rem 1rem; box-shadow: var(--shadow);
}
.entry-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.entry-card-date { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.entry-card-hours { font-size: 1.2rem; font-weight: 600; color: var(--sage-deep); }
.entry-card-client { font-weight: 500; }
.entry-card-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.entry-card-meta .pill { font-size: 0.75rem; background: var(--mint); color: var(--sage-deep); padding: 0.15rem 0.55rem; border-radius: 999px; }
.entry-card-note { margin: 0; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.entry-card-actions { margin-top: auto; display: flex; align-items: center; gap: 0.9rem; padding-top: 0.5rem; border-top: 1px solid var(--border-soft); }

.entries { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.entries th, .entries td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border-soft); }
.entries th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding-bottom: 0.35rem; }
.entries tbody tr:last-child td { border-bottom: none; }
.entries .actions { white-space: nowrap; text-align: right; }
.entries .actions a { margin-right: 0.75rem; }
.entries tfoot th { border-top: 2px solid var(--sage); padding-top: 0.5rem; color: var(--ink); }
.danger { color: #c0564b; }

/* Collapsible overflow for older entries. */
.more-entries { margin-top: 0.5rem; }
.more-entries summary {
  cursor: pointer; color: var(--sage-deep); font-weight: 600;
  font-size: 0.9rem; padding: 0.35rem 0; list-style: none;
}
.more-entries summary::-webkit-details-marker { display: none; }
.more-entries summary::before { content: "\25B8  "; }
.more-entries[open] summary::before { content: "\25BE  "; }

.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--danger); }

.messages { list-style: none; padding: 0; }
.messages li { padding: 0.7rem 1rem; border-radius: 10px; margin-bottom: 0.75rem; }
.messages .success { background: var(--mint); color: var(--sage-deep); }
.messages .warning { background: #fbeee6; color: #a86a4e; }

.site-footer { text-align: center; padding: 2rem 1.5rem; color: var(--muted); font-size: 0.85rem; }

@media (max-width: 600px) {
  .site-header { gap: 0.5rem; padding: 0.5rem 0.6rem 0.5rem 1.1rem; }
  .site-header.is-auth { justify-content: space-between; }
  .nav-toggle { display: flex; }

  /* Collapse nav into a solid dropdown under the pill. */
  .site-header nav {
    display: none;
    position: absolute; top: calc(100% + 0.6rem); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0.15rem;
    padding: 0.4rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 18px; box-shadow: var(--shadow);
  }
  .site-header.open nav { display: flex; }
  .site-header.open ~ .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 90;
    background: rgba(20, 30, 40, 0.4);
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  }
  .site-header nav a,
  .site-header nav .link-button {
    width: 100%; text-align: left; padding: 0.65rem 0.9rem; border-radius: 12px;
  }
  .inline-form { display: block; width: 100%; }
  .container { padding: 5.5rem 1rem 2.5rem; }
  .card { padding: 1.1rem; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head div { flex-wrap: wrap; }
  .stacked-form > .btn, .form-actions .btn { width: 100%; }
  .hero h1 { font-size: 2rem; }

  /* Full-width, single-column action rows so buttons never crowd or overflow. */
  .invoice-actions { flex-direction: column; align-items: stretch; }
  .invoice-actions .status-form { width: 100%; }
  .invoice-actions .status-form select { flex: 1; }
  .invoice-actions .btn { width: 100%; }
  .paper-toolbar { flex-direction: column; align-items: stretch; }
  .paper-toolbar .spacer { display: none; }
  .paper-toolbar .btn { width: 100%; }
  .split-btn { display: flex; width: 100%; }
  .split-btn .split-main { flex: 1; }
  .form-actions { flex-direction: column; align-items: stretch; }

  /* Stack tables into labeled cards instead of overflowing. */
  .entries thead { display: none; }
  .entries tr {
    display: block; margin-bottom: 0.75rem; padding: 0.75rem 0.9rem;
    border-radius: 12px;
    background: var(--card); box-shadow: var(--shadow);
  }
  .entries tbody tr:last-child { margin-bottom: 0; }
  .entries td { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3rem 0; border: none; text-align: right; }
  .entries td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
  .entries td.actions { justify-content: flex-start; text-align: left; padding-top: 0.5rem; margin-top: 0.25rem; border-top: 1px solid var(--border-soft); }
  .entries td.actions::before { content: ""; }
}

/* ---- Split button (primary action + dropdown) ---- */
.split-btn { position: relative; display: inline-flex; vertical-align: top; }
.split-btn .split-main { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-btn .split-caret {
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  padding-left: 0.6rem; padding-right: 0.6rem;
}
.split-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 20;
  min-width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lift); padding: 0.25rem;
}
.split-menu-item {
  display: block; width: 100%; text-align: left; white-space: nowrap;
  background: none; border: none; cursor: pointer; font: inherit;
  padding: 0.55rem 0.8rem; border-radius: 7px; color: var(--ink);
}
.split-menu-item:hover, .split-menu-item:focus { background: var(--sand); }

/* ---- Collapsible settings section ---- */
.settings-details > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center;
  gap: 0.5rem; font-weight: 600; font-size: 1.15rem;
}
.settings-details > summary::-webkit-details-marker { display: none; }
.settings-details > summary::before {
  content: "\25B8"; color: var(--muted); transition: transform 0.15s ease;
}
.settings-details[open] > summary::before { transform: rotate(90deg); }
.settings-details > summary:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }
.settings-details .settings-body { margin-top: 0.9rem; }
.settings-details + .settings-details { margin-top: 1rem; }

/* Placeholder reference for the customizable invoice email wording. */
.token-legend {
  margin-top: 0.75rem; padding: 0.75rem 0.9rem;
  background: var(--sand); border-radius: 10px; font-size: 0.9rem;
}
.token-legend ul { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.token-legend li { margin: 0.15rem 0; }
.token-legend code {
  background: #fff; border: 1px solid var(--border-soft); border-radius: 5px;
  padding: 0.05rem 0.3rem; color: var(--ink); font-size: 0.85em;
}

/* Separate the single save action from the collapsible settings sections. */
.settings-details + .form-actions {
  margin-top: 1.25rem; padding-top: 1.25rem;
  border-top: 1px solid var(--border-soft);
}

/* ---- Invoice paper view (browser preview that looks like the PDF) ---- */
.paper-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  margin-bottom: 1rem;
}
.paper-toolbar .spacer { flex: 1 1 auto; }
.paper-note {
  background: var(--mint); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.6rem 0.9rem; margin-bottom: 1rem;
  color: var(--sage-deep); font-size: 0.92rem;
}
.paper-scroll { overflow-x: auto; }
.paper-sheet {
  background: #fff; color: #222; width: 8.5in; max-width: 100%;
  margin: 0 auto; padding: 1in; box-sizing: border-box;
  box-shadow: var(--shadow-lift); border-radius: 4px;
  font-family: Helvetica, Arial, sans-serif; font-size: 11px; line-height: 1.4;
}
.paper-sheet h1 { font-size: 20px; margin: 0; color: #1b1b1b; }
.paper-sheet table { width: 100%; }
.paper-sheet .muted { color: #666; }
.paper-sheet .header td { vertical-align: top; }
.paper-sheet .company-purpose { color: #444; margin-top: 3px; }
.paper-sheet .company-phone { color: #666; margin-top: 2px; }
.paper-sheet .title { font-size: 26px; text-align: right; font-weight: bold; color: #2c6e6b; }
.paper-sheet .paper-meta { display: block; text-align: right; margin: 6px 0 0; line-height: 1.6; }
.paper-sheet .rule { border-bottom: 2px solid #2c6e6b; height: 1px; font-size: 1px;
  line-height: 1px; margin: 14px 0; }
.paper-sheet .parties { margin-top: 2px; }
.paper-sheet .parties td { vertical-align: top; }
.paper-sheet .label { font-size: 9px; font-weight: bold; letter-spacing: 1px; color: #2c6e6b;
  text-transform: uppercase; padding-bottom: 4px; }
.paper-sheet .box { border: 1px solid #ccc; padding: 10px; }
.paper-sheet .service { margin-top: 16px; }
.paper-sheet .service .body { margin-top: 3px; }
.paper-sheet table.lines { border-collapse: collapse; margin-top: 18px; }
.paper-sheet table.lines th { background: #2c6e6b; color: #fff; text-align: left;
  padding: 5px 7px; font-size: 10px; }
.paper-sheet table.lines td { padding: 4px 7px; border-bottom: 1px solid #ddd; }
.paper-sheet table.lines td.num, .paper-sheet table.lines th.num { text-align: right; }
.paper-sheet .totals td { font-weight: bold; border-top: 2px solid #2c6e6b; padding-top: 6px; }

@media (max-width: 640px) {
  .paper-sheet { padding: 1rem; width: 100%; font-size: 12px; overflow-x: auto; }
  /* Stack the two-column header and parties tables so nothing gets squished. */
  .paper-sheet table.header,
  .paper-sheet table.header tbody,
  .paper-sheet table.header tr,
  .paper-sheet table.parties,
  .paper-sheet table.parties tbody,
  .paper-sheet table.parties tr { display: block; }
  .paper-sheet table.header td,
  .paper-sheet table.parties td { display: block; width: auto !important; }
  .paper-sheet .title,
  .paper-sheet .paper-meta { text-align: left; }
  .paper-sheet .title { margin-top: 10px; }
  .paper-sheet .parties td + td { margin-top: 10px; }
  .paper-sheet table.lines th,
  .paper-sheet table.lines td { padding: 4px 5px; font-size: 11px; }
}
