:root {
  color-scheme: light;
  --ink: #14202b;
  --muted: #5d6b78;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --line: #d9e0e6;
  --brand: #17324d;
  --accent: #d88c28;
  --danger: #a42424;
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); min-height: 100vh; }
button, input, select, textarea { min-width: 0; font: inherit; font-size: 1rem; }
button, .file-button { min-height: 46px; border-radius: 12px; cursor: pointer; font-weight: 700; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #75a9d4; outline-offset: 2px; }
.app-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: max(16px, env(safe-area-inset-top)) 18px 15px; color: white; background: linear-gradient(135deg, #10293f, #254d6f); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 1.35rem; margin-bottom: 0; }
h2 { font-size: 1.4rem; margin-bottom: 0; }
h3 { font-size: 1.05rem; }
.eyebrow { margin-bottom: 4px; color: var(--muted); font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.app-header .eyebrow { color: #c6d8e8; }
.storage-status { padding: 7px 9px; border: 1px solid #7794ac; border-radius: 999px; font-size: .72rem; white-space: nowrap; }
.tab-bar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-bottom: 1px solid var(--line); }
.tab { min-height: 52px; border: 0; border-radius: 0; background: transparent; color: var(--muted); }
.tab.active { color: var(--brand); box-shadow: inset 0 -4px var(--accent); }
main { max-width: 920px; margin: 0 auto; padding: 20px 14px calc(110px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.active { display: block; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.section-heading > div:first-child, .card-top > div { min-width: 0; }
.heading-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.compact { min-height: 44px; padding: 8px 12px; white-space: nowrap; }
.count-badge { padding: 7px 11px; border-radius: 999px; background: #e3ebf1; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.filters label:last-child { grid-column: 1 / -1; }
label { display: block; color: #34424e; font-weight: 700; }
input, select, textarea { width: 100%; margin-top: 6px; padding: 12px; color: var(--ink); background: white; border: 1px solid #b8c2ca; border-radius: 10px; }
textarea { resize: vertical; line-height: 1.55; }
small { display: block; margin-top: 5px; color: var(--muted); font-weight: 400; }
.card-list { display: grid; gap: 12px; }
.opportunity-card { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid #758594; border-radius: var(--radius); box-shadow: 0 3px 13px rgba(19, 42, 61, .06); }
.opportunity-card[data-verdict="A"] { border-left-color: #167047; }
.opportunity-card[data-verdict="B"] { border-left-color: #9b6b00; }
.opportunity-card[data-verdict="C"] { border-left-color: #a44d17; }
.opportunity-card[data-verdict="D"] { border-left-color: var(--danger); background: #fff8f8; }
.card-top, .card-meta, .card-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; min-width: 0; }
.card-title { margin: 3px 0 12px; font-size: 1.08rem; overflow-wrap: anywhere; }
.verdict-badge { flex: 0 0 auto; padding: 7px 9px; border-radius: 10px; background: #e8edf1; font-weight: 900; }
[data-verdict="D"] .verdict-badge { color: #fff; background: var(--danger); }
.card-meta { flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.card-actions { align-items: end; margin-top: 14px; }
.card-actions select { max-width: 150px; margin: 0; padding: 9px; }
.link-button { border: 0; background: transparent; color: #145d91; text-decoration: underline; }
.empty-state { padding: 38px 22px; text-align: center; background: white; border: 1px dashed #a8b3bc; border-radius: var(--radius); }
.field { margin-bottom: 16px; }
.prominent label { font-size: 1.02rem; }
.form-grid { display: grid; gap: 0 14px; }
.advanced-fields { margin: 8px 0 18px; padding: 0 14px; background: #e9eef2; border: 1px solid #c8d2da; border-radius: 14px; }
.advanced-fields summary { min-height: 52px; padding: 15px 2px; color: var(--brand); font-weight: 800; cursor: pointer; }
.advanced-fields[open] summary { margin-bottom: 8px; border-bottom: 1px solid #c8d2da; }
.details-grid { padding-top: 4px; }
.privacy-note, .caution { padding: 13px; border-radius: 12px; background: #fff5d9; line-height: 1.5; }
.sticky-actions { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; justify-content: flex-end; gap: 9px; padding: 10px; background: rgba(243, 246, 248, .96); border: 1px solid rgba(217, 224, 230, .9); border-radius: 14px; backdrop-filter: blur(8px); }
.sticky-actions .primary { flex: 1 1 auto; }
.primary, .secondary, .danger-button, .file-button { padding: 11px 16px; border: 1px solid transparent; }
.primary { color: white; background: var(--brand); }
.secondary { color: var(--brand); background: white; border-color: #8ca0b0; }
.danger-button { color: white; background: var(--danger); }
.info-panel { padding: 18px; background: white; border: 1px solid var(--line); border-radius: var(--radius); line-height: 1.6; }
.backup-actions { display: grid; gap: 12px; margin: 18px 0; }
.file-button { display: flex; align-items: center; justify-content: center; color: var(--brand); background: white; border-color: #8ca0b0; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.message { margin: 14px 0; padding: 12px; border-radius: 10px; background: #e6f3eb; overflow-wrap: anywhere; }
.message.error { color: #7d1717; background: #fde8e8; }
.app-error { max-width: 920px; margin: 12px auto; }
dialog { width: min(760px, calc(100% - 20px)); max-height: calc(100vh - 24px); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 18px 60px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(7, 18, 28, .65); }
.dialog-header { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 12px; padding: 18px; background: white; border-bottom: 1px solid var(--line); }
.icon-button { width: 46px; padding: 0; border: 0; background: #edf1f4; font-size: 1.7rem; }
#detail-content { padding: 18px; }
.detail-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.detail-value { padding: 13px; background: #edf2f5; border-radius: 12px; }
.reason-group { margin: 18px 0; }
.reason-group ul { padding-left: 22px; }
.original-body { padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; background: #f5f6f7; border-radius: 12px; line-height: 1.6; }
.detail-row, .detail-row a { max-width: 100%; margin-bottom: 12px; overflow-wrap: anywhere; word-break: break-word; }
.dialog-actions { position: sticky; bottom: 0; display: flex; justify-content: space-between; padding: 14px 18px max(14px, env(safe-area-inset-bottom)); background: white; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 20; transform: translateX(-50%); width: min(90%, 480px); padding: 13px 16px; color: white; text-align: center; background: #14202b; border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.25); }
@media (min-width: 640px) {
  main { padding-top: 28px; }
  .filters { grid-template-columns: repeat(3, 1fr); }
  .filters label:last-child { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .backup-actions { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .app-header { align-items: flex-start; }
  .section-heading { align-items: flex-start; }
  .heading-actions { flex-direction: column; align-items: stretch; }
  .count-badge { align-self: flex-end; }
  .card-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .card-actions { flex-wrap: wrap; }
  .card-actions select { max-width: 100%; flex: 1 1 150px; }
  .sticky-actions { flex-wrap: wrap; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .sticky-actions { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
