/* J. Meade Construction CRM — minimal, no framework */

/* Brand typefaces (self-hosted, from jmeadeconstruction.com) */
@font-face {
  font-family: "Neue Haas Grotesk Display Pro";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/neue-haas-grotesk-display-pro-400.woff2") format("woff2");
}
@font-face {
  font-family: "Neue Haas Grotesk Display Pro";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/neue-haas-grotesk-display-pro-500.woff2") format("woff2");
}
@font-face {
  font-family: "Neue Haas Grotesk Display Pro";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/neue-haas-grotesk-display-pro-700.woff2") format("woff2");
}
@font-face {
  font-family: "Neue Haas Grotesk Display Pro";
  font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/neue-haas-grotesk-display-pro-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Madefor Text";
  font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("fonts/madefor-text.woff2") format("woff2");
}

:root {
  /* Brand palette — base color #2596be from jmeadeconstruction.com */
  --brand: #2596be;       /* base teal: accents, buttons, topbar */
  --brand-deep: #0d5a77;  /* dark teal: head panel / topbar start */
  --brand-2: #1b7ba1;     /* hover / pressed (darker than base) */
  --brand-3: #5cb6d8;     /* light accent / highlights */
  --tint: #eef7fb;        /* cool off-white backdrop */
  --tint-2: #dceef6;      /* secondary light surface */
  --font-display: "Neue Haas Grotesk Display Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "Madefor Text", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --navy: #0d2b45;
  --navy-2: #123a5c;
  --steel: #5b7a95;
  --ink: #1c2b38;
  --muted: #64798c;
  --line: #d7e0e8;
  --bg: #f4f7fa;
  --card: #ffffff;
  --accent: #2596be;
  --accent-2: #1b7ba1;
  --danger: #b42318;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --err: #b42318;
  --err-bg: #fef3f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(13, 43, 69, .06), 0 8px 24px rgba(13, 43, 69, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); letter-spacing: .005em; }

/* ------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: linear-gradient(120deg, var(--brand-deep), var(--brand));
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-logo {
  display: block;
  height: 44px;
  width: auto;
  border-radius: 10px;
}

.brand h1 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.tagline { margin: 0; font-size: .8rem; opacity: .75; letter-spacing: .3px; }

/* ------------------------------------------------ layout */

.container {
  max-width: 1080px;
  margin: 28px auto;
  padding: 0 20px 60px;
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  padding: 18px 0 34px;
}

/* ------------------------------------------------ buttons */

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #eef3f7; }
.btn:active { transform: translateY(1px); }

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: rgba(0,0,0,.04); color: var(--ink); }

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

.btn-small { padding: 5px 11px; font-size: .82rem; }

.inline-form { display: inline; margin: 0; }

/* ------------------------------------------------ flash */

