/* =====================================================================
   components.css — sidebar, topbar, cards, tables, forms, buttons,
   badges, modals, toasts, empty/loading states
   ===================================================================== */

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  min-height: var(--topbar-h);
}

.brand-mark {
  width: 32px; height: 32px;
  flex: none;
  border-radius: 8px;
  background: var(--primary-700);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .02em;
}

.brand-name {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-sub { font-size: 11.5px; color: var(--ink-400); }

.sidebar-nav {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}

.nav-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-400);
  font-weight: 600;
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-700);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .12s ease, color .12s ease;
}

.nav-item:hover { background: var(--surface-2); text-decoration: none; }

.nav-item.is-active {
  background: var(--primary-50);
  color: var(--primary-900);
  font-weight: 600;
}

.nav-item.is-active .nav-icon { color: var(--primary-700); }

.nav-icon { width: 18px; height: 18px; flex: none; color: var(--ink-400); }

.nav-badge {
  margin-left: auto;
  background: var(--danger-600);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding: 10px;
}

/* ---------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
}

.topbar-search {
  flex: 1;
  max-width: 460px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font: inherit;
  font-size: 14px;
  color: var(--ink-900);
}

.topbar-search input:focus {
  background: var(--surface);
  border-color: var(--primary-600);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-50);
}

.topbar-search svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--ink-400);
  pointer-events: none;
}

.topbar-spacer { flex: 1; }

/* User menu */
.user-menu { position: relative; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-100);
  color: var(--primary-900);
  display: grid; place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  flex: none;
}

.user-button {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  font: inherit;
  color: var(--ink-900);
}

.user-button:hover { background: var(--surface-2); border-color: var(--line); }

.user-button .user-name { font-size: 13.5px; font-weight: 600; line-height: 1.15; }
.user-button .user-role { font-size: 11.5px; color: var(--ink-500); text-align: left; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 60;
}

.menu-header { padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink-700);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item.danger { color: var(--danger-700); }

/* ---------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.card-body   { padding: 16px; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* Stat card — the dashboard's primary vocabulary */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat-label {
  font-size: 12.5px;
  color: var(--ink-500);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.stat-value.is-negative { color: var(--danger-700); }
.stat-meta { font-size: 12.5px; color: var(--ink-500); margin-top: 4px; }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-900);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}

.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--primary-700);
  border-color: var(--primary-700);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-900); border-color: var(--primary-900); }

.btn-danger { background: var(--danger-600); border-color: var(--danger-600); color: #fff; }
.btn-danger:hover { background: var(--danger-700); border-color: var(--danger-700); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { height: 32px; padding: 0 10px; font-size: 13.5px; }
.btn-block { width: 100%; }

.btn-icon { width: 36px; padding: 0; }

/* Inline spinner shown while a button is submitting */
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  color: #fff;
}
.btn.is-loading:not(.btn-primary):not(.btn-danger)::after { color: var(--ink-700); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-700);
  margin-bottom: 5px;
}

.field .hint { font-size: 12.5px; color: var(--ink-500); margin-top: 5px; }

.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 15px;                 /* 16px-ish stops iOS zooming on focus */
  color: var(--ink-900);
}

.textarea { min-height: 88px; resize: vertical; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px var(--primary-50);
}

.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-2);
  color: var(--ink-500);
}

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea { border-color: var(--danger-600); }

.field-error {
  display: none;
  font-size: 12.5px;
  color: var(--danger-700);
  margin-top: 5px;
}

