/* SAOFAL Portal. Brand: paper #fcfcfc, slate #0f172a, transition orange rgb(249, 115, 22);
   Outfit for headings and figures, Manrope for reading. Orange is a fill, never small text:
   slate on orange passes contrast, orange on paper does not. */
:root {
  --paper: #fcfcfc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --wash: #f1f5f9;
  --card: #ffffff;
  --orange: rgb(249, 115, 22);
  --orange-wash: #fff4ea;
  --good: #166534;
  --good-wash: #ecfdf3;
  --warn: #9a3412;
  --bad: #b91c1c;
  --bad-wash: #fef2f2;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --r-pill: 999px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.05);
  --shadow-up: 0 8px 24px rgba(15, 23, 42, 0.10);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --head: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --body: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.55 var(--body); }
h1, h2, h3 { font-family: var(--head); line-height: 1.2; margin: 0 0 0.6rem; letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; margin-top: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--ink); text-decoration-color: var(--orange); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
b { font-weight: 700; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: var(--r-sm); z-index: 10; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Frame */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; min-height: 32px; }
.brand img { display: block; height: 23px; width: auto; }
.who { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.who-name { font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; min-height: 32px; }
.who form { margin: 0; }
.nav { position: sticky; top: 0; z-index: 5; background: rgba(252, 252, 252, 0.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.nav ul { display: flex; gap: 4px; margin: 0 auto; padding: 8px 16px; list-style: none; max-width: 1180px; overflow-x: auto; scrollbar-width: none; }
.nav ul::-webkit-scrollbar { display: none; }
.nav a { display: block; padding: 8px 12px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600; text-decoration: none; color: var(--ink-2); white-space: nowrap; transition: background 0.2s var(--ease), color 0.2s var(--ease); }
.nav a:hover { background: var(--wash); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }

/* Blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.narrow { max-width: 460px; margin: 6vh auto 18px; }
.narrow-left { max-width: 520px; }
.card.highlight { border-color: var(--orange); background: var(--orange-wash); }
.card.highlight .muted { color: var(--ink-2); }
.card.announce h2 { margin-top: 4px; }
.badge { display: inline-block; min-width: 20px; margin-left: 4px; padding: 1px 6px; border-radius: var(--r-pill); background: var(--orange); color: var(--ink); font-size: 12px; font-weight: 800; line-height: 18px; text-align: center; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.grid-2 > .card, .grid-2 > div > .card { margin-bottom: 18px; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row > label { flex: 1 1 180px; }
.row.inline { align-items: center; gap: 8px; margin: 6px 0; }
.row.inline > label { flex: 1 1 140px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.row-between.wrap { flex-wrap: wrap; margin-bottom: 8px; }
.row-end { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.stack { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stack-sm:last-child { border-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.warn { color: var(--warn); font-weight: 600; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.big { display: block; font: 800 28px/1.1 var(--head); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.greet { font-size: 36px; margin-bottom: 4px; }
.note { background: var(--orange-wash); border-left: 4px solid var(--orange); padding: 10px 14px; border-radius: var(--r-sm); }
.flash { background: var(--good-wash); color: var(--good); border-radius: var(--r); padding: 10px 14px; font-weight: 600; animation: arrive 0.5s var(--ease) both; }
.error { background: var(--bad-wash); color: var(--bad); border-radius: var(--r); padding: 10px 14px; font-weight: 600; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 4px 0; }
.list { list-style: none; padding: 0; margin: 0 0 12px; }
.timeline { list-style: none; margin: 16px 0 0; padding: 0; }
.timeline > li + li { margin-top: 16px; }
.tl { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 2px solid var(--line); }
.tl > li { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); gap: 8px; padding: 8px 0; }
.tl > li + li { border-top: 1px solid var(--line); }
.tl .pre { margin: 4px 0; }
.tl-time { color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.list-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row form { margin: 0; }

/* Forms */
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 44px; }
input, select, textarea { font: 400 16px/1.4 var(--body); color: var(--ink); background: var(--card); border: 1px solid #cbd5e1; border-radius: var(--r); padding: 10px 12px; width: 100%; min-height: 44px; }
input[type="checkbox"], input[type="radio"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--orange); margin: 0; flex-shrink: 0; }
input[readonly] { background: var(--wash); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 3px solid rgba(249, 115, 22, 0.35); outline-offset: 0; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font: 600 16px/1.3 var(--head); padding: 0; margin-bottom: 6px; }
.area { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; display: grid; gap: 10px; }
details > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
details > summary h2 { display: inline; }
details.card > summary { list-style: none; }
details.card > summary::after { content: "+"; float: right; font: 600 18px var(--head); color: var(--muted); }
details.card[open] > summary::after { content: "\2212"; }
.pin-login { margin: 14px 0; border-top: 1px solid var(--line); padding-top: 10px; }
.pin-login form { margin-top: 10px; }
.filters label { flex: 0 1 220px; }
.copy-row { display: flex; gap: 8px; }

/* Buttons */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: var(--r-pill); border: 1px solid transparent; font: 700 15px/1 var(--body); text-decoration: none; cursor: pointer; transition: transform 0.15s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.primary { background: var(--orange); color: var(--ink); }
.primary:hover { box-shadow: var(--shadow-up); }
.secondary { background: var(--card); color: var(--ink); border-color: var(--ink); }
.secondary:hover { background: var(--wash); }
.link { background: none; border: 0; padding: 4px 0; min-height: 32px; color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--orange); text-underline-offset: 3px; }
.link.danger { color: var(--bad); text-decoration-color: currentColor; }
.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 8px; }
.is-busy { position: relative; color: transparent; }
.is-busy::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid var(--ink); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }

