/* SAMAF Workflow - SAMAF Brand Book palette (#465A6E slate, #D4D8DD, #BEC3CD, #E1E6E6).
   Montserrat for headings and navigation, Carlito (metric twin of Calibri) for text. */

@font-face { font-family: 'Montserrat'; src: url('/fonts/Montserrat-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('/fonts/Montserrat-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('/fonts/Montserrat-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('/fonts/Montserrat-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Carlito'; src: url('/fonts/Carlito-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Carlito'; src: url('/fonts/Carlito-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --paper: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2a36;
  --muted: #5f6b78;
  --line: #d4d8dd;
  --line-2: #bec3cd;
  --slate: #465a6e;
  --slate-dark: #37485a;
  --slate-soft: #e1e6e6;
  --red: #b3261e;
  --red-soft: #fbe9e7;
  --orange: #b85c00;
  --orange-soft: #fff1df;
  --green: #1d7a4f;
  --green-soft: #e4f2ea;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(22, 35, 43, .06), 0 2px 8px rgba(22, 35, 43, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: 'Carlito', Calibri, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.5;
}
h1, h2, h3, .brand-sub, .topnav, .tile .num, .btn { font-family: 'Montserrat', 'Segoe UI', sans-serif; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 17px; font-weight: 600; margin: 28px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
p { margin: 6px 0; }
a { color: var(--slate); }
.sub { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.upper { text-transform: uppercase; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 20px 70px; }
.topbar { background: var(--slate); color: #fff; border-bottom: 3px solid var(--slate-dark); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { height: 30px; display: block; }
.brand-sub { font-size: 15px; font-weight: 500; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.35); }
.topnav { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.topnav a, .topnav button { color: #e8edf1; text-decoration: none; font: inherit; padding: 6px 11px; border-radius: 5px; background: none; border: 0; cursor: pointer; }
.topnav a:hover, .topnav button:hover { background: rgba(255,255,255,.12); color: #fff; }
.topnav a.active { background: rgba(255,255,255,.2); color: #fff; }
.topnav .who { color: #c9d3dc; padding: 6px 8px; font-family: 'Carlito', Calibri, sans-serif; font-size: 14px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 16px 20px 28px; color: var(--muted); font-size: 13.5px; border-top: 1px solid var(--line); }
.loading { color: var(--muted); padding: 40px 0; }

.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head-row .sub { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; align-items: start; }
.grid > .card + .card { margin-top: 0; }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

/* ---------- buttons and forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; padding: 8px 14px; border-radius: 6px;
  border: 1px solid var(--slate); background: var(--slate); color: #fff; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--slate-dark); border-color: var(--slate-dark); }
.btn.ghost { background: #fff; color: var(--slate); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--slate-soft); }
.btn.danger { background: #fff; color: var(--red); border-color: #e3b7b3; }
.btn.danger:hover { background: var(--red-soft); }
.btn.big { font-size: 15px; padding: 12px 20px; }
.btn.sm { font-size: 12.5px; padding: 5px 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--slate); text-decoration: underline; cursor: pointer; font: inherit; font-size: 14px; }
.linkbtn.danger { color: var(--red); }

label.f { display: block; font-size: 13.5px; font-weight: 700; color: var(--muted); margin: 0 0 4px; }
.field { margin-bottom: 12px; }
input[type=text], input[type=email], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 15px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 6px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(70,90,110,.35); outline-offset: 1px; border-color: var(--slate); }
textarea { min-height: 90px; resize: vertical; }
textarea.mono { font-family: Consolas, 'Courier New', monospace; font-size: 13.5px; min-height: 150px; }
input.upper-input { text-transform: uppercase; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }
.hint { font-size: 13px; color: var(--muted); margin-top: 3px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 15px; cursor: pointer; }

.msg { padding: 10px 14px; border-radius: 6px; margin: 10px 0; font-size: 15px; }
.msg.err { background: var(--red-soft); color: #7c1b15; border: 1px solid #efc5c1; }
.msg.ok { background: var(--green-soft); color: #145638; border: 1px solid #bfe0cd; }
.msg.info { background: var(--slate-soft); color: var(--ink); border: 1px solid var(--line); }

/* ---------- status (always colour + icon + words) ---------- */
.rag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; letter-spacing: .3px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.rag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.rag.red { color: var(--red); background: var(--red-soft); }
.rag.orange { color: var(--orange); background: var(--orange-soft); }
.rag.green { color: var(--green); background: var(--green-soft); }
.rag.none { color: var(--muted); background: #eef0f2; }
.edge-red { border-left: 4px solid var(--red) !important; }
.edge-orange { border-left: 4px solid var(--orange) !important; }
.edge-green { border-left: 4px solid var(--green) !important; }

/* ---------- welcome ---------- */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 6px 0 22px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.tile .label { font-size: 13px; color: var(--muted); font-weight: 700; }
.tile .num { font-size: 30px; font-weight: 600; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .note { font-size: 13px; color: var(--muted); }
.tile.red .num { color: var(--red); } .tile.orange .num { color: var(--orange); } .tile.green .num { color: var(--green); }

.board-col { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.board-col > header { padding: 10px 14px; font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.board-col.red > header { background: var(--red-soft); color: var(--red); }
.board-col.orange > header { background: var(--orange-soft); color: var(--orange); }
.board-col.green > header { background: var(--green-soft); color: var(--green); }
.board-col .rule { font-size: 12.5px; font-weight: 400; font-family: 'Carlito', Calibri, sans-serif; opacity: .9; }
.board-list { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.board-list li a { display: block; padding: 10px 14px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.board-list li a:hover { background: #f7f9fa; }
.board-list .cname { font-weight: 700; text-transform: uppercase; }
.board-list .meta { font-size: 13.5px; color: var(--muted); }
.board-list .when { font-size: 13.5px; font-weight: 700; }
.board-empty { padding: 14px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline > li { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.timeline > li:first-child { border-top: 0; }
.timeline .day { font-weight: 700; }
.timeline .day small { display: block; font-weight: 400; color: var(--muted); }
.timeline .items a { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; text-decoration: none; color: inherit; padding: 2px 0; }
.timeline .items a:hover .cname { text-decoration: underline; }
.timeline .cname { font-weight: 700; text-transform: uppercase; }
@media (max-width: 640px) { .timeline > li { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
table.t th { text-align: left; font-size: 12.5px; letter-spacing: .3px; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid #eceef1; vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f7f9fa; }
table.t td.cname a { font-weight: 700; text-transform: uppercase; text-decoration: none; color: var(--ink); }
table.t td.cname a:hover { text-decoration: underline; }
table.t td.r, table.t th.r { text-align: right; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; }

.progress { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.progress .bar { width: 70px; height: 6px; background: #e6e9ec; border-radius: 3px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--slate); border-radius: 3px; }

/* ---------- client profile ---------- */
.profile-head h1 { text-transform: uppercase; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 0; }
.chip { font-size: 13px; padding: 3px 9px; border-radius: 999px; background: var(--slate-soft); color: var(--slate-dark); font-weight: 700; }
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: 15px; }
.dl dt { color: var(--muted); font-weight: 700; font-size: 13.5px; padding-top: 1px; }
.dl dd { margin: 0; white-space: pre-wrap; }
.period { padding: 0; overflow: hidden; }
.period > header { padding: 14px 18px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.period > header h3 { font-size: 16px; margin: 0 0 3px; }
.period .body { padding: 12px 18px 16px; }
.tasks { list-style: none; padding: 0; margin: 0 0 10px; }
.tasks li { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-bottom: 1px dashed #e5e8eb; }
.tasks li.subtask { padding-left: 30px; }
.tasks li:last-child { border-bottom: 0; }
.tasks input[type=checkbox] { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--green); cursor: pointer; flex: none; }
.tasks .ttl { flex: 1; }
.tasks li.done .ttl { color: var(--muted); text-decoration: line-through; }
.tasks .who { font-size: 12.5px; color: var(--muted); display: block; text-decoration: none; }
.tasks .opt { font-size: 11.5px; font-weight: 700; color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; margin-left: 6px; }
.tasks .tools { display: flex; gap: 10px; opacity: 0; transition: opacity .15s; }
.tasks li:hover .tools, .tasks li:focus-within .tools { opacity: 1; }
@media (hover: none) { .tasks .tools { opacity: 1; } }
.addtask { display: flex; gap: 8px; flex-wrap: wrap; }
.addtask input[type=text] { flex: 1 1 260px; }
.addtask select { width: auto; flex: 0 1 240px; }
.panel { background: #f7f9fa; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin-top: 12px; }
.panel.finalise { background: var(--green-soft); border-color: #bfe0cd; }
.next-note { margin-top: 10px; }
details.more > summary { cursor: pointer; color: var(--slate); font-weight: 700; font-size: 14px; }
.activity { list-style: none; padding: 0; margin: 8px 0 0; font-size: 14px; }
.activity li { padding: 5px 0; border-bottom: 1px solid #eceef1; display: grid; grid-template-columns: 130px 1fr; gap: 10px; }
.activity time { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- reports ---------- */
.bars { display: grid; gap: 8px; }
.barrow { display: grid; grid-template-columns: 170px 1fr 44px; gap: 10px; align-items: center; font-size: 14px; }
.barrow .track { height: 18px; background: #f0f2f4; border-radius: 3px; position: relative; }
.barrow .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--slate); min-width: 2px; }
.barrow .fill.red { background: var(--red); } .barrow .fill.orange { background: var(--orange); } .barrow .fill.green { background: var(--green); } .barrow .fill.none { background: #9aa4ae; }
.barrow .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.barrow[title] { cursor: default; }
.barrow:hover .fill { filter: brightness(1.12); }
.cols { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding: 0 2px; border-bottom: 1px solid var(--line-2); }
.cols .c { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 2px; }
.cols .c .v { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cols .c .stack { width: 70%; max-width: 48px; display: flex; flex-direction: column-reverse; gap: 2px; }
.cols .c .seg { width: 100%; border-radius: 4px 4px 0 0; background: var(--slate); }
.cols .c .seg.late { background: var(--red); border-radius: 4px 4px 0 0; }
.cols .c .stack .seg + .seg { border-radius: 4px 4px 0 0; }
.cols .c .stack .seg:not(:last-child) { border-radius: 0; }
.cols-x { display: flex; gap: 6px; padding: 4px 2px 0; }
.cols-x span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 13.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- sign in ---------- */
.signin { max-width: 440px; margin: 9vh auto 0; text-align: center; }
.signin .card { padding: 34px 30px 28px; }
.signin img { height: 54px; margin-bottom: 14px; }
.signin h1 { font-size: 22px; }
.ms-btn { display: inline-flex; align-items: center; gap: 10px; background: #fff; color: #1f1f1f; border: 1px solid #8c8c8c; font: 600 15px 'Segoe UI', 'Montserrat', sans-serif; padding: 10px 18px; border-radius: 4px; text-decoration: none; margin-top: 16px; }
.ms-btn:hover { background: #f3f3f3; }
.ms-logo { display: grid; grid-template-columns: 10px 10px; gap: 2px; }
.ms-logo i { width: 10px; height: 10px; display: block; }

@media print {
  .topbar, .foot, .actions, .filters, .no-print { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .card, .table-wrap, .board-col { box-shadow: none; break-inside: avoid; }
  .wrap { max-width: none; padding: 0; }
}