.field.has-error .field-error { display: block; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-alert {
  display: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.form-alert.is-visible { display: block; }
.form-alert.error   { background: var(--danger-50);  border-color: #fecaca; color: var(--danger-700); }
.form-alert.success { background: var(--success-50); border-color: #bbf7d0; color: var(--success-700); }
.form-alert.info    { background: var(--info-50);    border-color: #bfdbfe; color: var(--info-700); }

/* ---------------------------------------------------------------------
   Badges / status pills
   --------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-neutral { background: var(--surface-2);   color: var(--ink-700);     border-color: var(--line); }
.badge-info    { background: var(--info-50);     color: var(--info-700);    border-color: #bfdbfe; }
.badge-success { background: var(--success-50);  color: var(--success-700); border-color: #bbf7d0; }
.badge-warn    { background: var(--warn-50);     color: var(--warn-700);    border-color: #fde68a; }
.badge-danger  { background: var(--danger-50);   color: var(--danger-700);  border-color: #fecaca; }
.badge-primary { background: var(--primary-50);  color: var(--primary-900); border-color: var(--primary-100); }

.role-pill {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---------------------------------------------------------------------
   Tables
   Wide tables scroll inside their own container; the page never does.
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-500);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover { background: var(--primary-50); }

/* ---------------------------------------------------------------------
   Lists (used where a table is overkill)
   --------------------------------------------------------------------- */
.list { display: flex; flex-direction: column; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .list-main { flex: 1; min-width: 0; }
.list-item .list-title { font-weight: 550; font-size: 14.5px; }
.list-item .list-sub { font-size: 13px; color: var(--ink-500); }

/* ---------------------------------------------------------------------
   Empty / loading / error states
   --------------------------------------------------------------------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-500);
}

.empty svg { width: 30px; height: 30px; color: var(--ink-400); margin-bottom: 10px; }
.empty h3 { color: var(--ink-700); margin-bottom: 4px; }
.empty p { font-size: 13.5px; max-width: 380px; margin: 0 auto 14px; }

.skeleton {
  background: linear-gradient(90deg, #eef2f7 25%, #e2e8f0 37%, #eef2f7 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 6px;
  height: 13px;
}

.skeleton.tall { height: 26px; }
.skeleton.w-60 { width: 60%; }
.skeleton.w-40 { width: 40%; }

@keyframes shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--primary-700);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

.page-loader {
  display: grid;
  place-items: center;
  min-height: 55vh;
  gap: 12px;
  color: var(--ink-500);
  font-size: 14px;
}

/* ---------------------------------------------------------------------
   Modal / dialog
   --------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal.modal-lg { max-width: 760px; }
.modal.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-body { padding: 18px; overflow-y: auto; flex: 1; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.modal-close {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--ink-500);
  padding: 4px;
  border-radius: 6px;
  line-height: 0;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink-900); }

/* ---------------------------------------------------------------------
   Toasts
   --------------------------------------------------------------------- */
.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  padding: 11px 13px;
  border-radius: var(--radius);
  background: var(--ink-900);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out;
}

.toast.success { background: #14532d; }
.toast.error   { background: #7f1d1d; }
.toast.info    { background: var(--ink-900); }
.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------------
   Misc
   --------------------------------------------------------------------- */
.divider { height: 1px; background: var(--line); margin: 16px 0; }

.placeholder-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-500);
  font-size: 13.5px;
}

.placeholder-note svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--ink-400); }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--ink-500); }
.kv dd { margin: 0; }

/* ---------------------------------------------------------------------
   List-screen toolbar (search + filters) — Milestone 2
   --------------------------------------------------------------------- */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-search { position: relative; flex: 1 1 280px; min-width: 0; }
.toolbar-search input { padding-left: 34px; }

.toolbar-search svg {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--ink-400);
  pointer-events: none;
}

.toolbar-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-select { width: auto; min-width: 145px; }

/* Grouping heading inside a longer form */
.form-section {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-400);
  font-weight: 600;
  margin: 20px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.form-section:first-of-type { margin-top: 0; }

