/* Sentinel Scout · pilot app. Palette from Yuya's v0.3 concept (cream, forest green, brick red, warm yellow). */
:root {
  --cream: #f5eedb; --surface: #fffaf0; --bg: #eee5d0; --pale: #e7ecdb;
  --red: #a43d32; --yellow: #e5bf4c; --forest-deep: #203d2e; --forest: #31543e;
  --ink: #30382c; --muted: #5b614c; --line: #ded7bf; --focus: #b24736;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 'Segoe UI', system-ui, -apple-system, Arial, sans-serif; }
a { color: var(--forest); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

.site { max-width: 1240px; margin: 0 auto; min-height: 100vh; background: var(--cream); border-top: 5px solid var(--red); box-shadow: 0 0 60px #2b35210b; }
.brandbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 40px; background: var(--surface); border-bottom: 1px solid #d7cfb3; }
.logo { width: 200px; height: auto; display: block; }
.brand-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.company { font-size: 12px; letter-spacing: 1.2px; color: var(--muted); }
.company strong { display: block; color: var(--forest-deep); font-size: 14px; }
.session-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; }
.whoami { color: var(--forest-deep); font-weight: 600; }
.link-button { background: none; border: 0; padding: 6px 2px; min-height: 36px; color: var(--forest); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

.tabs { display: flex; gap: 26px; padding: 0 40px; background: #f0e8d1; border-bottom: 1px solid #d5ceb0; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 14px 2px 11px; min-height: 50px; font: 600 14px 'Segoe UI', system-ui, Arial, sans-serif; color: #5e694d; cursor: pointer; white-space: nowrap; }
.tabs button[aria-current="page"] { color: var(--forest-deep); border-bottom-color: var(--red); }
.badge { font-size: 11px; background: #f3e4ac; color: var(--forest-deep); padding: 1px 7px; border-radius: 10px; margin-left: 2px; }

.data-status { padding: 9px 40px; font-size: 13px; background: #e9edda; color: #455b3d; border-bottom: 1px solid #d1d6bb; }
.data-status.warn { background: #f7ebc7; color: #69542a; border-bottom-color: #e6d49a; }

main { padding: 26px 40px 40px; outline: none; }
.screen-head { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; margin-bottom: 16px; }
h1 { font-family: Georgia, 'Times New Roman', serif; font-weight: 500; font-size: 28px; color: var(--forest-deep); margin: 0; }
.count { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Auth card */
.auth-card { max-width: 520px; margin: 40px auto; padding: 30px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--yellow); border-radius: 6px; }
.auth-card h1 { font-size: 26px; margin-bottom: 10px; }
.alert { background: #f8e0dc; color: #7a2a20; border-left: 3px solid var(--red); padding: 10px 12px; border-radius: 4px; }

/* Forms */
.field label { display: block; font-size: 12px; font-weight: 650; color: #4d5d43; margin-bottom: 4px; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); width: 100%; border: 1px solid #c5c5a9; border-radius: 4px; background: var(--surface); padding: 8px 10px; min-height: 42px; }
textarea { resize: vertical; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--forest); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; margin-bottom: 20px; }
.filters .search-field { grid-column: span 2; }
.filters .check { grid-column: span 3; }
.filters-small { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.form-grid .wide { grid-column: 1 / -1; }
.form-msg { font-size: 13px; color: #7a2a20; min-height: 1em; margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 14px; border-radius: 4px; border: 1px solid var(--forest); font: 600 13px 'Segoe UI', system-ui, Arial, sans-serif; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--forest); color: #fffaf0; }
.btn.ghost { background: var(--surface); color: var(--forest); border-color: #a5b08a; }
.btn:disabled { background: #e9e8d9; color: #6a705a; border-color: #d3d2b9; cursor: not-allowed; }
.btn:hover:enabled { filter: brightness(.94); }

/* Cards */
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid #d7d2b7; border-radius: 6px; padding: 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.market { font-size: 10px; letter-spacing: 1px; font-weight: 700; color: #385436; background: #e9edda; border: 1px solid #ced6b8; padding: 4px 7px; border-radius: 3px; }
.card-title { font-size: 16px; line-height: 1.4; color: var(--forest-deep); margin: 4px 0 0; overflow-wrap: anywhere; }
.card-meta { font-size: 12px; color: var(--muted); margin: 0; }
.card-summary { font-size: 13px; color: #4f5944; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-facts { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12px; color: var(--ink); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; align-items: center; }

/* Chips: urgency and relevance are always separate */
.chip { display: inline-block; font-size: 11px; line-height: 1.4; padding: 2px 8px; border-radius: 10px; background: #edf0df; color: #3f5236; border: 1px solid transparent; }
.chip-sub { font-weight: 400; }
.u-urgent { background: #f6d9d3; color: #7a2a20; border-color: #e7b3a9; font-weight: 650; }
.u-soon { background: #f7e6af; color: #6b4d12; border-color: #ead18e; }
.u-later { background: #e2ebd6; color: #2f4a2c; }
.u-unconfirmed { background: #ecebe3; color: #4f5244; border-style: dashed; border-color: #b9b8a6; }
.u-expired { background: #e6e3da; color: #5a5a50; }
.rel { background: #e8ecf2; color: #2f3f55; }
.cat { background: #f1ecd9; color: #5b5233; }
.c-other { background: #ece8f0; color: #4a3f5b; }
.c-unclassified { background: #f0f0ea; color: #4f5244; border: 1px dashed #b9b8a6; }
.notice-closed { background: #e6e3da; color: #5a5a50; margin: 0 4px; }
.tracked, .status { background: #dfe9dc; color: #24442c; font-weight: 600; }
.s-closed { background: #e6e3da; color: #4f5244; }

.state { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed #b9c09c; border-radius: 5px; grid-column: 1 / -1; }
.state.error { border-color: #d7a49b; color: #7a2a20; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 18px; }

/* Facts list (detail and follow-up) */
.facts { margin: 0; }
.facts > div { display: grid; grid-template-columns: 170px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid #e8e0ca; font-size: 13px; }
.facts dt { font-weight: 650; color: #3c553d; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts.compact > div { grid-template-columns: 110px 1fr; padding: 5px 0; font-size: 12px; }
.detail section h3, .notes h3, .follow-form h3 { font-size: 15px; color: var(--forest-deep); margin: 18px 0 6px; }
.detail-sub { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; margin: 0 0 10px; }
.links { padding-left: 18px; margin: 0; }
.links li { margin: 4px 0; overflow-wrap: anywhere; }
.warning { background: #f7ebc7; color: #69542a; border-left: 3px solid var(--yellow); font-size: 12px; padding: 10px 12px; border-radius: 4px; margin: 16px 0; }

/* Notes and history */
.note-list { list-style: none; padding: 0; margin: 0; }
.note { border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface); }
.note.is-hidden { background: #f2efe6; border-style: dashed; }
.note-head { font-size: 12px; color: var(--muted); }
.note-head strong { color: var(--ink); }
.note-body { margin: 6px 0; font-size: 14px; }
.note-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.note-actions input { max-width: 320px; }
.note-add { display: grid; gap: 8px; margin-top: 10px; }
.note-add .btn { justify-self: start; }
.revisions { font-size: 12px; margin-top: 6px; }
.revisions summary, .history summary { cursor: pointer; font-weight: 650; color: var(--forest-deep); min-height: 32px; }
.history { margin-top: 18px; border: 1px solid var(--line); border-radius: 5px; padding: 10px 14px; background: var(--surface); font-size: 13px; }
.history ul { padding-left: 18px; }
.history li { margin: 6px 0; }

/* Share */
.share-layout { display: grid; grid-template-columns: 1fr 1.3fr; gap: 24px; align-items: start; }
.share-form { display: grid; gap: 14px; }
.brief-box { border: 1px solid #d8d0b3; border-radius: 6px; background: var(--surface); overflow: hidden; }
.brief-label { font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; color: #5e624b; background: #ece4cc; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.brief-text { margin: 0; padding: 16px; font: 13px/1.6 'Segoe UI', system-ui, Arial, sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 160px; }
.brief-fallback { min-height: 200px; border: 0; border-top: 1px solid var(--line); border-radius: 0; }

/* Dialog */
.dialog { width: min(760px, calc(100% - 24px)); max-height: 92vh; overflow: auto; border: 1px solid #c7c9aa; border-radius: 8px; padding: 22px; color: var(--ink); background: var(--cream); }
.dialog::backdrop { background: #14271ab3; }
.dialog-top { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 12px; position: sticky; top: -22px; background: var(--cream); padding-top: 4px; }
.dialog-top h2 { font-size: 19px; color: var(--forest-deep); margin: 0; overflow-wrap: anywhere; }
.close-dialog { font: 24px/1 Arial, sans-serif; border: 0; background: #ecebd8; color: var(--forest-deep); width: 40px; height: 40px; border-radius: 50%; cursor: pointer; flex-shrink: 0; }

.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--forest-deep); color: #fffaf0; padding: 10px 16px; border-radius: 6px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 24px); z-index: 20; }
.toast.show { opacity: 1; }

@media (max-width: 900px) {
  .brandbar, main { padding-left: 24px; padding-right: 24px; }
  .tabs, .data-status { padding-left: 24px; padding-right: 24px; }
  .filters, .filters-small { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .check { grid-column: 1 / -1; }
  .card-grid, .share-layout { grid-template-columns: 1fr; }
}
@media (max-width: 580px) {
  body { font-size: 15px; }
  .brandbar { padding: 10px 16px; gap: 10px; }
  .logo { width: 140px; }
  .company { display: none; }
  .tabs { padding: 0 16px; gap: 18px; }
  .data-status { padding: 8px 16px; font-size: 12px; }
  main { padding: 18px 16px 30px; }
  h1 { font-size: 23px; }
  .filters, .filters-small { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .filters .search-field, .filters .check, #clearFilters { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }   /* iOS Safari zooms into fields under 16px */
  .btn { min-height: 44px; }
  .card { padding: 14px; }
  .card-actions .btn { flex: 1 1 auto; }
  .facts > div { grid-template-columns: 1fr; gap: 2px; }
  .dialog { padding: 16px; width: calc(100% - 12px); max-height: 96vh; }
  .dialog-top { top: -16px; }
  .auth-card { margin: 20px auto; padding: 22px; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
