/* ================================================================
   COMPONENTS — buttons, cards, pills, tables, forms, dialogs, toast
   ================================================================ */

/* Buttons: pill shapes from the site */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 13px 'Inter', sans-serif; padding: 9px 18px; border-radius: var(--radius-pill); cursor: pointer;
  border: 1.5px solid var(--border-medium); background: var(--surface); color: var(--primary);
  transition: var(--trans); white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--bg-blue-tint); border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(29,111,219,0.25); }
.btn.primary { background: var(--grad-primary); border-color: transparent; color: #fff; box-shadow: var(--shadow-blue); }
.btn.primary:hover { color: #fff; box-shadow: 0 12px 40px rgba(29,111,219,0.4); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(220,38,38,0.25); }
.btn.danger:hover { background: rgba(220,38,38,0.06); border-color: var(--red); color: var(--red); }
.btn.sm { padding: 4px 12px; font-size: 12px; }
.btn.sm.primary { box-shadow: 0 4px 14px rgba(29,111,219,0.25); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.link { font-size: 13px; font-weight: 500; }
.link-btn { background: none; border: 0; padding: 0; font: 600 12px 'Inter', sans-serif; color: var(--primary); cursor: pointer; text-decoration: underline; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; transition: var(--trans);
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--bg-blue-tint); }

/* Boxes */
.box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; margin-bottom: 20px; min-width: 0; box-shadow: var(--shadow-card);
}
.box > h2 { margin-bottom: 10px; }
.box-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* Stat cards: hover lift + gradient top line, like the site's service cards */
.card {
  position: relative; overflow: hidden; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; box-shadow: var(--shadow-xs); transition: var(--trans);
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--grad-primary); transform: scaleX(0); transform-origin: left; transition: transform 0.4s;
}
.card:hover { border-color: var(--border-medium); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card:hover::before { transform: scaleX(1); }
.card .label { font-family: 'Space Mono', monospace; font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary); }
.card .value { font-family: 'Space Grotesk', sans-serif; font-size: 25px; font-weight: 700; margin-top: 6px; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card .value small { font-size: 15px; color: var(--muted); font-weight: 500; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.highlight .value { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.card.good .value { color: var(--paid); }
.card.info .value { color: var(--primary); }
.card.alert { border-color: rgba(220,38,38,0.25); }
.card.alert::before { background: var(--red); transform: scaleX(1); }
.card.alert .label, .card.alert .value { color: var(--overdue); }

/* Pills & tags (tags follow the site's .service-tag) */
.pill {
  display: inline-block; font: 600 11px 'Inter', sans-serif; padding: 2px 10px; border-radius: var(--radius-pill);
  border: 1px solid transparent; white-space: nowrap; vertical-align: middle; letter-spacing: 0;
}
.pill.paid, .pill.ontrack { background: var(--paid-bg); color: var(--paid); border-color: rgba(16,185,129,0.25); }
.pill.partial { background: var(--partial-bg); color: var(--partial); border-color: rgba(217,119,6,0.25); }
.pill.due { background: var(--due-bg); color: var(--due); border-color: var(--border-medium); }
.pill.upcoming { background: var(--bg-blue-tint); color: var(--muted); border-color: var(--border); }
.pill.overdue { background: var(--overdue-bg); color: var(--overdue); border-color: rgba(220,38,38,0.2); }
.pill.closed, .pill.none { background: var(--none-bg); color: var(--muted); border-color: var(--grid-line); }
.tag {
  display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 10px;
  background: var(--bg-blue-tint); border: 1px solid var(--border); border-radius: var(--radius-pill); color: var(--primary);
}

/* Progress */
.progress { height: 8px; background: var(--none-bg); border-radius: var(--radius-pill); overflow: hidden; }
.progress > div { height: 100%; background: var(--grad-primary); border-radius: var(--radius-pill); }

/* Legend swatches */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: -6px; vertical-align: middle; border: 1px solid rgba(0,0,0,0.06); }
.sw-paid { background: var(--green); }
.sw-due { background: var(--due-bg); border-color: var(--primary); }
.sw-principal { background: var(--primary); }
.sw-interest { background: var(--interest); }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.list th, .list td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; vertical-align: middle; }
.list thead th {
  font-family: 'Space Mono', monospace; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); font-weight: 400; background: var(--surface-alt);
}
.list tbody tr { transition: background 0.2s; }
.list tbody tr:hover { background: var(--bg-blue-tint); }
.list tr.is-next { background: rgba(29,111,219,0.05); box-shadow: inset 3px 0 0 var(--primary); }
.list tfoot td { font-weight: 700; font-family: 'Space Grotesk', sans-serif; background: var(--bg-blue-tint); border-bottom: 0; }
.list .num { text-align: right; }
.list.compact th, .list.compact td { padding: 6px 10px; font-size: 13px; }
.actions-cell { text-align: right; }
.actions-cell .btn + .btn { margin-left: 4px; }
.note-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* Toolbar, inputs, segmented control */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.input, dialog input, dialog select, dialog textarea {
  font: 14px 'Inter', sans-serif; padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-medium); background: var(--surface); color: var(--text);
  outline: none; transition: var(--trans); min-width: 0;
}
.input:focus, dialog input:focus, dialog select:focus, dialog textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,111,219,0.1);
}
.toolbar input[type="search"] { flex: 1 1 240px; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface); border: 1.5px solid var(--border-medium); border-radius: var(--radius-pill); }
.segmented button {
  border: 0; background: none; padding: 6px 14px; border-radius: var(--radius-pill); cursor: pointer;
  font: 600 13px 'Inter', sans-serif; color: var(--text-medium); transition: var(--trans);
}
.segmented button span { font-weight: 500; color: var(--text-light); margin-left: 2px; }
.segmented button.active { background: var(--grad-primary); color: #fff; }
.segmented button.active span { color: rgba(255,255,255,0.8); }

/* Banner, hints, empty states */
.banner {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  background: var(--partial-bg); border: 1px solid rgba(217,119,6,0.25); color: #78350F;
  padding: 10px 16px; border-radius: var(--radius-md); margin-bottom: 20px; font-size: 13px;
}
.hint {
  font-size: 13px; color: var(--primary-dark); background: var(--bg-blue-tint); border: 1px solid var(--border-medium);
  padding: 10px 14px; border-radius: var(--radius-sm); margin: 4px 0 10px; line-height: 1.7;
}
.hint:empty { display: none; }
.hint.warn { background: var(--overdue-bg); border-color: rgba(220,38,38,0.25); color: #991B1B; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-state h3 { margin-bottom: 6px; }
.empty-state .btn { margin-top: 10px; }
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center;
  background: var(--bg-blue-tint); color: var(--primary); font: 700 24px 'Space Grotesk', sans-serif;
}
.empty-mini { color: var(--muted); text-align: center; padding: 24px 0; }

/* Dialogs & forms (follow the site's contact form) */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0;
  width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-md);
}
dialog.dialog-lg { width: min(680px, calc(100vw - 24px)); }
dialog form { padding: 24px 28px; }
dialog::backdrop { background: rgba(15,23,42,0.45); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.dialog-head h2 { font-size: 20px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font: 700 10.5px 'Space Mono', monospace; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary); margin-bottom: 10px; padding: 0; }
.legend-note { font: 400 11px 'Inter', sans-serif; letter-spacing: 0; text-transform: none; color: var(--text-light); margin-left: 6px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-medium); margin-bottom: 12px; flex: 1; min-width: 0; }
dialog input, dialog select, dialog textarea { width: 100%; background: var(--surface-alt); border-color: var(--border); }
dialog input:focus, dialog select:focus, dialog textarea:focus { background: var(--surface); }
dialog input:disabled { opacity: 0.5; }
dialog textarea { resize: vertical; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row { display: flex; gap: 12px; }
.form-tip { font-size: 12px; color: var(--muted); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.spacer { flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  display: flex; align-items: center; gap: 16px;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(15,23,42,0.3); font-size: 14px; max-width: calc(100vw - 32px);
  transform: translate(-50%, 140%); opacity: 0; transition: transform 0.3s, opacity 0.3s; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast-action { background: none; border: 0; color: #93C5FD; font: 700 14px 'Inter', sans-serif; cursor: pointer; padding: 0; }

@media (max-width: 520px) {
  .row { flex-direction: column; gap: 0; }
  dialog form { padding: 20px 18px; }
}

/* Signed-in user, loading and error states */
.user-menu { display: flex; align-items: center; gap: 10px; padding-left: 12px; margin-left: 4px; border-left: 1px solid var(--border-medium); }
.user-name { font-weight: 600; font-size: 13px; color: var(--navy); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boot-state { text-align: center; padding: 80px 16px; color: var(--muted); }
.boot-state h3 { margin-bottom: 8px; }
.boot-state .btn { margin-top: 12px; }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 16px; border-radius: 50%;
  border: 3px solid var(--bg-blue-tint); border-top-color: var(--primary); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row.center { justify-content: center; }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none; }
@media (max-width: 600px) { .user-name { display: none; } }
