/* SALI — Jameson Law design language
   Cues from jamesonlaw.com.au: Poppins, slate #334155, gold #BDA654,
   charcoal #2A2A2E, off-white #F1F1EF, white wordmark on dark. */

:root {
  --charcoal: #2a2a2e;
  --charcoal-2: #1e1e22;
  --slate: #334155;
  --gold: #bda654;
  --gold-soft: #d8c88b;
  --paper: #f1f1ef;
  --white: #ffffff;
  --ink: #26262a;
  --muted: #6d6d74;
  --line: #e3e1da;
  --red: #b00020;
  --amber: #9a6700;
  --green: #2e6b34;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(30, 30, 34, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Poppins", "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--slate); }

/* ---------- wordmark ---------- */
.wordmark { display: inline-flex; flex-direction: column; line-height: 1.05; text-decoration: none; }
.wordmark .name { font-weight: 600; letter-spacing: 0.02em; font-size: 1.25rem; color: var(--white); }
.wordmark .name sup { font-size: 0.5em; font-weight: 400; }
.wordmark .tag {
  font-size: 0.58rem; letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--gold); font-weight: 500; margin-top: 2px;
}

/* ---------- app chrome ---------- */
header.appbar {
  background: var(--charcoal);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1.6rem;
  border-bottom: 3px solid var(--gold);
}
.appbar .right { display: flex; align-items: center; gap: 1rem; }
.appbar .who { color: #cfcfd4; font-size: 0.8rem; }
.appbar nav a {
  color: #e8e8ea; text-decoration: none; font-size: 0.85rem; margin-right: 1.1rem;
}
.appbar nav a:hover { color: var(--gold-soft); }

main { max-width: 1080px; margin: 2.2rem auto 4rem; padding: 0 1.4rem; }

h1 { font-size: 1.55rem; font-weight: 600; color: var(--charcoal); letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 600; color: var(--slate); margin-top: 2.2rem; }
.small, .muted { color: var(--muted); font-size: 0.82rem; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none;
  font-family: inherit; font-weight: 600; font-size: 0.88rem;
  padding: 0.62rem 1.35rem; border-radius: 999px;
  background: var(--gold); color: var(--charcoal-2);
  transition: filter 120ms ease, transform 120ms ease;
}
.btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn.secondary { background: transparent; color: var(--slate); box-shadow: inset 0 0 0 1.5px var(--slate); }
.btn.quiet { background: transparent; color: #cfcfd4; box-shadow: inset 0 0 0 1px #4a4a52; font-weight: 500; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}

input[type="text"], textarea, select {
  font-family: inherit; font-size: 0.9rem; color: var(--ink);
  padding: 0.55rem 0.75rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--white); width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
label { font-size: 0.78rem; font-weight: 600; color: var(--slate); display: block; margin-bottom: 0.25rem; }

/* ---------- cards & tables ---------- */
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem 1.6rem; margin: 1rem 0; box-shadow: 0 2px 10px rgba(30,30,34,0.04);
}
table.list { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; }
table.list th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--white); background: var(--slate); padding: 0.6rem 0.9rem;
}
table.list td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); font-size: 0.88rem; vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }

