:root {
  --ink: #1C2A22;
  --paper: #F4F6F3;
  --card: #FFFFFF;
  --line: #DCE3DD;
  --text: #1C2A22;
  --muted: #5E6E64;
  --leaf: #2D6A4F;
  --leaf-dark: #1F4D39;
  --leaf-soft: #E2EEE6;
  --danger: #B42318;
  --s-new: #B45309;
  --s-contacted: #2563A8;
  --s-quoted: #6D4AA8;
  --s-won: #2D6A4F;
  --s-lost: #8A958F;
  --radius-sm: 6px;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--leaf-dark); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #7FB89A; outline-offset: 2px; }
.boot { padding: 2rem; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--card);
  padding: .5rem .9rem; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none; color: var(--text); font-weight: 550; }
.btn:hover { border-color: #B7C4BB; }
.btn-primary { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.btn-primary:hover { background: var(--leaf-dark); border-color: var(--leaf-dark); }
.btn-danger { color: var(--danger); border-color: #F0C8C4; }
.btn-danger:hover { border-color: var(--danger); }
.btn:disabled { opacity: .6; cursor: default; }
label { display: block; font-weight: 550; font-size: .9rem; margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
input:focus, select:focus, textarea:focus { border-color: var(--leaf); outline: none; box-shadow: 0 0 0 3px var(--leaf-soft); }
textarea { min-height: 140px; resize: vertical; }
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .3rem 0 0; }
.error { color: var(--danger); font-size: .9rem; margin: .5rem 0 0; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.login-side { background: var(--ink); color: #DDE8E1; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-side .brand { color: #fff; }
.login-side p { max-width: 30ch; font-size: 1.35rem; line-height: 1.35; color: #fff; margin: 0; }
.login-side small { color: #9FB3A7; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-form { width: 100%; max-width: 360px; }
.login-form h1 { margin-bottom: .4rem; }
.login-form .sub { color: var(--muted); margin: 0 0 1.6rem; }
.login-form .btn { width: 100%; justify-content: center; padding: .65rem; }
@media (max-width: 760px) { .login-wrap { grid-template-columns: 1fr; } .login-side { padding: 1.5rem; gap: 1rem; } .login-side p { font-size: 1.1rem; } }

/* Shell */
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 650; font-size: 1.02rem; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: #2E4537; display: grid; place-items: center; }
.brand small { display: block; font-weight: 400; font-size: .78rem; color: #9FB3A7; }
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: #DDE8E1; padding: 1.25rem .9rem; display: flex; flex-direction: column; gap: 1.6rem; position: sticky; top: 0; height: 100vh; }
.side .brand { color: #fff; padding: 0 .4rem; }
.nav { display: flex; flex-direction: column; gap: .15rem; }
.nav a { color: #C9D7CF; text-decoration: none; padding: .55rem .7rem; border-radius: var(--radius-sm); display: flex; justify-content: space-between; align-items: center; }
.nav a:hover { background: #26382D; color: #fff; }
.nav a[aria-current=page] { background: #2E4537; color: #fff; font-weight: 600; }
.nav .badge { background: var(--s-new); color: #fff; font-size: .75rem; font-weight: 700; border-radius: 99px; padding: 0 .5rem; min-width: 1.5rem; text-align: center; }
.side-foot { margin-top: auto; font-size: .85rem; color: #9FB3A7; padding: 0 .4rem; }
.side-foot .who { color: #DDE8E1; word-break: break-all; margin-bottom: .5rem; }
.linkish { background: none; border: 0; padding: 0; color: #C9D7CF; text-decoration: underline; cursor: pointer; }
.main { padding: 2rem 2.5rem 4rem; max-width: 1180px; width: 100%; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .8rem 1rem; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; display: flex; gap: .8rem; align-items: center; }
  .side-foot .who { display: none; }
  .main { padding: 1.25rem 1rem 3rem; }
}

/* Page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.page-head .sub { color: var(--muted); margin: .3rem 0 0; }
.back { display: inline-block; margin-bottom: .8rem; color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--text); }
.section { margin-top: 2.2rem; }
.section > h2 { margin-bottom: .9rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }

/* Overview figures */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.figure { padding: 1.1rem 1.25rem; border-left: 1px solid var(--line); text-decoration: none; color: inherit; display: block; }
.figure:first-child { border-left: 0; }
a.figure:hover { background: #FAFBF9; }
.figure .num { font-size: 2.1rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.figure .lbl { color: var(--muted); font-size: .9rem; }
.figure.attention .num { color: var(--s-new); }
@media (max-width: 700px) { .figures { grid-template-columns: 1fr 1fr; } .figure:nth-child(3) { border-left: 0; } .figure:nth-child(n+3) { border-top: 1px solid var(--line); } }

/* Pipeline: the one bold element */
.pipeline { display: flex; height: 56px; border-radius: var(--radius); overflow: hidden; background: var(--line); }
.pipeline a { display: flex; align-items: center; padding: 0 .8rem; color: #fff; text-decoration: none; font-weight: 650; min-width: 0; white-space: nowrap; overflow: hidden; transition: filter .15s; }
.pipeline a:hover { filter: brightness(1.1); }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin-top: .75rem; font-size: .9rem; }
.legend a { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: .45rem; }
.legend a:hover { text-decoration: underline; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bg-new { background: var(--s-new); } .bg-contacted { background: var(--s-contacted); } .bg-quoted { background: var(--s-quoted); }
.bg-won { background: var(--s-won); } .bg-lost { background: var(--s-lost); }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1.5rem; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.bars { display: grid; gap: .7rem; }
.bar-row { display: grid; grid-template-columns: 11rem minmax(0, 1fr) 2rem; align-items: center; gap: .7rem; font-size: .92rem; }
.bar-track { height: 10px; background: var(--leaf-soft); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--leaf); border-radius: 99px; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
@media (max-width: 500px) { .bar-row { grid-template-columns: 1fr 2rem; } .bar-track { grid-column: 1 / -1; grid-row: 2; } }

.latest { list-style: none; margin: 0; padding: 0; }
.latest li + li { border-top: 1px solid var(--line); }
.latest a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .7rem 0; text-decoration: none; color: inherit; }
.latest a:hover .nm { text-decoration: underline; }
.latest .nm { font-weight: 600; }
.latest .meta { color: var(--muted); font-size: .85rem; grid-column: 1; }
.latest .pill { grid-row: 1 / span 2; grid-column: 2; align-self: center; }

.empty { color: var(--muted); padding: 1.5rem 0; }
.empty strong { color: var(--text); display: block; margin-bottom: .3rem; }

/* Status pill */
.pill { display: inline-block; font-size: .78rem; font-weight: 650; padding: .15rem .55rem; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.pill-new { color: var(--s-new); background: #FDF3E7; }
.pill-contacted { color: var(--s-contacted); background: #EAF1FA; }
.pill-quoted { color: var(--s-quoted); background: #F1ECF8; }
.pill-won { color: var(--s-won); background: var(--leaf-soft); }
.pill-lost { color: #66716B; background: #EFF1EF; }

/* Enquiries list */
.filters { display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: center; margin-bottom: 1rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; }
.tab { border: 1px solid var(--line); background: var(--card); padding: .35rem .8rem; border-radius: 99px; cursor: pointer; font-size: .9rem; }
.tab[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters select { width: auto; min-width: 13rem; }
.filters input[type=search] { width: 15rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; margin: 0; cursor: pointer; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .82rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #FAFBF9; }
td .nm { font-weight: 600; text-decoration: none; color: var(--text); }
td .sm { color: var(--muted); font-size: .85rem; }
.overdue { color: var(--danger); font-weight: 600; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; color: var(--muted); font-size: .9rem; gap: 1rem; flex-wrap: wrap; }
.pager .btns { display: flex; gap: .5rem; }
@media (max-width: 700px) {
  .filters select, .filters input[type=search] { width: 100%; }
  thead { display: none; }
  table, tbody, tr, td { display: block; }
  tr { padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
  td { border: 0; padding: .1rem 0; }
  .col-hide-sm { display: none; }
}

/* Enquiry detail */
.detail { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.message { white-space: pre-wrap; word-break: break-word; margin: 0; font-size: 1rem; line-height: 1.6; max-width: 70ch; }
dl.facts { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: .55rem 1rem; margin: 0; font-size: .93rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; word-break: break-word; }
.head-line { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.save-row { display: flex; gap: .8rem; align-items: center; }
.danger-zone { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.danger-zone p { color: var(--muted); font-size: .88rem; margin: 0 0 .7rem; }

/* Account */
.narrow { max-width: 440px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); background: var(--ink); color: #fff;
  padding: .7rem 1.1rem; border-radius: var(--radius-sm); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--danger); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