.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .92rem;
  border: 1px solid transparent;
}
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #b6f0cd; }
.flash-error   { background: var(--err-bg); color: var(--err); border-color: #ffd5d0; }
.flash-info    { background: #eff6ff; color: #1d4ed8; border-color: #c7ddff; }

/* ------------------------------------------------ list head */

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.list-head h2 { margin: 0; font-size: 1.4rem; }
.count {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--steel);
  font-size: .85rem;
  font-weight: 700;
}

.search-form { display: flex; gap: 8px; }
.search-form input[type="search"] {
  min-width: 260px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .92rem;
  background: var(--card);
}

/* ------------------------------------------------ table */

.customers {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.customers th, .customers td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.customers thead th {
  background: #f8fafc;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--steel);
}
.customers tbody tr:last-child td { border-bottom: none; }
.customers tbody tr:hover { background: #f6f9fc; }

.name-cell a { font-weight: 600; color: var(--navy); text-decoration: none; }
.name-cell a:hover { color: var(--accent); text-decoration: underline; }
.sub { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.mono { font-variant-numeric: tabular-nums; }

.actions { white-space: nowrap; display: flex; gap: 8px; }

/* role badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: capitalize;
  border: 1px solid transparent;
}
.badge-customer      { background: #eff6ff; color: #1d4ed8; border-color: #c7ddff; }
.badge-vendor        { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge-related-party { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.badge-internal      { background: #f8fafc; color: #475569; border-color: #e2e8f0; }
.badge-other         { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }

.chip {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}

/* ------------------------------------------------ empty state */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty-state h2 { margin: 0 0 6px; color: var(--ink); }
.empty-state p { margin: 0 0 18px; }

/* ------------------------------------------------ form */

.form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.form-head h2 { margin: 0; font-size: 1.4rem; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .92rem;
  margin-bottom: 18px;
}
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-error { background: var(--err-bg); color: var(--err); border: 1px solid #ffd5d0; }

.customer-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }

.field label { font-size: .85rem; font-weight: 600; color: var(--steel); }
.req { color: var(--danger); }

.field input, .field select, .field textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, .15);
}

.field-error input, .field-error select, .field-error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, .12);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* ------------------------------------------------ detail page */

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.detail-head h2 { margin: 0 0 8px; font-size: 1.6rem; }
.detail-actions { display: flex; gap: 8px; align-items: center; }
.meta-row { display: flex; align-items: center; }

.detail-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  margin-bottom: 26px;
}
.fact { display: flex; flex-direction: column; gap: 2px; }
.fact-wide { grid-column: 1 / -1; }
.fact .label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--steel);
  font-weight: 700;
}

.projects-section h3 { font-size: 1.15rem; margin: 0 0 14px; }

.project {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.project-head { display: flex; align-items: baseline; gap: 12px; }
.project-title { font-weight: 700; color: var(--navy); font-size: 1.02rem; }
.project-notes { margin-top: 4px; margin-bottom: 8px; }
.project-head .btn-tiny { margin-left: auto; }

.btn-tiny { padding: 2px 8px; font-size: .75rem; border-radius: 6px; line-height: 1.6; }

.activities {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
.activities th, .activities td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: .92rem;
}
.activities thead th {
  background: #f8fafc;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--steel);
}
.activities tbody tr:last-child td { border-bottom: none; }
.date-col { white-space: nowrap; width: 130px; }
.empty-project { padding: 4px 0 8px; }

.add-project-form {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 6px;
}
.add-project-form h3 { font-size: 1rem; margin: 0 0 12px; color: var(--steel); }
.add-project-row { display: flex; gap: 10px; flex-wrap: wrap; }
.add-project-row input {
  flex: 1;
  min-width: 160px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .92rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
.add-project-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, .15);
}

/* ------------------------------------------------ files (attachments) */

.files-section { margin-bottom: 26px; }
.files-section h3 { font-size: 1.15rem; margin: 0 0 14px; }

.file-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: #f6f9fc; }
.file-icon { font-size: 1.25rem; line-height: 1; }
.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
}
.file-name:hover { color: var(--accent); text-decoration: underline; }
.file-size {
  color: var(--muted);
  font-size: .8rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.file-date {
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.add-file-form {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 6px;
}
.add-file-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.add-file-row input[type="file"] {
  flex: 1;
  min-width: 220px;
  padding: 8px 10px;
  font-size: .9rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.add-file-form .sub { margin-top: 8px; }

/* files: project filter, per-file project label, reassign + upload pickers */
.file-filter-form {
  margin: 0 0 12px;
  display: flex;
  align-items: center;
}
.file-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
}
.file-filter select,
.upload-project-select,
.reassign-select {
  font-family: inherit;
  font-size: .85rem;
  padding: 6px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.upload-project-select { max-width: 260px; }
.reassign-select { max-width: 200px; font-weight: 400; }
.file-project {
  flex: none;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .76rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 999px;
  padding: 2px 10px;
}
.file-customer {
  flex: none;
  font-size: .74rem;
  font-weight: 600;
  color: var(--muted);
  background: #f1f4f8;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
/* keep the file name as the flexible column; labels shrink around it */
.file-item .file-name { flex: 1 1 10rem; }

/* ------------------------------------------------ login
   Branded on jmeadeconstruction.com: deep-teal head panel
   (the site logo is white artwork, so it needs a dark ground),
   cool-tinted page, grotesque display type. */

.login-body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--tint-2) 0%, var(--tint) 55%);
  padding: 24px;
  font-family: var(--font-body);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(13, 90, 119, .14), 0 28px 64px rgba(13, 90, 119, .28);
  text-align: center;
}

.login-head {
  background: linear-gradient(160deg, var(--brand-deep) 0%, var(--brand-2) 100%);
  padding: 40px 34px 30px;
}

.login-logo {
  height: 88px;
  width: auto;
  margin: 0 auto 16px;
  display: block;
}

.login-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: .015em;
  color: #fff;
}
.login-sub { margin: 6px 0 0; color: rgba(255, 255, 255, .75); font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; letter-spacing: .05em; }

