/* Expat Gameplan, styles */

:root {
  --navy: #10243a;
  --navy-2: #16314e;
  --teal: #0e7d72;
  --teal-dark: #0a5f57;
  --gold: #c8923a;
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #21303f;
  --muted: #66758a;
  --line: #e3ded4;
  --danger: #b3403a;
  --warn-bg: #fdf3e4;
  --good: #2e7d4f;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 36, 58, 0.08), 0 4px 16px rgba(16, 36, 58, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
}

#app { display: flex; height: 100vh; }

/* ---------- Sidebar ---------- */

#sidebar {
  width: 232px;
  min-width: 232px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #dce7f2;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 4px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; }
.brand-mark { font-size: 28px; }
.brand-name { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: 0.2px; }
.brand-tag { font-size: 11.5px; color: #8fa6bd; }

.nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: 0; color: #c3d2e1;
  font-size: 14px; font-family: inherit;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-btn.active { background: var(--teal); color: #fff; font-weight: 600; }
.nav-ico { width: 20px; text-align: center; }

.sidebar-spacer { flex: 1; }
.sidebar-foot { font-size: 10.5px; color: #7186a0; padding: 12px 10px 2px; line-height: 1.5; }

/* ---------- Main ---------- */

#content { flex: 1; overflow-y: auto; padding: 34px 44px 60px; }

.view { display: none; max-width: 980px; margin: 0 auto; }
.view.active { display: block; }

.view-head h1 { font-size: 27px; font-weight: 700; color: var(--navy); }
.view-head p { color: var(--muted); margin: 4px 0 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Buttons / inputs ---------- */

.btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  border-radius: 9px; border: 1px solid transparent;
  padding: 9px 18px; cursor: pointer; transition: 0.15s;
}
.btn-lg { padding: 13px 26px; font-size: 15.5px; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-accent { background: var(--gold); color: #fff; }
.btn-accent:hover { filter: brightness(0.93); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: #efece5; }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: default; }

.input {
  font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 9px;
  padding: 10px 13px; width: 100%;
}
.input:focus { outline: none; border-color: var(--teal); }
.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--navy); margin: 14px 0 5px; }
.field-hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- Home ---------- */

.hero {
  background: linear-gradient(135deg, var(--navy) 0%, #1c4368 70%, #205a72 100%);
  color: #fff; border-radius: 16px; padding: 46px 48px; margin-bottom: 26px;
}
.hero h1 { font-size: 30px; line-height: 1.25; font-weight: 750; }
.hero p { margin: 16px 0 24px; max-width: 640px; color: #cfdeea; font-size: 15.5px; }
.hero-actions { display: flex; gap: 12px; }
.hero .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.4); }
.hero .btn-ghost:hover { background: rgba(255,255,255,0.1); }

.home-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.home-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.hc-ico { font-size: 26px; margin-bottom: 10px; }
.home-card h3 { font-size: 15.5px; color: var(--navy); margin-bottom: 6px; }
.home-card p { font-size: 13.5px; color: var(--muted); }

.home-strip {
  display: flex; gap: 40px; justify-content: center;
  margin-top: 26px; padding: 18px; border-top: 1px solid var(--line);
}
.home-strip div { text-align: center; }
.home-strip strong { display: block; font-size: 24px; color: var(--teal); }
.home-strip span { font-size: 12.5px; color: var(--muted); }

/* ---------- Wizard ---------- */

.wizard { max-width: 720px; }
.wizard-progress { display: flex; gap: 8px; margin-bottom: 26px; }
.wizard-progress .step {
  flex: 1; height: 6px; border-radius: 4px; background: var(--line);
  position: relative;
}
.wizard-progress .step.done { background: var(--teal); }
.wizard-progress .step.current { background: var(--gold); }

.wizard h2 { font-size: 20px; color: var(--navy); margin-bottom: 4px; }
.wizard .step-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }

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

.radio-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 4px; }
.radio-card {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px;
  cursor: pointer; font-size: 13.5px; background: #fff;
}
.radio-card:hover { border-color: var(--teal); }
.radio-card.selected { border-color: var(--teal); background: #ecf6f4; font-weight: 600; }
.radio-card .rc-title { font-weight: 650; color: var(--navy); display: block; }
.radio-card .rc-sub { font-size: 12px; color: var(--muted); font-weight: 400; }

.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.check-item {
  display: flex; align-items: center; gap: 9px;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 13px;
  cursor: pointer; font-size: 13.5px; background: #fff;
}
.check-item.selected { border-color: var(--teal); background: #ecf6f4; }

.wizard-nav { display: flex; justify-content: space-between; margin-top: 28px; }

/* ---------- Country guides ---------- */

.search-input { max-width: 380px; margin-bottom: 18px; }

.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.country-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; box-shadow: var(--shadow); transition: 0.15s;
}
.country-card:hover { transform: translateY(-2px); border-color: var(--teal); }
.country-card .cc-flag { font-size: 26px; }
.country-card h3 { font-size: 15px; color: var(--navy); margin: 6px 0 2px; }
.country-card .cc-meta { font-size: 12px; color: var(--muted); }
.cc-badges { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  font-size: 10.5px; font-weight: 700; border-radius: 20px; padding: 2px 9px;
}
.badge-good { background: #e3f1e8; color: var(--good); }
.badge-warn { background: var(--warn-bg); color: #9a6516; }

#country-detail .card { margin-top: 18px; }
.cd-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.cd-head .cd-flag { font-size: 40px; }
.cd-head h2 { font-size: 23px; color: var(--navy); }
.cd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.cd-block { background: #faf8f4; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.cd-block h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--teal-dark); margin-bottom: 6px; }
.cd-block p, .cd-block li { font-size: 13.5px; }
.cd-block ul { padding-left: 18px; }
.cd-full { grid-column: 1 / -1; }
.back-link { background: none; border: none; color: var(--teal); font-size: 13.5px; cursor: pointer; padding: 0; margin-bottom: 12px; font-family: inherit; font-weight: 600; }

/* ---------- Plan ---------- */

.plan-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.plan-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-ico { font-size: 44px; margin-bottom: 10px; }
.empty-state h2 { color: var(--navy); margin-bottom: 6px; }
.empty-state p { margin-bottom: 18px; }

.plan-doc {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 40px 46px;
}
.plan-header { border-bottom: 3px solid var(--teal); padding-bottom: 18px; margin-bottom: 26px; }
.plan-header h1 { font-size: 25px; color: var(--navy); }
.plan-sub { color: var(--muted); font-size: 13.5px; margin-top: 5px; }

.plan-section { margin-bottom: 30px; }
.plan-section h2 { font-size: 18.5px; color: var(--teal-dark); margin-bottom: 12px; }
.plan-section h3 { font-size: 15px; color: var(--navy); margin: 16px 0 8px; }

.plan-table { width: 100%; border-collapse: collapse; }
.plan-table th {
  text-align: left; font-size: 13px; color: var(--muted); font-weight: 600;
  padding: 8px 14px 8px 0; width: 220px; vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.plan-table td { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

.plan-list { list-style: none; }
.plan-list li {
  padding: 10px 14px; margin-bottom: 8px;
  background: #faf8f4; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px;
}
.plan-list li.warn-li { background: var(--warn-bg); border-color: #efd9b0; }
.plan-list li.highlight-li { background: #ecf6f4; border-color: #bfe0db; }

.callout { border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.callout-primary { background: #ecf6f4; border: 1.5px solid var(--teal); }
.callout-primary strong { color: var(--teal-dark); }
.callout p { margin-top: 6px; font-size: 14px; }

.action-list { list-style: none; counter-reset: action; }
.action-list li { margin-bottom: 7px; }
.action-list label {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 13px; cursor: pointer; font-size: 13.5px;
}
.action-list input[type="checkbox"] { margin-top: 3px; accent-color: var(--teal); }
.action-list input:checked + span { text-decoration: line-through; color: var(--muted); }

.plan-note { font-size: 12.5px; color: var(--muted); margin-top: 8px; font-style: italic; }
.plan-footer { border-top: 1px solid var(--line); padding-top: 16px; font-size: 12px; color: var(--muted); }

/* AI summary box on plan page */
.ai-summary {
  background: linear-gradient(135deg, #fdfaf3, #f4f8f7);
  border: 1.5px solid var(--gold); border-radius: var(--radius);
  padding: 22px 26px; margin-bottom: 18px;
}
.ai-summary-head { font-weight: 700; color: var(--navy); margin-bottom: 10px; }
#ai-summary-status { font-weight: 400; font-size: 12.5px; color: var(--muted); margin-left: 8px; }

/* ---------- Advisor chat ---------- */

.chat-log {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px; height: calc(100vh - 360px); min-height: 320px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}
.chat-msg { display: flex; gap: 11px; max-width: 92%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-avatar {
  width: 32px; height: 32px; min-width: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  background: var(--navy); color: #fff;
}
.chat-msg.user .chat-avatar { background: var(--gold); }
.chat-bubble {
  background: #f3f0e9; border-radius: 12px; padding: 11px 15px; font-size: 14px;
}
.chat-msg.user .chat-bubble { background: var(--teal); color: #fff; }
.chat-status { font-size: 12.5px; color: var(--muted); font-style: italic; padding-left: 44px; }

.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip {
  font-family: inherit; font-size: 12.5px; color: var(--teal-dark);
  background: #ecf6f4; border: 1px solid #bfe0db; border-radius: 20px;
  padding: 6px 13px; cursor: pointer;
}
.chip:hover { background: #ddefeb; }

.chat-input-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-input-row textarea { resize: none; }
.chat-foot { font-size: 11.5px; color: var(--muted); margin-top: 8px; text-align: center; }

.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.source-chip {
  font-size: 11.5px; color: var(--navy); background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 3px 11px; cursor: pointer; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.source-chip:hover { border-color: var(--teal); }

/* markdown-ish rendering */
.md-body p { margin-bottom: 9px; }
.md-body p:last-child { margin-bottom: 0; }
.md-body ul, .md-body ol { padding-left: 20px; margin-bottom: 9px; }
.md-body h1, .md-body h2, .md-body h3 { color: var(--navy); margin: 12px 0 6px; font-size: 15.5px; }
.md-body code { background: #eee9df; border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.md-body strong { color: inherit; }
.md-body table { border-collapse: collapse; margin: 8px 0; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: 5px 10px; font-size: 13px; }

/* ---------- Settings ---------- */

.settings-card { max-width: 640px; margin-bottom: 18px; }
.settings-card h3 { color: var(--navy); margin-bottom: 8px; }
.key-row { display: flex; gap: 10px; margin-top: 4px; }
.key-status { font-size: 13px; margin-top: 8px; min-height: 18px; }
.key-status.ok { color: var(--good); }
.key-status.err { color: var(--danger); }
.ext-link { color: var(--teal); cursor: pointer; }

/* ---------- Pro: client manager ---------- */

.pro-badge {
  font-size: 9px; font-weight: 800; letter-spacing: 0.8px;
  background: var(--gold); color: #fff; border-radius: 4px; padding: 1.5px 5px;
  vertical-align: middle; margin-left: 4px;
}
.client-list { display: flex; flex-direction: column; gap: 10px; }
.client-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 20px;
}
.client-card.active-client { border-color: var(--teal); background: #f4faf9; }
.client-name { font-weight: 700; color: var(--navy); font-size: 15.5px; }
.client-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.client-actions { display: flex; gap: 7px; }
.btn-sm { padding: 6px 13px; font-size: 12.5px; }

/* ---------- Budget abroad ---------- */

.budget-card { margin-bottom: 22px; }
.budget-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 18px; }
.budget-total {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 15px; color: var(--navy);
}
.budget-total strong { color: var(--teal-dark); font-size: 18px; }
.budget-rank-title { color: var(--navy); font-size: 17px; margin-bottom: 10px; }
.budget-results-card { padding: 0; overflow: hidden; }
.budget-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.budget-table thead th {
  background: var(--navy); color: #fff; text-align: left; padding: 10px 14px; font-size: 12.5px;
}
.budget-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.budget-row { cursor: pointer; }
.budget-row:hover td { background: #f3f7f6; }
.budget-row.budget-top td { background: #ecf6f4; }
.budget-row.budget-top:hover td { background: #e2f0ed; }
.budget-table .pos { color: var(--good); font-weight: 600; }
.budget-table .neg { color: var(--danger); font-weight: 600; }
.budget-detail td { background: #faf8f4; }
.budget-breakdown { border-collapse: collapse; font-size: 12.5px; }
.budget-breakdown th { text-align: left; font-weight: 600; color: var(--muted); padding: 3px 16px 3px 0; }
.budget-breakdown td { padding: 3px 8px 3px 0; border: 0; }

/* ---------- Country comparison ---------- */

.compare-pickers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; max-width: 760px; }
.compare-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.compare-table { border-collapse: collapse; width: 100%; background: var(--card); font-size: 13px; }
.compare-table th, .compare-table td {
  border: 1px solid var(--line); padding: 10px 13px; text-align: left; vertical-align: top;
  min-width: 220px;
}
.compare-table thead th {
  background: var(--navy); color: #fff; text-align: center; font-size: 14.5px;
  position: sticky; top: 0;
}
.compare-table thead th:first-child { background: var(--navy); min-width: 150px; }
.compare-table tbody th {
  background: #faf8f4; color: var(--teal-dark); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.4px; min-width: 150px; width: 160px;
}
.cmp-flag { font-size: 24px; }

/* ---------- Activation gate ---------- */

.activate-wrap { display: flex; justify-content: center; padding-top: 6vh; }
.activate-card { max-width: 460px; width: 100%; text-align: center; padding: 38px 40px; }
.activate-logo { font-size: 46px; margin-bottom: 8px; }
.activate-card h1 { font-size: 23px; color: var(--navy); margin-bottom: 8px; }
.activate-card .muted { font-size: 13.5px; margin-bottom: 18px; }
.activate-input {
  text-align: center; font-family: Consolas, monospace; font-size: 17px;
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 12px;
}
.activate-btn { width: 100%; }
.activate-divider {
  margin: 22px 0 12px; color: var(--muted); font-size: 12.5px;
  display: flex; align-items: center; gap: 12px;
}
.activate-divider::before, .activate-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.activate-fine { font-size: 12px; color: var(--muted); margin-top: 12px; }
body.locked .nav-btn:not([data-view="settings"]) { opacity: 0.45; }

/* ---------- Misc ---------- */

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: #cfc8ba; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Mobile / iPhone (PWA) ---------- */

.lbl-short { display: none; }

@media (max-width: 760px) {
  #app { flex-direction: column; }

  /* Sidebar becomes a fixed bottom tab bar */
  #sidebar {
    order: 2;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    width: 100%; min-width: 0;
    flex-direction: row; align-items: stretch;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    gap: 0;
    overflow-x: auto;
  }
  .brand, .sidebar-foot, .sidebar-spacer { display: none; }
  .nav-btn {
    flex: 1; flex-direction: column; gap: 2px;
    font-size: 9.5px; padding: 7px 2px; text-align: center;
    justify-content: center; align-items: center; min-width: 42px;
  }
  .nav-ico { width: auto; font-size: 19px; }
  .pro-badge { display: none; }
  .lbl-full { display: none; }
  .lbl-short { display: inline; }

  #content { padding: 18px 14px 96px; }
  .view-head h1 { font-size: 22px; }

  .hero { padding: 26px 22px; }
  .hero h1 { font-size: 21px; }
  .hero-actions { flex-direction: column; }
  .home-grid { grid-template-columns: 1fr; }
  .home-strip { flex-wrap: wrap; gap: 18px; }

  .field-row { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
  .wizard { padding: 18px; }

  .cd-grid { grid-template-columns: 1fr; }
  .plan-doc { padding: 22px 18px; }
  .plan-head-row { flex-direction: column; }
  .plan-actions .btn { font-size: 12.5px; padding: 8px 12px; }

  .compare-pickers { grid-template-columns: 1fr; }
  .budget-grid { grid-template-columns: 1fr; }
  .budget-table { font-size: 12px; }
  .budget-table td, .budget-table thead th { padding: 8px 8px; }
  .compare-table th, .compare-table td { min-width: 170px; font-size: 12px; }

  .chat-log { height: calc(100vh - 420px); min-height: 240px; }
  .chat-msg { max-width: 100%; }
  .client-card { flex-direction: column; align-items: flex-start; }
}

/* Line icons (replace emoji) */
.ico { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.15em; }
.nav-ico { display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.brand-mark, .activate-logo { color: var(--gold); line-height: 1; }
.hc-ico, .empty-ico { color: var(--teal); line-height: 1; }
.chat-avatar .ico { font-size: 17px; }
/* Country code badges (replace flag emoji) */
.cc-flag, .cd-flag, .cmp-flag { display: inline-flex; align-items: center; justify-content: center; font: 700 12px/1 "Segoe UI", system-ui, sans-serif; letter-spacing: 0.06em; color: var(--navy); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.country-card .cc-flag { font-size: 12px; }
.cd-head .cd-flag { font-size: 14px; padding: 7px 10px; }
.cmp-flag { font-size: 11px; color: var(--navy); background: #fff; margin-right: 8px; vertical-align: 2px; }