/* Destructive action that should not shout as loudly as .btn-danger */
.btn.danger-text { color: var(--danger-700); }
.btn.danger-text:hover { background: var(--danger-50); border-color: #fecaca; }

/* Possible-duplicate suggestions in the Add Client form */
.dup-link { display: block; padding: 5px 0; font-weight: 600; }

/* "N leads need follow-up" panel on the Leads page */
.attention-card { border-color: #fde68a; }
.attention-card .card-header { background: var(--warn-50); border-bottom-color: #fde68a; }

/* Chevron reused as a back arrow */
.flip { transform: rotate(180deg); }

/* ---------------------------------------------------------------------
   Calendar — Milestone 3
   Month grid, week columns and the day agenda all reuse the existing
   card/badge vocabulary; only the layout is new.
   --------------------------------------------------------------------- */
.cal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-title { font-weight: 600; font-size: 16px; margin-left: 6px; }
.cal-views { display: flex; gap: 6px; }

.cal-grid-head {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.cal-grid-head div {
  padding: 9px 10px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-500);
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(104px, auto);
}

.cal-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px;
  min-width: 0;
  cursor: pointer;
  transition: background .12s ease;
}

.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.is-outside { background: var(--surface-2); }
.cal-cell.is-outside .cal-daynum { color: var(--ink-400); }
.cal-cell.is-selected { background: var(--primary-50); box-shadow: inset 0 0 0 2px var(--primary-600); }

.cal-daynum { font-size: 12.5px; font-weight: 600; color: var(--ink-700); padding: 2px 4px; }

.cal-cell.is-today .cal-daynum {
  background: var(--primary-700);
  color: #fff;
  border-radius: 999px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  padding: 0;
}

.cal-chips { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.cal-dots { display: none; gap: 3px; padding: 2px 4px; }

.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-400); }
.cal-dot.tone-success { background: var(--success-700); }
.cal-dot.tone-warn    { background: var(--warn-700); }
.cal-dot.tone-danger  { background: var(--danger-600); }
.cal-dot.tone-info    { background: var(--info-700); }

.cal-chip {
  border-left: 3px solid var(--ink-400);
  background: var(--surface-2);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11.5px;
  line-height: 1.35;
  cursor: pointer;
  overflow: hidden;
}

.cal-chip:hover { background: var(--primary-50); }
.cal-chip.tone-success { border-left-color: var(--success-700); }
.cal-chip.tone-warn    { border-left-color: var(--warn-700); }
.cal-chip.tone-danger  { border-left-color: var(--danger-600); }
.cal-chip.tone-info    { border-left-color: var(--info-700); }

.cal-chip-time { font-weight: 700; margin-right: 4px; font-variant-numeric: tabular-nums; }
.cal-chip-name { font-weight: 600; }
.cal-chip-meta {
  display: block;
  color: var(--ink-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-more { font-size: 11px; color: var(--ink-500); padding: 1px 6px; font-weight: 600; }

/* Week view */
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: hidden; }
.cal-col { border-right: 1px solid var(--line); min-width: 0; }
.cal-col:last-child { border-right: 0; }
.cal-col.is-today { background: var(--primary-50); }

.cal-col-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.cal-col-day { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); font-weight: 600; }
.cal-col-date { font-weight: 700; font-size: 14px; }
.cal-add { margin-left: auto; padding: 0 6px; height: 24px; }
.cal-col-body { padding: 6px; display: flex; flex-direction: column; gap: 4px; min-height: 120px; }
.cal-empty { color: var(--ink-400); font-size: 12px; text-align: center; padding: 10px 0; }

/* Day agenda */
.cal-agenda-time {
  flex: none;
  width: 76px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Section label inside a card (Upcoming / Previous) */
.section-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-400);
  font-weight: 600;
  padding: 10px 16px 4px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

/* Clickable stat card (dashboard -> filtered job list) */
.stat-link { display: block; color: inherit; text-decoration: none; transition: border-color .12s ease, box-shadow .12s ease; }
.stat-link:hover { text-decoration: none; border-color: var(--primary-600); box-shadow: var(--shadow); }

/* Job status tiles on the dashboard */
.status-tiles { display: flex; gap: 10px; flex-wrap: wrap; }

.status-tile {
  flex: 1 1 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
}

.status-tile:hover { text-decoration: none; border-color: var(--primary-600); background: var(--primary-50); }
.status-tile-value { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 6px; }

/* ---------------------------------------------------------------------
   The invoice document — Milestone 4
   Deliberately looks like a business document rather than an app screen:
   more white space, a serif-free but formal hierarchy, and a totals
   ladder that reads top to bottom.
   --------------------------------------------------------------------- */
.invoice-doc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 34px 38px;
  max-width: 860px;
  color: var(--ink-900);
}

.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.inv-logo { max-width: 190px; max-height: 76px; display: block; margin-bottom: 10px; }
.inv-brand-name { font-size: 21px; font-weight: 700; color: var(--primary-700); margin-bottom: 8px; }
.inv-brand-name-sm { font-weight: 700; color: var(--ink-900); margin-bottom: 2px; }
.inv-brand-lines { font-size: 12.5px; color: var(--ink-500); line-height: 1.65; }