/* Status */
.pill { display: inline-block; padding: 4px 10px; border-radius: var(--r-pill); font-size: 13px; font-weight: 700; background: var(--wash); color: var(--ink-2); white-space: nowrap; }
.pill-in, .pill-approved { background: var(--good-wash); color: var(--good); }
.pill-break, .pill-pending { background: var(--orange-wash); color: var(--warn); }
.pill-out, .pill-cancelled { background: var(--wash); color: var(--muted); }
.pill-rejected { background: var(--bad-wash); color: var(--bad); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 700; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.total td { font-weight: 700; border-bottom: 0; }
.table tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--orange); padding-left: 8px; }
.table tr.inactive { opacity: 0.55; }
.card > .table, .card .table { display: table; }
@media (max-width: 640px) { .card { overflow-x: auto; } }

/* Today: the day as a bar that fills from morning to now */
.clock-figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 10px 0 16px; }
.daybar { margin: 8px 0 4px; }
.daybar-track { position: relative; height: 14px; background: var(--wash); border-radius: var(--r-pill); overflow: hidden; }
.seg { position: absolute; top: 0; bottom: 0; border-radius: var(--r-pill); transform-origin: left center; animation: fill-in 0.7s var(--ease) both; animation-delay: calc(var(--i) * 0.12s); }
.seg-work { background: var(--ink); }
.seg-break { background: var(--orange); }
.daybar-scale { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 4px; }

/* Insights */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); animation: arrive 0.6s var(--ease) both; }
.stat:nth-child(2) { animation-delay: 0.06s; }
.stat:nth-child(3) { animation-delay: 0.12s; }
.stat:nth-child(4) { animation-delay: 0.18s; }
.stat-warn { border-color: var(--orange); background: var(--orange-wash); }
.notes { border-left: 4px solid var(--orange); }
.notes ul { margin: 0; padding-left: 20px; }
.notes li { margin-bottom: 6px; }
.meter { display: inline-block; width: 90px; height: 8px; background: var(--wash); border-radius: var(--r-pill); overflow: hidden; vertical-align: middle; margin-right: 6px; }
.target .meter { display: block; width: 100%; margin: 8px 0 0; }
.meter-fill { display: block; height: 100%; width: var(--w); border-radius: var(--r-pill); transform-origin: left center; animation: fill-in 0.9s var(--ease) both; }
.fill-self { background: var(--orange); }
.fill-lead, .fill-good { background: var(--ink); }
.fill-warn { background: var(--orange); }
.chart { margin: 0 0 12px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font: 600 12px var(--body); fill: var(--muted); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.line-self, .line-lead { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: draw 1.2s var(--ease) forwards; }
.line-self { stroke: var(--orange); }
.line-lead { stroke: var(--ink); animation-delay: 0.25s; }
.dot-self { fill: var(--orange); }
.dot-lead { fill: var(--ink); }
figcaption { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 14px; height: 4px; border-radius: var(--r-pill); margin-left: 8px; }
.key-self { background: var(--orange); }
.key-lead { background: var(--ink); }

/* Weekly check-in */
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.levels-compact { grid-template-columns: repeat(4, 64px); }
.level { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); font-weight: 500; font-size: 14px; cursor: pointer; transition: border-color 0.2s var(--ease), background 0.2s var(--ease); }
.level:has(input:checked) { border-color: var(--ink); background: var(--orange-wash); }
.level input { margin-top: 2px; }
.level-n { font: 800 16px/1.2 var(--head); }
.swot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.swot-cell { padding: 12px; border-radius: var(--r); background: var(--wash); }
.swot-strengths { background: var(--good-wash); }
.swot-threats { background: var(--bad-wash); }
.swot-opportunities { background: var(--orange-wash); }
@media (max-width: 560px) { .swot { grid-template-columns: 1fr; } }

/* Sales */
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 10px; margin-bottom: 18px; }
.stage-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; text-decoration: none; box-shadow: var(--shadow); transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease); }
.stage-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-up); }
.stage-won { border-top: 4px solid var(--good); }
.stage-proposal { border-top: 4px solid var(--orange); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs a { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; border-radius: var(--r-pill); border: 1px solid var(--line); font-size: 14px; font-weight: 600; text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

@keyframes arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fill-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .main { padding: 16px 16px 48px; }
  .top { padding: 12px 16px; }
  .greet { font-size: 28px; }
  h1 { font-size: 22px; }
  .big { font-size: 22px; }
  .nav { position: static; }
  .nav ul { flex-wrap: wrap; }
  .who-name { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row-end { flex-direction: column; align-items: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
  .line-self, .line-lead { stroke-dashoffset: 0; }
}
