:root {
  --ink: #0b1f2a;          /* deep sea */
  --ink-2: #47606d;
  --ink-3: #7f939d;
  --bg: #eef1f2;           /* surface haze */
  --panel: #ffffff;
  --line: #d9e0e3;
  --accent: #0e7c86;       /* petrol teal */
  --accent-ink: #0a5a61;
  --accent-soft: #e2f1f2;
  --brand: #FEDC00;        /* Cressi yellow */
  --brand-dark: #e6c700;
  --brand-ink: #111111;    /* Cressi black */
  --case-label-size: 14px; /* size of the Case properties titles */
  --amber: #9a6a12;  --amber-soft: #faf0da;
  --green: #2c6e31;  --green-soft: #e4f0e4;
  --red: #a03232;    --red-soft: #f7e4e4;
  --blue: #2b5d8f;   --blue-soft: #e3edf6;
  --radius: 8px;
  font-size: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 19px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }

/* ---- top bar ---- */
.topbar {
  background: var(--ink); color: #fff; display: flex; align-items: center;
  gap: 22px; padding: 0 18px; height: 48px;
  border-bottom: 3px solid var(--accent);
}
.topbar .brand { font-weight: 700; letter-spacing: .4px; font-size: 15px; color: #fff; }
.topbar .brand span { color: #6fc7ce; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: #c8d4da; padding: 6px 12px; border-radius: 6px; font-size: 13.5px;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.topbar nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .user { color: #93a7b0; font-size: 13px; }
.topbar .btn { background: var(--accent); color: #fff; border: none; }
.topbar .btn:hover { background: #0d6f78; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 18px; }
.flash { max-width: 1400px; margin: 10px auto -6px; padding: 0 18px; }
.flash div { padding: 8px 14px; border-radius: var(--radius); margin-bottom: 6px; font-size: 13px; }
.flash .success { background: var(--green-soft); color: var(--green); }
.flash .error { background: var(--red-soft); color: var(--red); }

/* ---- controls ---- */
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 6px; font-size: 13.5px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  cursor: pointer; font-family: inherit;
}
.btn:hover { border-color: var(--brand-ink); text-decoration: none; }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: var(--brand-ink);
  font-weight: 700;
}
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #e3c3c3; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
input, select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 6px; font: inherit; color: var(--ink); background: #fff;
}
input[type="checkbox"], input[type="radio"] {
  width: auto; height: auto; padding: 0; border: none; background: none;
  border-radius: 0; vertical-align: middle;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
label { display: block; font-size: 12px; color: var(--ink-2); margin: 10px 0 3px; font-weight: 600; }

/* ---- status pills ---- */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill.new, .pill.waiting_approval { background: var(--amber-soft); color: var(--amber); }
.pill.waiting_customer { background: var(--blue-soft); color: var(--blue); }
.pill.approved, .pill.delivered { background: var(--green-soft); color: var(--green); }
.pill.form_sent, .pill.form_submitted, .pill.dispatch, .pill.shipped { background: var(--accent-soft); color: var(--accent-ink); }
.pill.service_center { background: var(--blue-soft); color: var(--blue); }
.pill.closed { background: #e7eaec; color: var(--ink-2); }
.pill.rejected { background: var(--red-soft); color: var(--red); }

/* ---- cards / tables ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.metric .n { font-size: 26px; font-weight: 700; }
.metric .l { font-size: 12.5px; color: var(--ink-2); }
table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th { text-align: left; font-size: 12px; color: var(--ink-2); padding: 9px 12px; border-bottom: 1px solid var(--line); background: #f7f9f9; }
table.list td { padding: 9px 12px; border-bottom: 1px solid #edf1f2; font-size: 13.5px; }
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover td { background: #f4f8f8; }
.filters { display: flex; gap: 8px; margin: 0 0 12px; align-items: center; }
.filters input, .filters select { width: auto; }

/* ---- workspace: three panes ---- */
.workspace {
  display: grid; grid-template-columns: 250px minmax(0, 1fr) 290px;
  gap: 14px; align-items: start;
}
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.pane .inner { padding: 14px; }
.pane h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3); }

/* pipeline stepper — the signature */
.pipeline { display: flex; flex-wrap: wrap; gap: 0; margin: 12px 0 16px; }
.step { display: flex; align-items: center; font-size: 11.5px; color: var(--ink-3); }
.step .dot {
  width: 10px; height: 10px; border-radius: 50%; background: #fff;
  border: 2px solid var(--line); margin-right: 5px;
}
.step.done .dot { background: var(--accent); border-color: var(--accent); }
.step.current .dot { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.step.done, .step.current { color: var(--accent-ink); font-weight: 600; }
.step:not(:last-child)::after {
  content: ""; width: 18px; height: 2px; background: var(--line); margin: 0 7px;
}
.step.done:not(:last-child)::after { background: var(--accent); }

/* conversation */
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 10px; }
.msg .avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; background: var(--blue-soft); color: var(--blue);
}
.msg.out .avatar { background: var(--accent-soft); color: var(--accent-ink); }
.msg .bubble { background: #f4f6f7; border-radius: 10px; padding: 9px 13px; min-width: 0; }
.msg.out .bubble { background: var(--accent-soft); }
.msg.note .bubble { background: var(--amber-soft); }
.msg .meta { font-size: 11.5px; color: var(--ink-3); margin-bottom: 3px; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; }
.msg.event { justify-content: center; }
.msg.event .body { font-size: 12px; color: var(--ink-3); background: none; }
.composer { border-top: 1px solid var(--line); padding: 12px 14px; }
.composer .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.composer select { width: auto; }

/* right pane */
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.who .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.kv { font-size: 13px; margin: 3px 0; color: var(--ink-2); }
.kv b { color: var(--ink); font-weight: 600; }
.hist { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.hist .item { font-size: 12.5px; margin-bottom: 8px; }
.hist .item .sub { color: var(--ink-3); font-size: 11.5px; }
.copylink { font-size: 12px; word-break: break-all; background: #f4f6f7; padding: 6px 8px; border-radius: 6px; }

/* public form */
.public { max-width: 560px; margin: 40px auto; padding: 0 16px; }
.public .card { padding: 26px; }
.public .head { border-bottom: 3px solid var(--accent); padding-bottom: 14px; margin-bottom: 16px; }
.public .it { color: var(--ink-3); font-size: 12.5px; font-weight: 400; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
}

/* ---- profile menu ---- */
.usermenu { position: relative; }
.usermenu summary {
  list-style: none; cursor: pointer; color: #c8d4da; font-size: 13px;
  display: flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 6px;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { background: rgba(255,255,255,.1); color: #fff; }
.uavatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.usermenu .menu {
  position: absolute; right: 0; top: 40px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; min-width: 190px;
  box-shadow: 0 8px 24px rgba(11,31,42,.14); padding: 6px; z-index: 50;
}
.usermenu .menu-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--ink-3); padding: 6px 10px 4px; font-weight: 700;
}
.usermenu .menu a, .usermenu .menu button {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  border-radius: 6px; color: var(--ink); font-size: 13.5px; background: none;
  border: none; cursor: pointer; font-family: inherit; text-decoration: none;
}
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--accent-soft); text-decoration: none; }
.usermenu .menu form { margin: 0; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.usermenu .menu button { color: var(--red); }

/* ---- footer ---- */
.sitefooter {
  max-width: 1400px; margin: 26px auto 18px; padding: 14px 18px 0;
  border-top: 1px solid var(--line); color: var(--ink-3);
  font-size: 12px; text-align: center; line-height: 1.7;
}

/* ---- collapsible sidebar gadgets ---- */
.gadget { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.gadget:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.gadget > summary { list-style: none; cursor: pointer; display: flex; align-items: center; }
.gadget > summary::-webkit-details-marker { display: none; }
.gadget > summary h2 { margin: 0; flex: 1; }
.gadget .toggle { font-size: 11px; font-weight: 600; color: var(--accent-ink); text-transform: none; letter-spacing: 0; }
.gadget .when-open { display: none; }
.gadget[open] .when-open { display: inline; }
.gadget[open] .when-closed { display: none; }
.gadget .gbody { margin-top: 8px; }

/* ---- Case properties panel: larger, bolder titles ---- */
.pane.props h2 {
  font-size: calc(var(--case-label-size) + 2px); text-transform: none;
  letter-spacing: 0; color: var(--ink); font-weight: 700;
}
.pane.props label {
  font-size: var(--case-label-size); font-weight: 700; color: var(--ink);
  margin: 16px 0 5px; line-height: 1.25;
}
.pane.props input, .pane.props select, .pane.props textarea { font-size: 14px; }

/* ---- sidebar gadget text size (Customer details ... Interaction history) ---- */
.pane .gadget .gbody, .pane .gadget .kv, .pane .gadget .item,
.pane .gadget .gbody p, .pane .gadget label { font-size: 14px; line-height: 1.55; }
.pane .gadget .sub { font-size: 12.5px; }
.pane .gadget h2 { font-size: 14px; text-transform: none; letter-spacing: 0; }

/* ---- branch bar above the footer ---- */
.branchbar { max-width: 1400px; margin: 26px auto 0; padding: 14px 18px 0; border-top: 1px solid var(--line); }
.branchgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 16px; font-size: 11.5px; color: var(--ink-3); line-height: 1.5;
}
.branchgrid b { color: var(--ink-2); }
.branchbar + .sitefooter { border-top: none; margin-top: 12px; }

/* ---- slide-out menu in the top bar ---- */
.sidemenu { position: relative; margin-right: 4px; }
.sidemenu > summary {
  list-style: none; cursor: pointer; color: #fff; font-size: 18px;
  padding: 2px 8px; border-radius: 6px; opacity: .85;
}
.sidemenu > summary::-webkit-details-marker { display: none; }
.sidemenu > summary:hover { opacity: 1; background: rgba(255,255,255,.12); }
.sidepanel {
  position: absolute; top: 34px; left: 0; z-index: 60; min-width: 210px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(11,31,42,.18); padding: 8px 0;
}
.sidepanel a {
  display: block; padding: 7px 14px; font-size: 13.5px; color: var(--ink); text-decoration: none;
}
.sidepanel a:hover { background: var(--accent-soft); color: var(--accent-ink); }
.sidepanel .menu-title {
  padding: 6px 14px 2px; font-size: 11px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .04em;
}

/* ---- settings hub tiles ---- */
.tilegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; max-width: 900px; }
.tile {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none; color: var(--ink);
  transition: box-shadow .12s, transform .12s, border-color .12s;
}
.tile:hover { border-color: var(--accent); box-shadow: 0 8px 22px rgba(11,31,42,.10); transform: translateY(-1px); }
.tile .ticon { font-size: 22px; line-height: 1; margin-top: 2px; }
.tile b { font-size: 14px; }
.tile .tdesc { font-size: 12px; color: var(--ink-3); margin-top: 3px; line-height: 1.45; }

/* ---- small screens: single case page ---- */
@media (max-width: 760px) {
  .wrap { padding: 10px; }
  .split, .case-split, .workspace { display: block !important; }
  .split > *, .case-split > * { max-width: 100% !important; }
  .composer .row { flex-wrap: wrap; gap: 6px; }
  .composer select, .composer button { max-width: 100% !important; }
  #drafttarget { max-width: 46vw !important; }
  .thread .msg, .thread .body { word-break: break-word; }
  table.list { display: block; overflow-x: auto; white-space: nowrap; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .tilegrid { grid-template-columns: 1fr; }
  h1 { font-size: 20px; }
  .branchgrid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* ---- v76/v79: aligned tick grids on member pages ---- */
.tickgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.tickgrid label {
  font-weight: 400; display: flex; gap: 7px; align-items: flex-start;
  margin: 0; font-size: 12.5px; color: var(--ink); line-height: 1.35;
  text-transform: none; letter-spacing: 0;
}
.tickgrid label input[type="checkbox"] {
  flex: 0 0 auto; margin: 1px 0 0; width: auto; height: auto;
}
.tickgrid label span { display: inline; color: var(--ink); font-size: 12.5px; }