.inv-title-block { text-align: right; flex: none; }
.inv-title { font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.inv-number { font-size: 14px; font-weight: 600; color: var(--primary-700); margin-top: 5px; }
.inv-status-line { margin-top: 8px; }

.inv-meta { display: flex; justify-content: space-between; gap: 28px; padding: 22px 0; }
.inv-meta-block { font-size: 13px; line-height: 1.65; color: var(--ink-700); min-width: 0; }
.inv-meta-block:last-child { text-align: right; min-width: 240px; flex: none; }

.inv-meta-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-400);
  font-weight: 700;
  margin-bottom: 5px;
}

.inv-meta-strong { font-weight: 700; font-size: 15px; color: var(--ink-900); margin-bottom: 2px; }
.inv-meta-row { display: flex; justify-content: space-between; gap: 18px; padding: 2px 0; }
.inv-meta-row span { color: var(--ink-500); }

.inv-items { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13.5px; }

.inv-items thead th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-500);
  font-weight: 700;
  padding: 9px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-strong);
}

.inv-items tbody td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.inv-items .inv-col-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-items thead .inv-col-num { text-align: right; }
.inv-items-sm { font-size: 12.5px; margin-top: 8px; }
.inv-empty { color: var(--ink-400); text-align: center; padding: 22px 0; }

.inv-totals-wrap { display: flex; justify-content: space-between; gap: 34px; margin-top: 22px; }
.inv-notes-col { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-700); }
.inv-note-block { margin-bottom: 16px; }
.inv-pre { white-space: pre-wrap; line-height: 1.6; }

.inv-totals { width: 280px; flex: none; font-size: 13.5px; }

.inv-total-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 0;
  font-variant-numeric: tabular-nums;
}

.inv-total-row span:first-child { color: var(--ink-500); }

.inv-total-grand {
  border-top: 1px solid var(--line-strong);
  margin-top: 5px;
  padding-top: 10px;
  font-size: 16px;
  font-weight: 700;
}
.inv-total-grand span:first-child { color: var(--ink-900); }

.inv-total-balance {
  border-top: 2px solid var(--ink-900);
  margin-top: 5px;
  padding-top: 10px;
  font-size: 17px;
  font-weight: 700;
}
.inv-total-balance span:first-child { color: var(--ink-900); }

.inv-payments { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }

.inv-void {
  margin-top: 22px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--danger-600);
  border: 2px solid var(--danger-600);
  border-radius: 6px;
  padding: 8px;
}

/* Live totals inside the invoice form */
.inv-preview-totals {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 4px;
}

/* Line-item editor */
.item-table td { padding: 6px; vertical-align: middle; }
.item-table .input { min-height: 38px; }

/* Overdue strip on the dashboard */
.attention-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 16px;
  background: var(--danger-50);
  border-bottom: 1px solid #fecaca;
  color: var(--danger-700);
  font-size: 13.5px;
}
.attention-strip .btn { margin-left: auto; }

/* ---------------------------------------------------------------------
   Public demo credentials panel on the login page
   --------------------------------------------------------------------- */
.demo-panel {
  margin-top: 24px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.demo-panel-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.demo-panel-head h2 { font-size: 14.5px; }

.demo-accounts { display: flex; flex-direction: column; gap: 8px; }

.demo-account {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "role  use"
    "email use"
    "pass  use";
  gap: 1px 12px;
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  transition: border-color .12s ease, background .12s ease;
}

.demo-account:hover { border-color: var(--primary-600); background: var(--primary-50); }
.demo-account.is-chosen { border-color: var(--primary-700); background: var(--primary-50); }

.demo-role  { grid-area: role;  font-weight: 650; font-size: 13.5px; color: var(--ink-900); }
.demo-cred  { font-size: 12.5px; color: var(--ink-500); font-family: var(--font-num); word-break: break-all; }
.demo-account .demo-cred:nth-of-type(1) { grid-area: email; }
.demo-account .demo-cred:nth-of-type(2) { grid-area: pass; }

.demo-use {
  grid-area: use;
  align-self: center;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--primary-700);
  border: 1px solid var(--primary-100);
  background: var(--primary-50);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.demo-account.is-chosen .demo-use { background: var(--primary-700); color: #fff; border-color: var(--primary-700); }

/* Simple, dependency-free bar chart used by the dashboard/reports */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 78px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: 9px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary-600); border-radius: 999px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-700); }
