/* Contractor In Charge brand (BrandKit: Logo Color Kit, Color Shade Kit, Typography),
   laid out like the CIC Customer Portal redesign: dark charcoal sidebar, teal accent,
   gold for highlights. */
:root {
  --teal: #00a3aa;          /* Light Sea Green, primary */
  --teal-ink: #0b6c70;      /* teal shade for text on light backgrounds */
  --teal-soft: #e4f4f4;
  --teal-line: #b7e2e3;
  --charcoal: #2e3532;      /* primary dark: sidebar, primary buttons */
  --charcoal-hover: #3a423f;
  --gold: #f3bf33;          /* Goldenrod: highlights */
  --gold-soft: #fdf3d6;
  --gold-ink: #8a6206;
  --pearl: #f8f4f9;         /* Pearl White: page background */

  --bg: var(--pearl);
  --surface: #ffffff;
  --surface-2: #fbf9fb;
  --border: #e7e3e8;
  --border-2: #d9d4da;
  --text: #1f2422;
  --text-2: #464c49;
  --muted: #747b78;
  --faint: #a9afab;
  --ok: #1e8f52;
  --ok-soft: #e6f5ec;
  --warn: #b8730c;
  --warn-soft: #fdf1dc;
  --bad: #c8403b;
  --bad-soft: #fbe9e7;
  --side-ink: #e9ebe8;
  --side-muted: #a3aba7;
  --side-line: #414946;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(46, 53, 50, .05), 0 1px 1px rgba(46, 53, 50, .03);
  /* The brand typeface is Helvetica Now Display (Neue Haas Grotesk Display): bold for
     headings, regular for body. It is licensed, so machines without it fall back to
     Helvetica / Arial. */
  --font: "Helvetica Now Display", "Neue Haas Grotesk Display Pro", "Neue Haas Grotesk Display",
          "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--teal-ink); text-decoration: none; }
a:hover { color: var(--teal); text-decoration: underline; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

button {
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
}
button:hover { border-color: var(--faint); }
button.primary { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }
button.primary:hover { background: var(--charcoal-hover); }
button.link { border: none; background: none; height: auto; padding: 4px 6px; color: var(--teal-ink); }
button.link:hover { color: var(--teal); text-decoration: underline; }
button.link.danger { color: var(--bad); }
button.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
input, select {
  font: inherit; width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
input:focus, select:focus { outline: 3px solid var(--teal-soft); border-color: var(--teal); }

/* layout: sidebar + main */
.app { display: flex; min-height: 100vh; }
.side {
  width: 232px; flex: 0 0 232px; background: var(--charcoal); color: var(--side-ink);
  display: flex; flex-direction: column; gap: 6px; padding: 20px 14px 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; color: var(--side-ink); }
.brand:hover { text-decoration: none; color: #fff; }
.brand img { width: 32px; height: 32px; }
.brand b { display: block; font-size: 16px; font-weight: 700; line-height: 1.15; }
.brand small { display: block; color: var(--side-muted); font-size: 11px; }
.client-switch {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 8px 10px;
  background: var(--charcoal-hover); border: 1px solid var(--side-line); border-radius: 10px;
}
.client-switch .av {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px; background: var(--teal); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 11px;
}
.client-switch select {
  height: 30px; padding: 0 4px; border: 0; background: transparent; color: var(--side-ink); font-weight: 500;
  min-width: 0; cursor: pointer;
}
.client-switch select:focus { outline: none; }
.client-switch select option { color: var(--text); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .sec { color: #7f8783; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; padding: 12px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--side-muted); font-weight: 500; font-size: 13.5px; position: relative;
}
.nav a:hover { background: var(--charcoal-hover); color: var(--side-ink); text-decoration: none; }
.nav a.current { background: var(--charcoal-hover); color: #fff; }
.nav a.current::before {
  content: ""; position: absolute; left: -14px; top: 9px; width: 3px; height: 22px; border-radius: 3px; background: var(--teal);
}
.pill-count {
  margin-left: auto; background: var(--teal); color: #fff; font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 999px;
}
.side-foot {
  margin-top: auto; display: grid; gap: 8px; padding: 12px 4px 0; border-top: 1px solid var(--side-line);
  font-size: 12px;
}
.side-foot form { margin: 0; }
.intake {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px; border: 0;
  background: none; color: var(--side-ink); font-size: 12.5px; text-align: left; border-radius: 6px;
}
.intake:hover { background: var(--charcoal-hover); }
.intake.off { color: var(--side-muted); }
.engine {
  justify-self: start; margin-left: 8px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
  background: var(--charcoal-hover); color: var(--side-muted);
}
.engine.on { background: rgba(0, 163, 170, .18); color: #7fd6da; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { padding: 28px 32px 48px; }
.notice {
  margin: 20px 32px 0; padding: 11px 16px; border-radius: var(--radius-sm);
  background: var(--teal-soft); border: 1px solid var(--teal-line); color: var(--teal-ink);
}
.notice.warn { background: var(--gold-soft); border-color: #f3dc9a; color: #5f4405; }
.notice a, .issue a { color: inherit; text-decoration: underline; }

/* page headings */
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-h h1, .vendors h1 { font-size: 24px; line-height: 1.2; }
.page-h p, .vendors > p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; max-width: 75ch; }
.vendors > p { margin-bottom: 20px; }

.banner {
  display: block; margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--gold-soft); border: 1px solid #f3dc9a; color: #5f4405; font-weight: 500;
}
.banner:hover { text-decoration: none; color: #5f4405; filter: brightness(.98); }
.field.flagged select { border-color: var(--gold); background: var(--gold-soft); }
.address { font-family: var(--mono); font-size: 12.5px; }
.copy { margin-left: 6px; }
.clients-add { display: flex; gap: 12px; align-items: end; margin: 0 0 20px; max-width: 760px; }
.clients-add label { flex: 1; }

/* inbox */
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex: 1; }
.tabs a {
  padding: 10px 12px; margin-bottom: -1px; color: var(--muted); font-weight: 500; font-size: 13.5px;
  border-bottom: 2px solid transparent; display: inline-flex; gap: 8px; align-items: center;
}
.tabs a.current { color: var(--text); border-color: var(--teal); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.tabs a.current .count { background: var(--teal); border-color: var(--teal); color: #fff; }
.search { width: min(340px, 100%); }
.dropzone {
  border: 1.5px dashed var(--border-2); border-radius: var(--radius); background: var(--surface);
  padding: 16px; text-align: center; color: var(--muted); margin-bottom: 20px; transition: all .15s;
}
.dropzone input { display: none; }
.dropzone label { cursor: pointer; display: block; }
.dropzone strong { color: var(--text); }
.dropzone.dragging { border-color: var(--teal); background: var(--teal-soft); }
.export {
  display: flex; align-items: center; gap: 16px; padding: 12px 16px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.export button { margin-left: auto; }
table.documents {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  font-size: 13.5px;
}
.documents th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap;
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.documents td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.documents tbody tr { cursor: pointer; }
.documents tbody tr:hover td { background: #fcfbfc; }
.documents tr:last-child td { border-bottom: none; }
.documents td.mono, .documents td.nowrap { white-space: nowrap; }
.documents td.received { max-width: 220px; overflow-wrap: anywhere; font-size: 12.5px; }
.documents .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.overdue { color: var(--bad); font-weight: 700; }
.empty {
  border: 1px dashed var(--border-2); border-radius: var(--radius); padding: 32px; text-align: center;
  color: var(--muted); background: var(--surface-2);
}
.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px;
  font-weight: 500; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.pill.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.pill.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.pill.subtle { background: var(--teal-soft); border-color: transparent; color: var(--teal-ink); }
.pill.status-approved, .pill.status-exported { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.pill.status-failed { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.pill.status-review { background: var(--gold-soft); border-color: transparent; color: var(--gold-ink); }

/* review screen */
body.review main { padding: 0; }
.review-layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; height: 100vh; }
.viewer { overflow-y: auto; padding: 28px; background: #ece8ed; }
.page {
  position: relative; max-width: 860px; margin: 0 auto 20px; background: white; border-radius: 4px;
  box-shadow: 0 1px 3px rgba(46, 53, 50, .12), 0 6px 20px rgba(46, 53, 50, .08);
}
.page img { display: block; width: 100%; border-radius: 4px; }
.box {
  position: absolute; border-radius: 3px; background: rgba(0, 163, 170, .10);
  outline: 1.5px solid rgba(0, 163, 170, .55); outline-offset: 1px; transition: all .12s; cursor: pointer;
}
.box.active { background: rgba(243, 191, 51, .38); outline: 2px solid #d9a21c; }
.viewer-foot { text-align: center; color: var(--muted); font-size: 12px; }
.panel { overflow-y: auto; background: var(--surface); border-left: 1px solid var(--border); padding: 20px 24px 32px; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; font-size: 13px; }
.panel-head .pill { margin-left: auto; text-transform: capitalize; }
.issues { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.issue { padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.issue.error { background: var(--gold-soft); border: 1px solid #f3dc9a; color: #5f4405; }
.issue.warning { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.issue[data-field] { cursor: pointer; }
.all-clear {
  color: var(--ok); background: var(--ok-soft); padding: 9px 12px; border-radius: var(--radius-sm);
  margin: 0 0 16px; font-weight: 500;
}
.processing { color: var(--muted); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 12px; }
.field { display: block; }
.field[data-field="vendor_name"], .field.wide { grid-column: span 2; }
.field-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
.source { font-weight: 400; font-size: 11px; color: var(--faint); }
.field.flagged input { border-color: var(--gold); background: var(--gold-soft); }
.field.active input { border-color: var(--teal); }
.actions { display: flex; gap: 8px; margin-top: 20px; }
.actions .primary { flex: 1; }
.actions.secondary { margin-top: 8px; justify-content: space-between; }
.lines { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 14px; }
.lines summary { cursor: pointer; font-weight: 700; font-size: 13px; }
.lines table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; }
.lines th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border); padding: 5px 4px; }
.lines td { padding: 5px 4px; border-bottom: 1px solid #f2eff3; vertical-align: top; }
.meta { display: grid; grid-template-columns: 80px 1fr; gap: 4px 10px; margin-top: 24px; font-size: 12.5px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }

/* vendors and clients */
form.inline { display: flex; gap: 10px; align-items: center; }
form.inline input[name="default_category"] { max-width: 240px; }
form.inline label { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
form.inline input[type="checkbox"] { width: auto; height: auto; accent-color: var(--teal); }

/* invoices split from one file */
tr.batch-head td { background: var(--teal-soft); padding-top: 10px; padding-bottom: 10px; cursor: default; }
tr.batch-head .batch-title { font-weight: 700; }
tr.batch-head form.inline { display: inline-flex; margin-left: 12px; }
tr.in-batch td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
.batch-nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 0 0 14px; font-size: 13px; }
.batch-nav .muted { width: 100%; margin-bottom: 2px; }
.batch-nav .chip {
  min-width: 28px; height: 28px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 6px;
  text-decoration: none; border: 1px solid var(--border-2); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.batch-nav .chip:hover { border-color: var(--teal); color: var(--teal-ink); }
.batch-nav .chip.status-approved, .batch-nav .chip.status-exported { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.batch-nav .chip.current { background: var(--charcoal); border-color: var(--charcoal); color: #fff; font-weight: 700; }
.split-actions { margin: -4px 0 14px; }

/* sign-in */
.signed-in { display: flex; align-items: center; gap: 6px; padding: 0 8px; color: var(--side-muted); font-size: 12px; min-width: 0; }
.signed-in span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signed-in button.link { color: var(--side-ink); padding: 2px 4px; font-size: 12px; }
.login-body { background: var(--bg); }
.login { max-width: 420px; margin: 12vh auto 0; padding: 0 20px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-brand b { display: block; font-size: 20px; font-weight: 700; line-height: 1.1; }
.login-brand small { color: var(--muted); font-size: 12px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px;
}
.login-card h1 { font-size: 22px; margin-bottom: 8px; }
.login-card p { color: var(--text-2); margin: 0 0 16px; }
.login-card form { display: grid; gap: 12px; }
.login-card button.primary { height: 40px; }
.login-error { color: var(--bad) !important; background: var(--bad-soft); padding: 8px 12px; border-radius: var(--radius-sm); }
