/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  overflow-x: hidden;
  min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -0.025em; line-height: 1.12; }
ul, ol { margin: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
::selection { background: rgba(215, 38, 27, 0.16); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
[hidden] { display: none !important; }
@media (min-width: 861px) { .only-m { display: none !important; } }

.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.serif-i { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
.mono, .num { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: -0.01em; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap-row { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ---------- Icons ---------- */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }

.ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.ic .i { width: 18px; height: 18px; }
.ic.red { background: var(--accent-soft); color: var(--accent); }
.ic.green { background: var(--ok-soft); color: var(--ok); }
.ic.violet { background: var(--violet-soft); color: var(--violet); }
.ic.amber { background: var(--warn-soft); color: var(--warn); }
.ic.blue { background: var(--info-soft); color: var(--info); }
.ic.gray { background: var(--surface-3); color: var(--ink-2); }
.ic.ink { background: var(--ink); color: #fff; }

.checks { list-style: none; display: grid; gap: 9px; margin: 18px 0 22px; padding: 0; font-size: 14px; }
.checks li { display: flex; gap: 10px; align-items: flex-start; }
.checks .i { color: var(--ok); width: 17px; height: 17px; margin-top: 2px; flex: none; stroke-width: 2.4; }
.checks li.off { color: var(--ink-3); }
.checks li.off .i { color: var(--ink-4); }

/* ---------- Buttons ---------- */
.btn {
  --h: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h);
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 550;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.08s var(--ease), color 0.15s;
  position: relative;
}
.btn:hover { background: #2a2a26; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.btn-accent { background: var(--accent); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 6px 16px -8px rgba(215, 38, 27, 0.6); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); box-shadow: var(--shadow-1); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-4); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(18, 18, 16, 0.05); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--accent-ink); border-color: var(--line-2); }
.btn-danger:hover { background: var(--accent-soft); border-color: #f4b9b4; }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #0b6b4a; }
.btn-sm { --h: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn-lg { --h: 50px; padding: 0 22px; font-size: 15.5px; border-radius: 12px; }
.btn-xl { --h: 56px; padding: 0 26px; font-size: 16.5px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }
.btn .i { width: 17px; height: 17px; }
.btn-sm .i { width: 15px; height: 15px; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: rgba(255, 255, 255, 0.9) rgba(255, 255, 255, 0.9) rgba(255, 255, 255, 0.25) rgba(255, 255, 255, 0.25);
  animation: spin 0.7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--ink) var(--ink) var(--line-2) var(--line-2); }
@keyframes spin { to { transform: rotate(360deg); } }

.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink-4); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--ink); }
.link-accent { color: var(--accent-ink); font-weight: 550; text-decoration: none; }
.link-accent:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 14px; }
.field > label, .label { font-size: 13px; font-weight: 550; color: var(--ink); }
.field .hint, .hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input[readonly] { background: var(--surface-2); }
.textarea { height: auto; min-height: 110px; padding: 11px 12px; line-height: 1.5; resize: vertical; }
.select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2387847b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.input-group { display: flex; align-items: stretch; }
.input-group .addon {
  display: grid;
  place-items: center;
  padding: 0 11px;
  font-size: 13px;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-right: 0;
  border-radius: 10px 0 0 10px;
}
.input-group .addon + .input { border-radius: 0 10px 10px 0; }
.input-group .input + .addon { border-left: 0; border-right: 1px solid var(--line-2); border-radius: 0 10px 10px 0; }
.input-group .input:has(+ .addon) { border-radius: 10px 0 0 10px; }
.form-error { font-size: 13.5px; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid #f6c7c2; border-radius: 10px; padding: 10px 12px; }
.form-ok { font-size: 13.5px; color: var(--ok); background: var(--ok-soft); border: 1px solid #bfe5d2; border-radius: 10px; padding: 10px 12px; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background 0.2s var(--ease); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s var(--ease); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }
.switch input:disabled + span { opacity: 0.5; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; }
.seg button, .seg a {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg .on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.no-dot::before { display: none; }
.badge-draft { background: var(--surface-3); color: var(--ink-3); }
.badge-sent { background: var(--info-soft); color: var(--info); }
.badge-viewed { background: var(--violet-soft); color: var(--violet); }
.badge-accepted, .badge-paid { background: var(--ok-soft); color: var(--ok); }
.badge-invoiced { background: #ebeae5; color: var(--ink); }
.badge-declined, .badge-cancelled { background: var(--surface-3); color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.badge-overdue { background: var(--accent-soft); color: var(--accent-ink); }
.badge-expired, .badge-reported, .badge-due { background: var(--warn-soft); color: var(--warn); }
.badge-pro { background: var(--ink); color: #fff; height: 20px; font-size: 11px; letter-spacing: 0.04em; padding: 0 7px; }
.badge-pro::before { display: none; }

.pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  box-shadow: var(--shadow-1);
}
.pill-tag b { background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 999px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-1); }
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; letter-spacing: -0.01em; }
.card-body { padding: 18px 20px; }
@media (max-width: 720px) {
  .card-pad { padding: 18px; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
}

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 550; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow-3);
  animation: toast-in 0.28s var(--ease);
}
.toast .i { color: #7ee2b4; }
.toast.err .i { color: #ff9b93; }
.toast a, .toast button { color: #fff; font-weight: 600; background: none; border: 0; padding: 0; text-decoration: underline; }
.toast.out { animation: toast-out 0.2s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Modal / sheet ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(18, 18, 16, 0.42);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in 0.2s var(--ease);
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-3);
  animation: pop-in 0.26s var(--ease);
}
.modal.wide { max-width: 680px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 6px; }
.modal-head h2 { font-size: 20px; }
.modal-head p { margin-top: 4px; }
.modal-body { padding: 14px 24px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 22px; flex-wrap: wrap; }
.modal-close { margin: -6px -8px 0 0; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
@media (max-width: 640px) {
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal { max-width: none; border-radius: 22px 22px 0 0; max-height: 92vh; animation: sheet-in 0.3s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
  .modal-head { padding: 20px 18px 4px; }
  .modal-body { padding: 12px 18px 6px; }
  .modal-foot { padding: 14px 18px 18px; }
  .modal-foot .btn { flex: 1; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0.4; } }

/* ---------- Misc ---------- */
.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-2);
}
.notice .i { margin-top: 2px; color: var(--ink-3); }
.notice.warn { background: var(--warn-soft); border-color: #f3d6ad; color: #7a4100; }
.notice.warn .i { color: var(--warn); }
.notice.ok { background: var(--ok-soft); border-color: #bfe5d2; color: #0b5e42; }
.notice.ok .i { color: var(--ok); }
.notice.accent { background: var(--accent-soft); border-color: #f6c7c2; color: var(--accent-ink); }
.notice.accent .i { color: var(--accent); }

.skel { background: linear-gradient(90deg, var(--surface-3), var(--bg-2), var(--surface-3)); background-size: 200% 100%; animation: skel 1.2s linear infinite; border-radius: 8px; }
@keyframes skel { to { background-position: -200% 0; } }

.kbd { font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--ink-2); background: var(--surface); }

.logo-mark { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 17px; letter-spacing: -0.035em; text-decoration: none; color: var(--ink); }
.logo-mark img, .logo-mark svg { width: 28px; height: 28px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