.login-main { padding: 28px 34px 24px; }

.login-form { display: grid; gap: 14px; text-align: left; }
.login-form .field input { width: 100%; }

.login-btn {
  padding: 11px 16px;
  font-size: .98rem;
  margin-top: 4px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .02em;
  background: var(--brand);
  border-color: var(--brand);
}
.login-btn:hover { background: var(--brand-2); border-color: var(--brand-2); }

.login-foot {
  margin: 20px 0 4px;
  color: var(--muted);
  font-size: 1.1rem;
}

/* who-am-i chip in the topbar */
.whoami {
  color: rgba(255, 255, 255, .85);
  font-size: .85rem;
  margin-right: 4px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------ tabs */

.tabs {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(13, 43, 69, .04);
}
.tabs-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
}
.tab {
  display: inline-block;
  padding: 12px 18px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.tab:hover { color: var(--navy); background: #f2f6fa; }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}

/* ------------------------------------------------ dashboard */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform .08s, border-color .15s, box-shadow .15s;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 2px 4px rgba(13, 43, 69, .08), 0 14px 34px rgba(14, 116, 144, .14);
}
.stat-num {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--steel);
  font-weight: 700;
}
.stat-grid .stat-card:nth-child(1):hover .stat-num { color: #1d4ed8; }
.stat-grid .stat-card:nth-child(2):hover .stat-num { color: var(--accent); }
.stat-grid .stat-card:nth-child(3):hover .stat-num { color: var(--ok); }

.projects-section h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: var(--navy);
}
.projects-section h3 .sub { margin: 0 0 0 8px; font-weight: 600; }
.sub.link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.sub.link:hover { text-decoration: underline; }

