/* Executor's Compass — senior-friendly, offline-first UI */

:root {
  --accent: #1a5f5a;
  --accent-hover: #134845;
  --accent-soft: #e6f3f1;
  --accent-mid: #2a7a73;
  --danger: #a32020;
  --danger-soft: #fdecec;
  --warn: #8a5a00;
  --warn-soft: #fff4db;
  --ok: #1a6b4a;
  --ok-soft: #e6f4ed;
  --text: #1a1f28;
  --text-muted: #4a5568;
  --border: #c5cdd9;
  --surface: #ffffff;
  --bg: #f2f5f4;
  --shadow: 0 2px 10px rgba(26, 31, 40, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --touch: 48px;
  --max: 720px;
  --space: 1rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  font-size: 1.75rem;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Tab nav */
.tab-nav {
  max-width: var(--max);
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 0.25rem;
  padding: 0.65rem 0.75rem 0;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 40;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 2px solid var(--border);
}

.tab {
  flex: 1 1 auto;
  min-height: var(--touch);
  min-width: 4.25rem;
  padding: 0.5rem 0.55rem;
  border: 2px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.tab:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.tab.active {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
  border-bottom: 2px solid var(--surface);
  margin-bottom: -2px;
}

/* Main */
main {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  color: var(--text);
}

.panel-lead {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 1rem;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 0.65rem;
  font-size: 1.1rem;
  color: var(--text);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.card-head h3 {
  margin: 0;
}

.card-note {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.sample-card {
  border-color: var(--accent-mid);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 55%);
}

.form-card h3 {
  margin-bottom: 1rem;
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-grid.compact {
  margin-bottom: 0.85rem;
}

@media (min-width: 560px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.stat-card.stat-primary {
  border-color: var(--accent-mid);
  background: var(--accent-soft);
}

.stat-card.stat-warn {
  border-color: #e0b84a;
  background: var(--warn-soft);
}

.stat-card.stat-danger {
  border-color: #e0a0a0;
  background: var(--danger-soft);
}

.stat-label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  margin: 0.25rem 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}

.stat-of {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-link {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stat-link:hover,
.stat-link:focus-visible {
  color: var(--accent-hover);
}

.stat-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Progress */
.progress-card {
  margin-bottom: 1rem;
}

.progress-wrap {
  height: 14px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0 0.65rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s ease;
  min-width: 0;
}

.progress-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Phase grid */
.phase-grid {
  display: grid;
  gap: 0.55rem;
}

.phase-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

.phase-row button {
  grid-column: 1 / -1;
  justify-self: start;
}

.phase-name {
  font-weight: 600;
  color: var(--text);
}

.phase-count {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.phase-mini {
  grid-column: 1 / -1;
  height: 8px;
  background: #d8dee6;
  border-radius: 999px;
  overflow: hidden;
}

.phase-mini > span {
  display: block;
  height: 100%;
  background: var(--accent-mid);
  border-radius: 999px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.6rem 1.1rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-secondary:hover {
  background: var(--accent-soft);
}

.btn-text {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  min-width: auto;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

.btn-text:hover {
  background: var(--accent-soft);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #8a1a1a;
}

.btn-sm {
  min-height: 44px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-icon:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Forms */
.field {
  margin-bottom: 0.9rem;
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  color: var(--text);
}

.req {
  color: var(--danger);
  font-weight: 600;
  font-size: 0.85rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 0.65rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface);
}

.field textarea {
  min-height: 5rem;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 95, 90, 0.2);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 0.75rem;
}

@media (min-width: 520px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

.filters {
  margin-bottom: 1rem;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 0.75rem;
}

@media (min-width: 520px) {
  .filter-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 640px) {
  .filter-row {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Lists */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.item-card {
  display: grid;
  gap: 0.45rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.item-card.overdue {
  border-color: #e0a0a0;
  background: var(--danger-soft);
}

.item-card.soon {
  border-color: #e0b84a;
  background: var(--warn-soft);
}

.item-card.done {
  opacity: 0.88;
  background: var(--ok-soft);
  border-color: #9bc9b3;
}

.item-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
}

.item-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.item-meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.item-notes {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
  white-space: pre-wrap;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.pill.priority-high {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill.priority-low {
  background: #e8ecf0;
  color: var(--text-muted);
}

.pill.status-done {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.status-in_progress {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.status-open {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.status-na {
  background: #e8ecf0;
  color: var(--text-muted);
}

.pill.doc-needed {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill.doc-have,
.pill.doc-filed {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.doc-requested {
  background: var(--warn-soft);
  color: var(--warn);
}

.empty-msg {
  margin: 0.5rem 0 0;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}

.result-summary {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

.status-msg {
  margin: 0.65rem 0 0;
  font-size: 0.95rem;
  color: var(--ok);
  font-weight: 600;
  min-height: 1.4em;
}

/* Tips & about */
.tip-list {
  margin: 0;
  padding-left: 1.25rem;
}

.tip-list li {
  margin-bottom: 0.5rem;
  color: var(--text);
}

.about-list {
  margin: 0;
  padding-left: 1.25rem;
}

.about-list li {
  margin-bottom: 0.55rem;
  color: var(--text-muted);
}

.prose {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
}

/* Bar charts */
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.bar-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  background: #d8dee6;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  min-width: 0;
}

.bar-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 2.5rem;
  text-align: right;
}

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: calc(100% - 1.5rem);
  max-width: 520px;
  max-height: min(90vh, 720px);
  box-shadow: 0 12px 40px rgba(26, 31, 40, 0.25);
  color: var(--text);
  background: var(--surface);
}

.modal::backdrop {
  background: rgba(26, 31, 40, 0.55);
}

.modal-sm {
  max-width: 400px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--accent);
}

.modal-body {
  padding: 1rem 1.1rem;
  overflow-y: auto;
  max-height: min(60vh, 480px);
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 200;
  max-width: calc(100% - 2rem);
  padding: 0.85rem 1.25rem;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  text-align: center;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1.25rem 1rem 1.5rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.app-footer p {
  margin: 0;
  max-width: var(--max);
  margin-inline: auto;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Checkbox-style mark done button row */
.duty-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.duty-check:hover {
  background: var(--accent-soft);
}

.duty-check:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.duty-check.checked {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.item-with-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
}

/* Deadline timeline marker */
.deadline-date {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
}

.deadline-relative {
  font-size: 0.85rem;
  font-weight: 600;
}

.deadline-relative.past {
  color: var(--danger);
}

.deadline-relative.near {
  color: var(--warn);
}

.deadline-relative.future {
  color: var(--text-muted);
}
