/* panel.tica.cat — misma paleta que www.tica.cat */
:root {
  --brand: #00b395;
  --brand-dark: #00876f;
  --brand-darker: #06564a;
  --brand-wash: #e3f4ef;
  --ink: #11201d;
  --ink-soft: #3f514d;
  --muted: #6b7b77;
  --paper: #f6f4ee;
  --card: #fffdf8;
  --line: #e3ddd0;
  --line-soft: #eee9dd;
  --accent: #ff6a3d;
  --warn-bg: #fff3df;
  --warn-ink: #7a4a00;
  --err-bg: #fde8e3;
  --err-ink: #8a2611;
  --ok-bg: #e3f4ef;
  --ok-ink: #06564a;
  --radius: 10px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font-body);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--font-body);
}
a { color: var(--brand-dark); text-underline-offset: 2px; }
a:hover { color: var(--brand-darker); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .8em; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ---------- layout ---------- */
.topbar {
  background: var(--ink);
  color: #dfe9e6;
}
.topbar .wrap { display: flex; align-items: center; gap: 1.5rem; min-height: 56px; }
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  text-decoration: none;
  display: flex; align-items: baseline; gap: .45rem;
}
.brand b { color: var(--brand); }
.brand span { font-weight: 500; font-size: .8rem; color: #9fb3ae; letter-spacing: .04em; text-transform: uppercase; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a {
  color: #c9d6d2; text-decoration: none; padding: .4rem .7rem; border-radius: 6px; font-size: .92rem;
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.topbar nav a.on { color: #fff; box-shadow: inset 0 -2px 0 var(--brand); border-radius: 0; }
.topbar .user { font-size: .85rem; color: #9fb3ae; }
.topbar .user a { color: #c9d6d2; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.wrap.narrow { max-width: 760px; }
main { padding: 28px 0 60px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: .25rem; }
.crumb { font-size: .85rem; margin-bottom: .35rem; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--brand-dark); }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.grid-2 > * { min-width: 0; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 22px; }
.stat { padding: 14px 18px; border-left: 1px solid var(--line-soft); }
.stat:first-child { border-left: 0; }
.stat .n { font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; }
.stat .l { color: var(--muted); font-size: .82rem; }
.stat.hl .n { color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.t th {
  text-align: left; font-weight: 600; font-size: .75rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); padding: 8px 10px; border-bottom: 1.5px solid var(--line);
}
table.t td { padding: 10px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t tr.row-link { cursor: pointer; }
table.t tr.row-link:hover td { background: #faf7ef; }
table.t td.name a { color: var(--ink); font-weight: 600; text-decoration: none; }
table.t tfoot td { border-top: 1.5px solid var(--line); border-bottom: 0; font-weight: 600; }
.void td { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; vertical-align: 1px; }
.badge.pending { background: var(--warn-bg); color: var(--warn-ink); }
.badge.signed { background: var(--ok-bg); color: var(--ok-ink); }
.badge.void { background: #eee; color: #777; }
.badge.soft { background: #efece4; color: var(--ink-soft); }

/* ---------- forms ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d6cfbf;
  border-radius: 7px;
  padding: 9px 11px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85rem; line-height: 1.5; min-height: 460px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,179,149,.18); }
.field { margin-bottom: 14px; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(var(--cols, 2), 1fr); }
.row > * { min-width: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-family: var(--font-display); font-weight: 600; font-size: 1rem; padding: 0; margin-bottom: 10px; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; font-size: .92rem; color: var(--ink); }
.check input { margin-top: .25rem; accent-color: var(--brand-dark); width: 16px; height: 16px; flex: none; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 .9rem/1 var(--font-body);
  padding: 10px 16px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--brand-dark); color: #fff; }
.btn-primary:hover { background: var(--brand-darker); color: #fff; }
.btn-ghost { background: transparent; border-color: #cfc7b5; color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); background: #fff; }
.btn-danger { background: transparent; color: var(--err-ink); border-color: #e9c2b8; }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: 6px 10px; font-size: .82rem; }
.btn-lg { padding: 14px 22px; font-size: 1rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand-dark); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- flash ---------- */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; border-left: 3px solid; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--brand); }
.flash.err { background: var(--err-bg); color: var(--err-ink); border-color: #d9583a; }
.flash.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: #e3a43a; }

/* ---------- misc ---------- */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .92rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; background: #faf8f2; }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.search { max-width: 320px; }
.doc-item { display: flex; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.doc-item:first-of-type { border-top: 0; padding-top: 4px; }
.doc-item .meta { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.doc-item.is-void { opacity: .55; }
details.more summary { cursor: pointer; color: var(--brand-dark); font-size: .85rem; font-weight: 600; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { margin-bottom: 10px; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .84rem; }
.timeline li { padding: 6px 0; border-top: 1px dashed var(--line); display: flex; gap: 10px; }
.timeline li:first-child { border-top: 0; }
.timeline time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.missing { font-size: .82rem; color: var(--warn-ink); margin-top: 4px; }
.placeholder-list { columns: 2; font-size: .8rem; margin: 0; padding: 0; list-style: none; }
.placeholder-list li { break-inside: avoid; margin-bottom: 3px; }
.placeholder-list code { background: #efece4; padding: 1px 5px; border-radius: 4px; cursor: pointer; }
.seal-preview { max-height: 80px; border: 1px dashed var(--line); padding: 6px; background: #fff; border-radius: 6px; }
pre.json { background: #1b2a27; color: #d9ece6; padding: 14px; border-radius: 8px; overflow: auto; font-size: .78rem; max-height: 480px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { color: var(--ink); margin-bottom: 1.25rem; font-size: 1.4rem; }
.login-card .brand span { color: var(--muted); }

/* ================= PORTAL ================= */
.portal-top { border-bottom: 1px solid var(--line); background: var(--card); }
.portal-top .wrap { display: flex; justify-content: space-between; align-items: center; min-height: 60px; gap: 1rem; }
.portal-top .brand { color: var(--ink); }
.portal-top .brand span { color: var(--muted); }
.portal-top .who { font-size: .85rem; color: var(--muted); text-align: right; }
.hello { margin: 6px 0 22px; }
.hello h1 { font-size: 1.6rem; }
.pending-strip {
  display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--ink); color: #e6efec; border-radius: var(--radius); padding: 16px 20px; margin-bottom: 18px;
}
.pending-strip strong { color: #fff; font-family: var(--font-display); font-size: 1.05rem; }
.pending-strip .btn-primary { background: var(--brand); color: var(--ink); }
.pending-strip .btn-primary:hover { background: #2fd1b3; }
.otp-input { font-family: var(--font-display) !important; font-size: 1.8rem !important; letter-spacing: .5em; text-align: center; padding: 12px !important; }
.access-card { max-width: 440px; margin: 40px auto; }
.sign-layout { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
.sign-layout > * { min-width: 0; }
.pdf-pages { height: 78vh; min-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #e9e5da; padding: 0; }
.pdf-pages canvas { display: block; margin: 0 auto 8px; background: #fff; box-shadow: 0 1px 3px rgba(17,32,29,.15); }
.pdf-pages canvas:last-child { margin-bottom: 0; }
.pdf-loading { padding: 40px 16px; text-align: center; color: var(--muted); font-size: .9rem; }
.tabs { display: flex; border-bottom: 1px solid var(--line); margin: -4px 0 16px; }
.tabs button {
  flex: 1; background: none; border: 0; padding: 10px 6px; font: 600 .88rem var(--font-body); color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--ink); border-color: var(--brand); }
.pad-wrap { position: relative; border: 1.5px dashed #c8bfac; border-radius: 8px; background: #fff; touch-action: none; }
.pad-wrap canvas { display: block; width: 100%; height: 190px; cursor: crosshair; }
.pad-wrap .baseline { position: absolute; left: 18px; right: 18px; bottom: 44px; border-top: 1px solid #e6e0d2; pointer-events: none; }
.pad-wrap .hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: .78rem; color: #b0a891; pointer-events: none; }
.pad-tools { display: flex; justify-content: flex-end; margin-top: 6px; }
.log { background: #f2efe7; padding: 10px; border-radius: 7px; font-size: .78rem; max-height: 180px; overflow: auto; white-space: pre-wrap; margin-top: 10px; }
.done-mark { width: 54px; height: 54px; border-radius: 50%; background: var(--brand-wash); color: var(--brand-dark); display: grid; place-items: center; font-size: 1.6rem; margin-bottom: 10px; }
.foot { text-align: center; font-size: .8rem; color: var(--muted); padding: 24px 0 40px; }

@media (max-width: 860px) {
  .grid-2, .sign-layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .row { grid-template-columns: 1fr; }
  .pdf-pages { height: 62vh; min-height: 340px; }
  .topbar .wrap { flex-wrap: wrap; gap: .5rem 1rem; padding-top: 8px; padding-bottom: 8px; }
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .placeholder-list { columns: 1; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  .card { padding: 16px; }
  h1 { font-size: 1.4rem; }
}
