/* Katiwala — one stylesheet, no framework. Mobile first: most clients open
   the invitation link on a phone, from Viber. */

:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1d1f1e;
  --muted: #5d6360;
  --line: #dcdad3;
  --accent: #1f5f4a;
  --accent-text: #ffffff;
  --danger: #a2312a;
  --warn-bg: #fff4dc;
  --warn-line: #e0b54c;
  --ok-bg: #e6f2ec;
  --bad-bg: #fbe9e7;
  --radius: 8px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141615;
    --surface: #1d201f;
    --text: #e8e9e7;
    --muted: #a3aaa6;
    --line: #353a38;
    --accent: #5fb393;
    --accent-text: #0d1a14;
    --danger: #ef8a80;
    --warn-bg: #3a2f14;
    --warn-line: #a3802b;
    --ok-bg: #18302a;
    --bad-bg: #3a1d1a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 460px; }

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0.6em 0 0.4em; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.6em 0 0.6em; }
h3 { font-size: 1rem; margin: 0 0 0.4em; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; min-height: 52px; gap: 12px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: 0.02em; }
.top nav { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 0.9rem; }

.foot { color: var(--muted); font-size: 0.8rem; padding-top: 32px; padding-bottom: 32px; }
.muted { color: var(--muted); }
.meta { color: var(--muted); margin-top: 0; }
.crumbs { margin: 16px 0 0; font-size: 0.9rem; }

.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-row h1, .head-row h2 { margin-bottom: 0.4em; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
label small { font-weight: 400; color: var(--muted); }
input, textarea, select {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-weight: 600; padding: 0 4px; }
.choice { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.choice input { width: auto; }
.row-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.row-form label { flex: 1 1 240px; }
.inline { display: inline; }
.deliverable { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) {
  .deliverable { grid-template-columns: 140px 1fr 1fr; }
  .deliverable legend { grid-column: 1 / -1; }
  .deliverable input[name^="sha256"] { grid-column: 2 / -1; }
}

button, .button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 10px 16px; text-decoration: none; display: inline-block;
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 500; text-decoration: underline; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }

details { margin: 16px 0; }
summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details[open] summary { margin-bottom: 12px; }

/* Messages */
.flash, .alert, .callout, .verified, .deadline {
  border-radius: var(--radius); padding: 12px 14px; margin: 16px 0;
  border: 1px solid var(--line); background: var(--surface);
}
.flash { border-color: var(--accent); }
.alert { background: var(--bad-bg); border-color: var(--danger); }
.verified { background: var(--ok-bg); border-color: transparent; font-size: 0.9rem; }
.deadline { background: var(--surface); }
.deadline.urgent { background: var(--warn-bg); border-color: var(--warn-line); }
.deadline p, .callout p { margin: 0.3em 0; }
.field-error { color: var(--danger); margin: 0; font-size: 0.9rem; }
.verdict.bad { border-color: var(--danger); background: var(--bad-bg); }
.urgent-text { font-weight: 600; }

/* Lists */
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card p { margin: 4px 0 0; }
.card.urgent { border-color: var(--warn-line); background: var(--warn-bg); }
.plain { list-style: none; padding: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.criteria li { margin: 6px 0; }
.deliverables { list-style: none; padding: 0; }
.deliverables li { margin: 6px 0; word-break: break-word; }
.verdicts { list-style: none; padding: 0; }
.verdicts li { padding: 4px 0; }
.verdicts .fail { color: var(--danger); }
.submission { border-top: 1px solid var(--line); padding: 14px 0; }
.note { white-space: pre-wrap; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.list th, .list td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.num { white-space: nowrap; }
@media (max-width: 560px) {
  .list thead { display: none; }
  .list tr { display: block; border-bottom: 1px solid var(--line); padding: 6px 0; }
  .list td { display: block; border: none; padding: 2px 10px; }
}

.badge, .pill {
  display: inline-block; font-size: 0.78rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap;
}
.pill.on { background: var(--ok-bg); }
.s-ACTIVE, .s-ACCEPTED, .s-AUTO_ACCEPTED { background: var(--ok-bg); }
.s-IN_REVIEW, .s-PENDING_ACTIVATION { background: var(--warn-bg); border-color: var(--warn-line); }
.s-REVISION_REQUESTED, .s-REJECTED, .s-CANCELLED, .s-TERMINATED { background: var(--bad-bg); }
/* Change requests: prefixed, since ACCEPTED means something different here. */
.s-CR-PROPOSED { background: var(--warn-bg); border-color: var(--warn-line); }
.s-CR-ACCEPTED { background: var(--ok-bg); }
.s-CR-DECLINED, .s-CR-WITHDRAWN { color: var(--muted); }

.copy { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; word-break: break-all; }
