/* TaskOak staff website. Brand: navy #062B55 primary, teal #00DEBC accent (docs/design/brand_colours_teal.md).
   Teal is only ever a fill with navy on it, or text on navy; never text on white. Success uses #047857 with a word. */
:root {
  --navy: #062B55;
  --navy-deep: #0B4F6C;
  --teal: #00DEBC;
  --teal-tint: #E6FBF6;
  --teal-tint-border: #B3F0E4;
  --muted-on-navy: #D3E1EE;
  --background: #F8FAFC;
  --card: #FFFFFF;
  --text: #1F2937;
  --text-secondary: #4B5563;
  --border: #E5E7EB;
  --outline: #6B7280;
  --success-text: #047857;
  --success-tint: #ECFDF5;
  --warning-text: #B45309;
  --warning-tint: #FFFBEB;
  --danger: #B91C1C;
  --danger-tint: #FEF2F2;
  --disabled-fill: #E2E8F0;
  --disabled-text: #475569;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
}
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .25rem; color: var(--navy); }
h2 { font-size: 1.2rem; margin: 0; color: var(--navy); }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; color: var(--navy); }
h4 { font-size: 1rem; margin: 1rem 0 .4rem; }
h1:focus { outline: none; }
a { color: var(--navy); text-decoration: underline; text-underline-offset: 2px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: #F1F5F9; padding: .05em .3em; border-radius: 4px; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.muted { color: var(--text-secondary); }
.block { display: block; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--teal); color: var(--navy); padding: .6rem 1rem; z-index: 10; font-weight: 600; }
.skip-link:focus { left: 1rem; }

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem;
  padding: .75rem 1.25rem;
  background: linear-gradient(135deg, var(--navy), var(--navy-deep));
  color: #fff;
}
.topbar :focus-visible { outline-color: var(--teal); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.15rem; }
.brand-mark { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--teal); color: var(--navy); font-weight: 800; }
.who { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.who-email { color: var(--muted-on-navy); overflow-wrap: anywhere; }
.role-badge { background: var(--teal); color: var(--navy); font-weight: 700; padding: .2rem .7rem; border-radius: 999px; }
.env { display: inline-block; font-size: .85rem; font-weight: 700; padding: .2rem .6rem; border-radius: 6px; }
.env-dev { background: var(--warning-tint); color: var(--warning-text); border: 1px solid var(--warning-text); }
.env-prod { background: var(--danger-tint); color: var(--danger); border: 1px solid var(--danger); }
.offline-banner { margin: 0; padding: .6rem 1.25rem; background: var(--warning-tint); color: var(--warning-text); font-weight: 600; border-bottom: 1px solid var(--warning-text); }

/* Layout: menu on the left on a laptop, a scrolling row on a tablet held upright */
.layout { display: grid; grid-template-columns: 15rem 1fr; min-height: calc(100vh - 4rem); }
.menu { background: var(--card); border-right: 1px solid var(--border); padding: 1rem .75rem; }
.menu ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.menu a { display: flex; align-items: center; min-height: 44px; padding: .5rem .85rem; border-radius: 8px; text-decoration: none; color: var(--navy); font-weight: 600; }
.menu a:hover { background: var(--teal-tint); }
.menu a[aria-current="page"] { background: var(--teal); color: var(--navy); }
.content { padding: 1.5rem; max-width: 72rem; width: 100%; }
.content:focus { outline: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu { border-right: 0; border-bottom: 1px solid var(--border); padding: .5rem; overflow-x: auto; }
  .menu ul { flex-direction: row; }
  .menu a { white-space: nowrap; }
  .content { padding: 1rem; }
  .who { margin-left: 0; }
}

/* Cards, lists and details */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.intro { margin: 0; color: var(--text-secondary); max-width: 48rem; }
.list { display: flex; flex-direction: column; gap: 1rem; }
.list > div > .card + .card, .list > div > .card, .list .card { margin-bottom: 1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: 0 1px 2px rgba(6, 43, 85, .06); }
.card.done { opacity: .7; border-style: dashed; }
.card.done .actions button { display: none; }
.card-header { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card-header h2, .card-header h3 { margin: 0 .25rem 0 0; }
.narrow { max-width: 26rem; width: 100%; }
.centered { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 .75rem; }
.details dt { color: var(--text-secondary); font-weight: 600; }
.details dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .details { grid-template-columns: 1fr; } .details dd { margin-bottom: .4rem; } }
.section-title { margin: 1.5rem 0 .75rem; }
.count { color: var(--text-secondary); margin: 0 0 .75rem; }
.user-text { white-space: pre-wrap; overflow-wrap: anywhere; }
blockquote.user-text { margin: .5rem 0 .75rem; padding: .75rem 1rem; background: var(--background); border-left: 4px solid var(--navy); border-radius: 0 8px 8px 0; }
pre.json { background: var(--background); padding: .75rem; border-radius: 8px; overflow-x: auto; font-size: .9rem; }
.notice { background: var(--teal-tint); border: 1px solid var(--teal-tint-border); color: var(--navy); padding: .6rem .85rem; border-radius: 8px; }
.hint { color: var(--text-secondary); font-size: .92rem; margin: .4rem 0; }
.services { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .25rem; }
.services li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem .6rem; background: var(--background); border-radius: 6px; }
.price { font-weight: 600; white-space: nowrap; }