.pill { display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.6rem; border-radius: 999px; }
.pill.ok { background: #e7efe8; color: var(--green); }
.pill.gap { background: #fff6e0; color: var(--amber); }
.pill.blocker { background: #fbeaea; color: var(--red); }
.pill.neutral { background: #ececef; color: var(--slate); }

.flag { border-left: 4px solid var(--red); background: #fbeaea; padding: 0.7rem 1rem; border-radius: 0 8px 8px 0; margin: 0.5rem 0; font-size: 0.9rem; }
.flag.first { font-weight: 600; }

/* ---------- login ---------- */
body.login-body {
  /* Jameson Law homepage hero, darkened for legibility */
  background:
    linear-gradient(160deg, rgba(30, 30, 34, 0.82) 0%, rgba(42, 42, 46, 0.66) 55%, rgba(51, 65, 85, 0.72) 100%),
    url("hero.webp") center / cover no-repeat fixed,
    var(--charcoal-2);
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.login-card {
  width: min(400px, 92vw); text-align: center;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px; padding: 3rem 2.6rem 2.6rem;
  backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.login-card .wordmark { margin-bottom: 2rem; }
.login-card .wordmark .name { font-size: 1.7rem; }
.login-card h1 { color: var(--white); font-size: 1.02rem; font-weight: 500; margin: 0 0 0.4rem; }
.login-card .sub { color: #b9b9c0; font-size: 0.8rem; margin-bottom: 2rem; }
.login-card .rule { height: 2px; width: 44px; background: var(--gold); margin: 1.2rem auto 1.6rem; border: 0; }
.btn.ms {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; padding: 0.8rem; font-size: 0.92rem;
}
.login-error { color: #ffb3b8; background: rgba(176,0,32,0.18); border: 1px solid rgba(176,0,32,0.4);
  border-radius: 8px; padding: 0.6rem 0.9rem; font-size: 0.82rem; margin-bottom: 1.2rem; }
.login-foot { margin-top: 2rem; color: #8e8e96; font-size: 0.68rem; letter-spacing: 0.04em; }

/* ---------- hub ---------- */
.hub-hero { margin: 1rem 0 2rem; }
.hub-hero h1 { margin-bottom: 0.2rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.2rem; }
.tile {
  position: relative; display: block; text-decoration: none;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.7rem 1.6rem 1.5rem; box-shadow: 0 2px 10px rgba(30,30,34,0.05);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.tile.live { border-top: 4px solid var(--gold); }
.tile.live:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tile.soon { opacity: 0.62; border-top: 4px solid var(--line); cursor: default; }
.tile .kicker { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.28em; color: var(--gold); font-weight: 600; }
.tile.soon .kicker { color: var(--muted); }
.tile h3 { margin: 0.45rem 0 0.4rem; font-size: 1.18rem; color: var(--charcoal); }
.tile p { margin: 0; font-size: 0.84rem; color: var(--muted); }
.tile .go { position: absolute; right: 1.3rem; top: 1.45rem; color: var(--gold); font-size: 1.2rem; }

/* ---------- matter page ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
.qa-item { border-bottom: 1px solid var(--line); padding: 0.9rem 0; }
.qa-item:last-child { border-bottom: 0; }
.qa-item .why { font-size: 0.78rem; color: var(--muted); margin: 0.15rem 0 0.5rem; }
.report-row { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.report-row:last-child { border-bottom: 0; }
.banner { background: #fff6e0; border: 1px solid #ecd9a0; color: var(--amber); border-radius: 8px; padding: 0.6rem 1rem; font-size: 0.84rem; margin: 1rem 0; }
form.inline { display: inline; }
.actions { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
progress-note { display: block; }

/* ---------- analysis job ---------- */
.job { display: flex; gap: 0.9rem; align-items: flex-start; padding: 0.9rem 1rem;
  border-radius: 8px; background: #f6f3e6; border: 1px solid #e6dcb3; font-size: 0.9rem; }
.spinner { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 2px; border-radius: 50%;
  border: 2.5px solid #e6dcb3; border-top-color: var(--gold); animation: sali-spin 0.9s linear infinite; }
@keyframes sali-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--gold); } }

/* ---------- matter sub-navigation ---------- */
.matter-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.subnav { display: flex; gap: 1.2rem; margin-top: 0.3rem; }
.subnav a { text-decoration: none; font-size: 0.86rem; font-weight: 500; color: var(--muted); padding-bottom: 0.25rem; border-bottom: 2px solid transparent; }
.subnav a.on { color: var(--charcoal); border-bottom-color: var(--gold); }
.subnav a:hover { color: var(--slate); }

/* ---------- matter chat ---------- */
.chat-layout { display: grid; grid-template-columns: 250px 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 800px) { .chat-layout { grid-template-columns: 1fr; } }
.chat-side { position: sticky; top: 1rem; }
.conv-list { margin-top: 0.9rem; display: flex; flex-direction: column; gap: 0.35rem; max-height: 65vh; overflow-y: auto; overflow-x: hidden; }
.conv { display: block; text-decoration: none; padding: 0.55rem 0.75rem; border-radius: 8px; border: 1px solid transparent; }
.conv .t, .conv .small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .t { font-size: 0.84rem; color: var(--ink); }
.conv:hover { background: var(--white); border-color: var(--line); }
.conv.on { background: var(--white); border-color: var(--gold); }
.chat-main { margin: 0; padding: 0; display: flex; flex-direction: column; min-height: 60vh; }
.thread { flex: 1; overflow-y: auto; max-height: 64vh; padding: 1.2rem 1.4rem; display: flex; flex-direction: column; gap: 0.9rem; }
.msg { max-width: 88%; border-radius: 12px; padding: 0.7rem 0.95rem; font-size: 0.9rem; }
.msg .meta { font-size: 0.7rem; color: var(--muted); margin-bottom: 0.2rem; }
.msg.user { align-self: flex-end; background: #f3efdf; border: 1px solid #e6dcb3; }
.msg.sali { align-self: flex-start; background: var(--white); border: 1px solid var(--line); }
.msg.error { align-self: stretch; max-width: none; background: #fbeaea; border-left: 4px solid var(--red); border-radius: 0 8px 8px 0; }
.msg.pending { display: flex; gap: 0.6rem; align-items: center; color: var(--muted); }
.msg .docs { font-size: 0.72rem; color: var(--slate); background: #eef1f5; border-radius: 6px; padding: 0.2rem 0.5rem; margin-bottom: 0.4rem; display: inline-block; }
.md p { margin: 0.35rem 0; }
.md ul, .md ol { margin: 0.35rem 0; padding-left: 1.3rem; }
.md li { margin: 0.15rem 0; }
.md .md-h { font-weight: 600; color: var(--slate); margin-top: 0.7rem; }
.md code { background: #f1f1ef; padding: 0 0.3rem; border-radius: 4px; font-size: 0.84em; }
.md-table { overflow-x: auto; margin: 0.5rem 0; }
.md-table table.list th, .md-table table.list td { padding: 0.4rem 0.6rem; font-size: 0.8rem; }
.composer { border-top: 1px solid var(--line); padding: 0.9rem 1.2rem 1rem; }
.chat-empty .composer { border-top: 0; padding: 0; }
.chat-empty { padding: 1.6rem; }
.composer-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 0.6rem; }
.btn:disabled { opacity: 0.55; cursor: progress; transform: none; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.7rem; }
.chip { font-family: inherit; font-size: 0.78rem; background: var(--paper); border: 1px solid var(--line); color: var(--slate); border-radius: 999px; padding: 0.35rem 0.8rem; cursor: pointer; }
.chip:hover { border-color: var(--gold); }
#chat-error { margin: 0 1.2rem; }

/* ---------- client emails & uploads ---------- */
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; }
.checklist { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.7rem; background: #fcfcfb; }
.checklist.short { max-height: 160px; }
label.check { display: flex; gap: 0.55rem; align-items: flex-start; font-weight: 400; font-size: 0.85rem; color: var(--ink); padding: 0.3rem 0; margin: 0; }
label.check input { margin-top: 0.3rem; }
label.check .small { display: block; }
.small-btn { padding: 0.3rem 0.8rem; font-size: 0.75rem; }
.copyrow { display: flex; gap: 0.6rem; align-items: center; }
.copyrow input { font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; }
.linkbox { border: 2px solid var(--gold); }
details summary { list-style: none; cursor: pointer; display: inline-block; }
details summary::-webkit-details-marker { display: none; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 1.1rem 0; }
.grid2.wide-left { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 800px) { .grid2.wide-left { grid-template-columns: 1fr; } }
textarea#body { font-family: "Segoe UI", system-ui, sans-serif; font-size: 0.9rem; line-height: 1.5; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.stat { display: flex; flex-direction: column; text-decoration: none; background: var(--white); border: 1px solid var(--line);
  border-top: 4px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; }
.stat .n { font-size: 2rem; font-weight: 600; color: var(--charcoal); line-height: 1.1; }
.stat .l { font-size: 0.8rem; color: var(--muted); }
.stat.hot { border-top-color: var(--red); }
.stat.warm { border-top-color: var(--gold); }
.row-item { padding: 0.55rem 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.row-item:last-child { border-bottom: 0; }

/* ---------- public upload page ---------- */
body.public-body { background: var(--paper); }
header.appbar.public .lock { color: var(--gold-soft); font-size: 0.85rem; font-weight: 500; }
.public-main { max-width: 640px; }
.public-main h1 { font-size: 1.35rem; }
.notice { border-radius: 8px; padding: 0.7rem 1rem; margin: 1rem 0; font-size: 0.9rem; }
.notice.ok { background: #e7efe8; color: var(--green); border: 1px solid #c4dcc7; }
.notice.bad { background: #fbeaea; color: var(--red); border: 1px solid #f0c9c9; }
ul.req li, ul.received li { margin: 0.25rem 0; font-size: 0.9rem; }
.upload-form { margin-top: 1.2rem; padding: 1.1rem; border: 1.5px dashed var(--gold); border-radius: 10px; background: #fdfcf7; }
.upload-form input[type=file] { margin: 0.4rem 0 0.6rem; width: 100%; }
.public-foot { text-align: center; margin-top: 1.4rem; }

/* ---------- lodgement field map ---------- */
.stat.ok-top { border-top-color: var(--green); }
table.fieldmap td { vertical-align: top; }
table.fieldmap tr.section td { background: #f6f5f0; font-weight: 600; color: var(--slate); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
table.fieldmap input.note { margin-top: 0.35rem; font-size: 0.78rem; padding: 0.35rem 0.6rem; }
table.fieldmap tr.d-blank td { background: #fafafa; color: var(--muted); }
table.fieldmap select { min-width: 120px; }
ol.steps li { margin: 0.4rem 0; }
pre.qa { white-space: pre-wrap; font-size: 0.82rem; background: #fafaf8; border: 1px solid var(--line); border-radius: 8px; padding: 1rem; max-height: 480px; overflow: auto; }

/* ---------- hub branding ---------- */
.sali-logo { display: block; height: 56px; width: auto; margin-bottom: 0.35rem; }
.sali-tagline { font-size: 0.95rem; font-weight: 500; color: var(--slate); letter-spacing: 0.02em; margin-bottom: 0.5rem; }
h2.hub-section { margin: 0 0 0.9rem; font-size: 1.15rem; color: var(--charcoal); }

/* ---------- app bar on narrow screens ---------- */
.appbar nav a { white-space: nowrap; }
@media (max-width: 860px) {
  header.appbar { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 1rem; }
  .appbar .right { flex-wrap: wrap; gap: 0.6rem; }
  .appbar .who { display: none; }
  .appbar nav a { margin-right: 0.8rem; }
}

/* ---------- small screens: nothing may push the page wider than the viewport ---------- */
.grid2 > *, .chat-layout > *, .card { min-width: 0; }
input[type="file"] { max-width: 100%; }
@media (max-width: 800px) {
  main { padding: 0 1rem; margin-top: 1.4rem; }
  table.list { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card { padding: 1.1rem 1.1rem; }
  .composer-row, .actions { flex-wrap: wrap; }
  .copyrow { flex-direction: column; align-items: stretch; }
}
