/* The one stylesheet of the Loans app, for every screen. The look is the drawings' (design/Home.html and
   design/Loan-page.html): a grey page, white cards with thin borders and round corners, one dark main button per
   screen, white buttons for the rest, system fonts, a monospace font for loan numbers, dates and amounts.
   No web font, nothing loaded from another site. Red only for a message that something must be fixed. */

body { margin: 0; background: #f3f4f6; color: #111827; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.45; min-height: 100vh; }
a { color: #111827; }
a:hover { color: #374151; }
[hidden] { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: #5b6472; }
.sub { color: #5b6472; font-size: 14px; }
.strong { font-weight: 600; }
.grow { flex-grow: 1; }

/* The top bar */
.topbar { background: #ffffff; border-bottom: 1px solid #e5e7eb; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 0 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; min-height: 56px; }
.topbar a { text-decoration: none; display: flex; align-items: center; min-height: 44px; }
.topbar .brand { font-weight: 700; font-size: 17px; }

.page { max-width: 1080px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* Cards, their headings and their rows */
.card { background: #ffffff; border: 1px solid #e5e7eb; border-radius: 10px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; padding: 16px 20px; }
.card-head h1, .card-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 14px 20px; }
.head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 14px 20px; border-top: 1px solid #e5e7eb; }
.row.tight { gap: 6px 16px; padding: 12px 20px; }
.row .main, .next .main { flex: 1 1 320px; min-width: 0; }
.row .side { flex: 1 1 220px; min-width: 0; }
.row .date { width: 104px; }
.row a.tall, .footline a { display: flex; align-items: center; min-height: 44px; }

.btn { font: inherit; font-size: 14px; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid #d1d5db; background: #ffffff; color: #111827; cursor: pointer; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn.dark { background: #111827; border-color: #111827; color: #ffffff; }
.linklike { font: inherit; background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }
.linklike.tall { display: flex; align-items: center; min-height: 44px; color: #111827; }
.linklike:hover { color: #374151; }
.chip { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: #eef0f3; color: #374151; white-space: nowrap; }

/* The red line: something must be fixed */
.alert { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 10px; padding: 12px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.alert a { color: #991b1b; font-weight: 600; }
.error { color: #991b1b; margin: 8px 0 0; min-height: 1.45em; }

/* Tables. A wide table scrolls sideways inside its card, so the page itself always fits a phone. */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { font-weight: 600; font-size: 13px; color: #5b6472; text-align: left; }
th, td { padding: 10px 12px; border-top: 1px solid #e5e7eb; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
table.roomy { min-width: 760px; }
table.roomy td { padding-top: 14px; padding-bottom: 14px; white-space: normal; }
table.advances { min-width: 420px; }
table.payments { min-width: 440px; }

.footline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; color: #5b6472; font-size: 14px; padding: 0 4px; }

/* The loan page */
.loan-top { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.title-row h1 { margin: 0; font-size: 30px; font-weight: 700; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px 24px; }
.big { font-size: 17px; font-weight: 600; }
.next { padding: 16px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.next .line { font-size: 17px; }
.pair { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.pair > .card { min-width: 0; }
.w400 { flex: 1 1 400px; }
.w460 { flex: 1 1 460px; }
.w560 { flex: 1 1 560px; }
details.card { padding: 0 20px; }
details.card summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; }
.history { padding: 0 0 16px; }
.history-line { padding: 10px 0; border-top: 1px solid #e5e7eb; overflow-wrap: anywhere; }

/* Settings: the title, one row of tabs, then the open tab's card (as in the QC app) */
.topbar a[aria-current="page"] { font-weight: 600; }
.settings-head { display: flex; flex-direction: column; gap: 12px; }
.settings-head h1 { margin: 0; font-size: 24px; font-weight: 700; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px 28px; border-bottom: 1px solid #e5e7eb; }
.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: #5b6472; text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: #111827; }
.tabs a[aria-current="page"] { color: #111827; font-weight: 700; border-bottom-color: #111827; }
.tabs a[data-later] { cursor: default; }
.tabs a[data-later]:hover { color: #5b6472; }
.tab-part { display: flex; flex-direction: column; gap: 20px; }
.message { margin: 0; border: 1px solid #111827; border-radius: 10px; background: #ffffff; padding: 12px 20px; font-weight: 600; }
.form-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.form-card h2 { margin: 0; font-size: 18px; font-weight: 700; }
.form-card p { margin: 4px 0 0; }
.form-card .error { min-height: 0; }
.field { display: flex; flex-direction: column; max-width: 360px; }
.field label { margin: 0 0 4px; }
.field input { font: inherit; width: 100%; box-sizing: border-box; min-height: 44px; padding: 0 12px; border: 1px solid #d1d5db; border-radius: 8px; background: #ffffff; color: #111827; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }

/* The sign-in screen */
.sign-in { max-width: 360px; width: 100%; margin: 24px auto 0; padding: 20px; box-sizing: border-box; }
.sign-in h1 { margin: 0 0 16px; font-size: 18px; font-weight: 700; }
.sign-in label { display: block; margin: 12px 0 4px; }
.sign-in input { font: inherit; width: 100%; box-sizing: border-box; min-height: 44px; padding: 0 12px; border: 1px solid #d1d5db; border-radius: 8px; background: #ffffff; color: #111827; }
.sign-in .btn { width: 100%; margin-top: 8px; }
