/* LSP CRM screens. Phone first; wider layouts for the Galaxy Tab and PC. */
:root {
  --navy: #0A1F33;
  --navy-2: #163452;
  --teal: #3FC1D0;
  --teal-dark: #1F8D9A;
  --bg: #F3F5F8;
  --card: #FFFFFF;
  --text: #13202E;
  --muted: #5B6B7C;
  --line: #DCE2E9;
  --red: #C62828;
  --green: #2E7D32;
  --amber: #A66300;
  --radius: 12px;
  --tap: 48px;
  --nav-h: 64px;
  font-family: "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-size: 17px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
a { color: var(--teal-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Frame: header, nav, content ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #fff;
  border-bottom: 4px solid var(--teal);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 12px; min-height: 60px;
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back {
  color: #fff; text-decoration: none; font-size: 26px; line-height: 1;
  min-width: var(--tap); min-height: 40px; display: grid; place-items: center; margin-left: -12px;
}
.topbar .brand { font-weight: 700; letter-spacing: .5px; color: var(--teal); font-size: 15px; }

main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--navy); display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 3px solid var(--teal);
}
.nav a {
  flex: 1; min-height: var(--nav-h); color: #C9D6E3; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 13px; font-weight: 600; position: relative;
}
.nav a .icon { font-size: 22px; line-height: 1; }
.nav a.active { color: #fff; background: var(--navy-2); }
.nav a.active::before { content: ""; position: absolute; top: 0; left: 20%; right: 20%; height: 3px; background: var(--teal); }
.nav .nav-brand { display: none; }
.badge { background: var(--teal); color: var(--navy); border-radius: 999px; font-size: 12px; padding: 0 7px; font-weight: 700; }

/* ---------- Cards, lists, sections ---------- */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 16px; overflow: hidden; }
.card-pad { padding: 16px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: #FAFBFC;
}
.section-head h2 { font-size: 17px; margin: 0; color: var(--navy); }
.section-head .count { color: var(--muted); font-weight: 400; }
.empty { padding: 16px; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 64px;
  text-decoration: none; color: inherit;
}
a.row:active, a.row:hover { background: #F0F7F8; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 17px; }
.row .sub { color: var(--muted); font-size: 15px; margin-top: 2px; }
.row .chev { color: var(--muted); font-size: 22px; }
.row .side { text-align: right; color: var(--muted); font-size: 14px; white-space: nowrap; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; vertical-align: middle; }
.pill.active { background: #E3F4E5; color: var(--green); }
.pill.prospect { background: #E1F5F8; color: #136C76; }
.pill.inactive { background: #FFF1DC; color: var(--amber); }
.pill.past { background: #ECEFF2; color: var(--muted); }
.pill.overdue { background: var(--red); color: #fff; }
.pill.soon { background: #FFF1DC; color: var(--amber); }
.list > li.is-overdue { border-left: 5px solid var(--red); background: #FFF6F6; }
.overdue-text, .overdue-text strong { color: var(--red); }
.code { font-family: Consolas, "Courier New", monospace; font-size: 22px; font-weight: 700; letter-spacing: 2px; color: var(--navy); }
.list > li.system-head { background: #EEF6F8; }
.list > li.system-head .title { color: var(--navy); }
.list > li.in-system .row { padding-left: 36px; border-left: 4px solid var(--teal); }
.change-list { margin: 8px 0; padding: 8px 14px; background: #F3F8F9; border-left: 4px solid var(--teal); border-radius: 6px; }
.change-list div { display: flex; gap: 8px; padding: 2px 0; }
.change-list dt { font-weight: 600; min-width: 120px; color: var(--muted); text-transform: capitalize; }
.change-list dd { margin: 0; }
.key-box { font-family: Consolas, "Courier New", monospace; font-size: 15px; word-break: break-all; background: #FFF8E1; border: 2px dashed var(--amber); border-radius: 10px; padding: 12px; margin: 8px 0; }
.note-quote { margin: 8px 0; padding: 10px 14px; background: #F3F8F9; border-left: 4px solid var(--teal); border-radius: 6px; white-space: pre-wrap; }
.queue-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.inline-form { margin-top: 12px; }
.inline-form .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.inline-form textarea { width: 100%; min-height: 96px; border: 1px solid #C5CED8; border-radius: 10px; padding: 10px 12px; font: inherit; resize: vertical; }
.suggest-box { padding: 0 16px; }
.suggest-box:empty { display: none; }
.suggest-box .inline-form { padding-bottom: 16px; }
.tag { display: inline-block; background: #EEF1F5; color: #34495E; border-radius: 6px; padding: 1px 8px; font-size: 13px; margin: 2px 4px 2px 0; }
.flag { display: inline-block; background: var(--navy); color: #fff; border-radius: 6px; padding: 1px 8px; font-size: 12px; margin: 2px 4px 2px 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--navy); font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--navy); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); border-color: #F0C7C7; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; }
.topbar .btn { min-height: 40px; background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 25;
  min-height: 56px; padding: 0 22px; border-radius: 28px; box-shadow: 0 4px 14px rgba(10,31,51,.25);
}

/* ---------- Client list tools ---------- */
.search {
  width: 100%; min-height: 52px; border-radius: 12px; border: 1px solid var(--line);
  padding: 0 16px; font-size: 17px; background: #fff;
}
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-size: 15px; font-weight: 600; color: var(--navy); cursor: pointer;
}
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.filter-selects { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-selects select { flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 0 10px; }
.result-count { color: var(--muted); font-size: 14px; margin: 0 0 8px 4px; }

/* ---------- Client page ---------- */
.hero { padding: 16px; }
.hero .name { font-size: 24px; font-weight: 700; margin: 0 0 6px; color: var(--navy); }
.hero .meta { color: var(--muted); margin-bottom: 8px; }
.hero .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.details { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.details > div { padding: 12px 16px; border-top: 1px solid var(--line); }
.details > div:first-child { border-top: 0; }
.details dt { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.details dd { margin: 2px 0 0; white-space: pre-wrap; }
.contact-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.contact-links a { min-height: 44px; }
.lock-note { font-size: 13px; color: var(--muted); font-weight: 400; }
.notes-text { padding: 16px; white-space: pre-wrap; }

/* ---------- Forms ---------- */
form .field { margin-bottom: 16px; }
form label.lbl { display: block; font-weight: 600; margin-bottom: 6px; color: var(--navy); }
form .req { color: var(--red); }
form input[type=text], form input[type=email], form input[type=tel], form input[type=number], form input[type=date], form select, form textarea {
  width: 100%; min-height: var(--tap); border: 1px solid #C5CED8; border-radius: 10px; padding: 10px 12px; background: #fff;
}
form textarea { min-height: 96px; resize: vertical; }
form input:focus, form select:focus, form textarea:focus, .search:focus { outline: 3px solid rgba(63,193,208,.45); border-color: var(--teal-dark); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-addr { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--teal-dark); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px 12px; margin: 0 0 16px; background: #fff; }
legend { font-weight: 700; color: var(--navy); padding: 0 6px; }
.hint { font-size: 14px; color: var(--muted); margin: 4px 0 0; }
.form-actions {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: var(--bg);
  padding: 12px 0; display: flex; gap: 8px; border-top: 1px solid var(--line); z-index: 5;
}
.form-actions .btn { flex: 1; }
.error { background: #FDECEC; color: var(--red); border-radius: 10px; padding: 12px; margin-bottom: 12px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--navy); }
.login .card { width: 100%; max-width: 400px; border-top: 5px solid var(--teal); }
.login h1 { margin: 0 0 4px; color: var(--navy); }
.login p { color: var(--muted); margin-top: 0; }
.linkbtn { background: none; border: 0; color: var(--teal-dark); text-decoration: underline; cursor: pointer; min-height: 44px; padding: 0; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 80px); z-index: 50;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s; max-width: 90vw; border-left: 4px solid var(--teal);
}
#toast.show { opacity: 1; }

/* ---------- Tablet and PC ---------- */
@media (min-width: 768px) {
  body { font-size: 17px; }
  .shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
  .nav {
    position: sticky; top: 0; height: 100vh; flex-direction: column; justify-content: flex-start;
    border-top: 0; border-right: 4px solid var(--teal); padding: 0;
  }
  .nav .nav-brand {
    display: block; padding: 22px 18px; color: #fff; font-weight: 700; font-size: 18px; line-height: 1.2;
    border-bottom: 1px solid rgba(255,255,255,.12);
  }
  .nav .nav-brand small { display: block; color: var(--teal); font-size: 12px; letter-spacing: .5px; font-weight: 600; }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 18px; font-size: 16px; min-height: 56px; }
  .nav a.active::before { top: 10%; bottom: 10%; left: 0; right: auto; width: 4px; height: auto; }
  .topbar { padding: 12px 24px; }
  .topbar h1 { font-size: 22px; }
  main { padding: 24px 24px 48px; }
  .fab { bottom: 24px; right: 24px; }
  .form-actions { bottom: 0; }
  #toast { bottom: 40px; }
  .details { grid-template-columns: 1fr 1fr; }
  .details > div { border-top: 0; }
  .details > div.wide { grid-column: 1 / -1; }
  form.wide-form { max-width: 760px; }
}
/* Tablet turned sideways, and the PC: two columns side by side */
@media (min-width: 1000px) {
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
}
@media (max-width: 420px) {
  .grid-addr { grid-template-columns: 1fr 1fr; }
  .grid-addr > :first-child { grid-column: 1 / -1; }
}