.recent-list {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: #f6f9fc; }
.recent-name {
  font-weight: 600;
  color: var(--navy);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-item .sub { flex: 1; min-width: 0; }
.recent-date { white-space: nowrap; font-size: .8rem; }

/* ------------------------------------------------ shared data table */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table th, .data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table thead th {
  background: #f8fafc;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--steel);
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f6f9fc; }
.data-table .actions { justify-content: flex-end; }
.data-table .actions-col { text-align: right; }
.data-table td.actions-col, .data-table th.actions-col { text-align: right; }
.data-table .date-col {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--steel);
  font-size: .9rem;
}
.data-table .name-cell a { font-weight: 600; color: var(--navy); text-decoration: none; }
.data-table .name-cell a:hover { color: var(--accent); text-decoration: underline; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .nowrap { white-space: nowrap; }
.data-table .strong { font-weight: 600; }

/* ------------------------------------------------ page head + list controls */

.muted { color: var(--muted); }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head h2 { margin: 0 0 2px; font-size: 1.5rem; }
.page-head p { margin: 0; }

.list-controls {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.search-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-input {
  flex: 1;
  min-width: 240px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .92rem;
  background: var(--card);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}
.filter-cell { display: flex; flex-direction: column; gap: 4px; }
.filter-cell span {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--steel);
  font-weight: 700;
}
.filter-cell input {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .85rem;
  background: var(--card);
  min-width: 110px;
}
.filter-actions { display: flex; gap: 8px; align-items: flex-end; margin-left: auto; }

/* sort links in the table header */
.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  text-decoration: none;
}
.sort-link:hover { color: var(--accent); text-decoration: underline; }
.sort-link.active { color: var(--navy); font-weight: 700; }
.sort-dir { font-size: .95em; line-height: 1; }
.list-foot { margin-top: 12px; }

/* ================================================ service & maintenance */

/* status chips — contract & visit statuses */
.chip-active       { background: var(--ok-bg); color: var(--ok); border-color: #b6f0c9; }
.chip-paused       { background: #fff8e6; color: #9a6b00; border-color: #f2dd9a; }
.chip-completed    { background: var(--tint); color: var(--brand-deep); border-color: #bcdcef; }
.chip-scheduled    { background: var(--tint); color: var(--brand-deep); border-color: #bcdcef; }
.chip-in_progress  { background: #fff8e6; color: #9a6b00; border-color: #f2dd9a; }
.chip-overdue      { background: var(--err-bg); color: var(--err); border-color: #ffd5d0; }
.chip-due          { background: var(--tint); color: var(--brand-deep); border-color: #bcdcef; }

/* due-date highlighting in tables */
.due-overdue { color: var(--err); font-weight: 700; }
.due-soon    { color: #9a6b00; font-weight: 600; }
.due-ok      { color: inherit; }

/* stat-card alert variant (the "due / overdue" card) */
.stat-card-alert { border-color: #ffd5d0; background: var(--err-bg); }
.stat-card-alert .stat-num { color: var(--err); }

/* dashboard: upcoming / due lists reuse .recent-list; date chips inline */
.recent-item .chip { margin-left: auto; white-space: nowrap; }

/* info alert variant (contract paused/completed banner) */
.alert-info { background: var(--tint); color: var(--brand-deep); border: 1px solid #bcdcef; }

/* contract detail: two-up grid of cards */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
.detail-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.detail-card h3 { margin: 0 0 14px; font-family: var(--font-display); }
.detail-card h4 { margin: 16px 0 4px; font-size: .82rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); }
.detail-notes p { margin: 4px 0 0; white-space: pre-wrap; }

/* definition list inside a detail card */
.dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: baseline; }
.dl dt { color: var(--muted); font-size: .86rem; }
.dl dd { margin: 0; }

/* visits table: keep long work text readable, action column right-aligned */
.work-done { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visit-actions { text-align: right; white-space: nowrap; }
.visit-actions .btn-tiny { margin-left: 6px; }

/* the inline "mark complete" forms under the visits table */
.complete-visit-form { padding: 10px 0 0; }
.complete-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.complete-label { color: var(--muted); font-size: .9rem; }
.complete-row input[type="date"] { flex: 0 0 auto; }
.complete-row input[type="text"] { flex: 1 1 200px; }
.cost-input { flex: 0 0 110px; }

/* small empty state (inside a section) */
.empty-state.small { padding: 24px 16px; }

/* responsive: stack detail grid on narrow screens */
@media (max-width: 760px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------ responsive */

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .grid { grid-template-columns: 1fr; }
  .search-form input[type="search"] { min-width: 0; flex: 1; }
  .list-head { flex-direction: column; align-items: stretch; }
  .customers { font-size: .9rem; }
  .customers th:nth-child(4),
  .customers td:nth-child(4) { display: none; }
  .tabs-inner { overflow-x: auto; }
  .tab { padding: 10px 14px; white-space: nowrap; }
  .stat-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-num { font-size: 1.7rem; }
  .recent-item { flex-wrap: wrap; }
  .recent-date { order: 5; width: 100%; margin-top: 2px; }
  .filter-row { gap: 6px; }
  .filter-cell { flex: 1 1 45%; }
  .filter-cell input { min-width: 0; width: 100%; }
  .filter-actions { margin-left: 0; width: 100%; }
  .data-table { display: block; overflow-x: auto; }
}

/* ================================================ tasks */

/* the "done" checkbox column */
.data-table th.done-col, .data-table td.done-col { width: 46px; text-align: center; }
.task-check {
  width: 17px;
  height: 17px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--brand);
}

/* title links in the task table (no name-cell class on this table) */
.data-table td.strong a { font-weight: 600; color: var(--navy); text-decoration: none; }
.data-table td.strong a:hover { color: var(--accent); text-decoration: underline; }

/* completed rows: fade + strike the title */
.data-table tr.task-done td { background: #fafcfe; color: var(--muted); }
.data-table tr.task-done td.strong a {
  color: var(--muted);
  text-decoration: line-through;
}
.data-table tr.task-done td.strong a:hover { color: var(--muted); text-decoration: line-through underline; }
.data-table tr.task-done td .due-overdue,
.data-table tr.task-done td .due-soon { font-weight: 500; }

/* --------------------------------- detail-page task lists */

/* customer-level "Tasks" section (h3 + button header) */
.tasks-section { margin-bottom: 26px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h3 { margin: 0; }

/* task rows (shared by the customer section + per-project subsections) */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  margin-bottom: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.task-item .inline-form { margin: 0; }
.task-item .task-check { flex: 0 0 auto; }
.task-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-title:hover { color: var(--accent); text-decoration: underline; }
.task-due { flex: 0 0 auto; font-size: .8rem; color: var(--steel); }
.task-attach { flex: 0 1 auto; font-size: .78rem; color: var(--muted); }
.task-item.task-done { background: #fafcfe; }
.task-item.task-done .task-title { color: var(--muted); text-decoration: line-through; }
.task-item.task-done .task-title:hover { color: var(--muted); }
.task-item.task-done .task-due { font-weight: 500; }
.task-list.compact .task-item { padding: 5px 8px; margin-bottom: 4px; }

/* per-project "Tasks" subsection inside a project card */
.project-tasks {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.project-tasks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.project-tasks-head .label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--steel);
  font-weight: 700;
}

/* ----------------------------------------------- calendar */

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-nav .btn { padding: 6px 12px; }
.cal-month {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  min-width: 190px;
  text-align: center;
}
.cal-filters { margin-bottom: 14px; }
.cal-filters .filter-row { padding: 10px; }

.cal-grid {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--line);
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.cal-weekdays span {
  background: #f8fafc;
  padding: 9px 10px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--steel);
  font-weight: 700;
}
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
}
.cal-cell {
  background: var(--card);
  min-height: 98px;
  padding: 6px 7px;
  overflow: hidden;
}
.cal-cell.cal-blank { background: #f6f9fc; }
.cal-cell.cal-today { background: var(--tint); box-shadow: inset 0 0 0 2px var(--brand-3); }
.cal-daynum {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--steel);
}
.cal-cell.cal-today .cal-daynum { color: var(--brand-deep); font-weight: 700; }

/* task chips inside a calendar cell */
.cal-task {
  display: block;
  margin-top: 4px;
  padding: 2px 6px;
  border: 1px solid #d3e6f0;
  border-radius: 5px;
  background: var(--tint);
  color: var(--navy);
  font-size: .72rem;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-task:hover { background: var(--tint-2); border-color: var(--brand-3); color: var(--brand-deep); }
.cal-task.due-overdue { background: var(--err-bg); border-color: #ffd5d0; color: var(--err); }
.cal-task.due-soon    { background: #fff8e6; border-color: #f2dd9a; color: #9a6b00; }
.cal-task.task-done   { text-decoration: line-through; opacity: .6; }

@media (max-width: 640px) {
  .cal-cell { min-height: 74px; padding: 4px; }
  .cal-task { font-size: .66rem; }
  .cal-month { min-width: 0; font-size: 1.05rem; }
}