/* Identity documents */
.documents { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin-bottom: .75rem; }
.document { margin: 0; border: 1px solid var(--border); border-radius: 8px; padding: .5rem; background: var(--background); }
.document img { display: block; width: 100%; max-height: 22rem; object-fit: contain; background: #fff; border-radius: 6px; }
.document figcaption { margin-top: .4rem; font-weight: 600; }
.document-missing { display: grid; place-items: center; min-height: 8rem; color: var(--warning-text); font-weight: 600; }
.document-error { color: var(--warning-text); }

/* Conversations */
.transcript { list-style: none; padding: 0; margin: 0 0 .75rem; display: flex; flex-direction: column; gap: .5rem; }
.message { padding: .5rem .75rem; border-radius: 8px; background: var(--background); border: 1px solid var(--border); max-width: 46rem; }
.message.from-reporter { background: var(--teal-tint); border-color: var(--teal-tint-border); }
.message p { margin: 0; }
.message-meta { font-size: .85rem; color: var(--text-secondary); margin-bottom: .2rem !important; }
.attachments li { margin-bottom: .75rem; }
.attachment-view img { display: block; max-width: 100%; max-height: 28rem; margin-top: .5rem; border: 1px solid var(--border); border-radius: 6px; }

/* Badges */
.badge { display: inline-block; font-size: .82rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; border: 1px solid currentColor; }
.badge-neutral { color: var(--text-secondary); background: #F1F5F9; }
.badge-success { color: var(--success-text); background: var(--success-tint); }
.badge-warning { color: var(--warning-text); background: var(--warning-tint); }
.badge-danger { color: var(--danger); background: var(--danger-tint); }

/* Buttons and forms: at least 44px tall for touch */
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .75rem; }
.button {
  min-height: 44px; padding: .55rem 1.1rem; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer;
  border: 2px solid transparent;
}
.button.primary { background: var(--navy); color: #fff; }
.button.primary:hover { background: var(--navy-deep); }
.button.secondary { background: #fff; color: var(--navy); border-color: var(--navy); }
.button.secondary:hover { background: var(--teal-tint); }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:hover { background: #991B1B; }
.button.on-dark { background: transparent; color: #fff; border-color: var(--muted-on-navy); }
.button.on-dark:hover { background: rgba(255, 255, 255, .12); }
.button:disabled, .button:disabled:hover { background: var(--disabled-fill); color: var(--disabled-text); border-color: var(--disabled-fill); cursor: not-allowed; }
.button.wide { width: 100%; margin-top: .5rem; }
.link-button { background: none; border: 0; color: var(--navy); text-decoration: underline; font: inherit; cursor: pointer; min-height: 44px; padding: 0; margin-top: .5rem; }
.or { text-align: center; color: var(--text-secondary); margin: .5rem 0 0; }
.form-field { display: flex; flex-direction: column; gap: .3rem; margin: .75rem 0; }
.form-field label { font-weight: 600; }
.form-field.grow { flex: 1 1 14rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: #fff; min-height: 44px; padding: .5rem .7rem;
  border: 1px solid var(--outline); border-radius: 8px; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--navy); outline: 2px solid var(--navy); outline-offset: 0; }
textarea { resize: vertical; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 1rem; margin-bottom: 1rem; }
.inline-form .form-field { margin: .5rem 0; }
.inline-form .button { margin: .5rem 0; }
.tools summary { cursor: pointer; font-weight: 700; color: var(--navy); min-height: 32px; }
.tools { margin-bottom: 1rem; }
.field-error { color: var(--danger); font-weight: 600; margin: 0; min-height: 0; }
.field-error:empty { display: none; }
.counter { font-size: .85rem; color: var(--text-secondary); align-self: flex-end; }
.load-more { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }

/* Status lines and page states */
.status { margin: .6rem 0 0; font-weight: 600; }
.status:empty { display: none; }
.status-working { color: var(--text-secondary); }
.status-success { color: var(--success-text); }
.status-success::before { content: "\2713  "; }
.status-error { color: var(--danger); }
.state { padding: 1.25rem; text-align: center; color: var(--text-secondary); }
.state-title { font-weight: 700; color: var(--text); margin: 0 0 .25rem; }
.state-empty, .state-error { background: var(--card); border: 1px dashed var(--outline); border-radius: var(--radius); }
.state-error { border-color: var(--danger); }
.state-error .state-title { color: var(--danger); }
.state-slow { display: block; margin-top: .4rem; }
.spinner { display: inline-block; width: 1rem; height: 1rem; margin-right: .5rem; vertical-align: -2px; border: 3px solid var(--teal-tint-border); border-top-color: var(--navy); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Confirmation dialog */
dialog { border: 0; border-radius: 12px; padding: 1.25rem 1.5rem; max-width: 32rem; width: calc(100% - 2rem); box-shadow: 0 10px 40px rgba(6, 43, 85, .3); color: var(--text); }
dialog::backdrop { background: rgba(6, 43, 85, .55); }
dialog h2 { margin-bottom: .5rem; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }

/* Numbers table */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
table.kpi { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.kpi caption { text-align: left; padding: .75rem 1rem; color: var(--text-secondary); }
table.kpi th, table.kpi td { padding: .5rem .75rem; border-top: 1px solid var(--border); text-align: right; white-space: nowrap; }
table.kpi th[scope="row"] { text-align: left; white-space: normal; min-width: 14rem; position: sticky; left: 0; background: var(--card); color: var(--navy); }
table.kpi thead th { background: var(--navy); color: #fff; }
table.kpi thead th:first-child { text-align: left; position: sticky; left: 0; }
table.kpi thead .muted { color: var(--muted-on-navy); font-weight: 400; font-size: .85rem; }
