:root {
  --bg0: #07161c;
  --bg: #f4f1ea;
  --paper: rgba(255,255,255,.86);
  --ink: #12202a;
  --muted: #667684;
  --line: #e6dfd2;
  --brand: #0e6e7a;
  --brand-d: #0a4d56;
  --gold: #d4a24c;
  --gold-2: #f3d9a0;
  --ok: #0f7a4a;
  --danger: #c24130;
  --shadow: 0 18px 50px rgba(12, 32, 40, .10);
  --radius: 22px;
  --nav-w: 272px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  margin: 0; min-height: 100%;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(212,162,76,.18), transparent 55%),
    radial-gradient(900px 500px at -10% 20%, rgba(14,110,122,.10), transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: "Heebo", "Segoe UI", Tahoma, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.layout { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh;
  background:
    linear-gradient(165deg, rgba(212,162,76,.16), transparent 38%),
    linear-gradient(180deg, #08262d 0%, #0b3f48 55%, #0e5b66 100%);
  color: #eef7f8; padding: 26px 16px 20px; overflow: auto;
}
.brand {
  display: flex; align-items: center; gap: 12px; margin: 0 8px 22px;
  color: inherit; text-decoration: none;
}
.logo {
  width: 44px; height: 44px; border-radius: 16px;
  background: linear-gradient(145deg, var(--gold-2), var(--gold));
  color: #3b2a0d; display: grid; place-items: center; font-weight: 800; letter-spacing: .04em;
  box-shadow: 0 8px 20px rgba(212,162,76,.35);
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: .06em; }
.brand small { display: block; opacity: .65; font-size: 12px; font-weight: 500; }
.credits {
  margin: 0 8px 22px; padding: 12px 14px; border-radius: 16px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
}
.credits b { color: var(--gold-2); }
.nav a.n {
  display: flex; align-items: center; gap: 10px;
  color: #d7ecef; padding: 11px 12px; border-radius: 14px; margin-bottom: 4px; font-weight: 600;
}
.nav a.n:hover, .nav a.n.active {
  background: rgba(255,255,255,.12); color: #fff;
}
.nav a.n.active { box-shadow: inset 3px 0 0 var(--gold); }
.nav .sec { font-size: 11px; letter-spacing: .12em; opacity: .5; margin: 18px 12px 8px; }
.main { padding: 28px 28px 48px; min-width: 0; }
.topbar {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap;
}
.live-search { position: relative; flex: 1; min-width: min(100%, 280px); max-width: 560px; }
.live-search input {
  width: 100%; padding: 13px 16px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--paper); box-shadow: var(--shadow);
}
.suggest {
  position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 40;
  background: #fff; border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--line);
  overflow: hidden; display: none;
}
.suggest.open { display: block; }
.suggest a, .suggest .s-item {
  display: block; padding: 10px 14px; color: var(--ink); border-bottom: 1px solid #f1ece3;
  cursor: pointer;
}
.suggest a:hover, .suggest .s-item:hover { background: #f7f3ea; }
.suggest .meta { color: var(--muted); font-size: 12px; }
.menu-btn, .bottom-nav { display: none; }
h2 { margin: 0 0 6px; font-size: clamp(22px, 3vw, 32px); font-weight: 800; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.card, .panel {
  background: var(--paper); border: 1px solid rgba(255,255,255,.7);
  border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.card { padding: 18px 18px 16px; overflow: hidden; position: relative; }
.card:before {
  content: ""; position: absolute; inset: auto -20px -30px auto; width: 90px; height: 90px;
  border-radius: 50%; background: radial-gradient(circle, rgba(212,162,76,.28), transparent 70%);
}
.card span { color: var(--muted); font-size: 13px; font-weight: 600; }
.card b { display: block; font-size: 30px; margin-top: 8px; letter-spacing: -.03em; }
.panel { padding: 18px; margin-bottom: 16px; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: right; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 14px; white-space: nowrap; }
th { color: var(--muted); font-weight: 700; font-size: 12px; letter-spacing: .04em; }
tr:hover td { background: #fbf8f2; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, #128190, var(--brand-d)); color: #fff !important;
  border: 0; border-radius: 14px; padding: 11px 16px; cursor: pointer; font-weight: 700;
  box-shadow: 0 10px 18px rgba(14,110,122,.22);
}
.btn.gold { background: linear-gradient(180deg, #e3b65e, #c4922f); color: #2c1d05 !important; }
.btn.gray { background: #ece7dc; color: var(--ink) !important; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--brand) !important; box-shadow: none; border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #d9d1c4; border-radius: 14px; background: #fff;
}
textarea { resize: vertical; min-height: 96px; }
label { display: block; margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.field { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.flash { padding: 10px 14px; border-radius: 14px; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
.flash.ok { background: #eef6f1; color: var(--ok); }
.flash.err { background: #fdecea; color: var(--danger); }
.clients-panel { padding: 14px 16px 10px; }
.clients-search { margin-bottom: 6px; }
.clients-search input { padding: 14px 16px; font-size: 16px; border-radius: 16px; }
.clients-table-wrap { margin-top: 8px; }
.clients-table { width: 100%; min-width: 720px; }
.clients-table th:first-child, .clients-table td:first-child {
  position: sticky; right: 0; background: #fff; z-index: 1; font-weight: 800;
}
.clients-table td.eye { white-space: normal; max-width: 240px; }
.visits-table { width: 100%; min-width: 820px; }
.visits-table td.eye { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 13px; }
.visits-table .visit-note {
  min-width: 180px;
  max-width: 320px;
  white-space: normal;
  line-height: 1.55;
  color: var(--ink);
}
.first-visit-badge {
  display: block;
  width: max-content;
  margin-top: 6px;
  color: var(--brand-d);
  background: #e8f4f2;
}
.client-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: start;
}
.client-side { display: grid; gap: 12px; }
.client-side .panel { padding: 14px; }
.client-side h3 { margin: 0 0 6px; font-size: 16px; }
.client-side-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.client-meta { margin: 0; display: grid; gap: 6px; }
.client-meta div { display: grid; grid-template-columns: 48px 1fr; gap: 6px; align-items: baseline; font-size: 13px; }
.client-meta dt { margin: 0; color: var(--muted); font-weight: 700; font-size: 11px; }
.client-meta dd { margin: 0; font-weight: 600; word-break: break-word; }
.client-side textarea { min-height: 56px; }
.eye,
td.eye,
input.eye,
.v-val.eye {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}
.visit-sheet { display: grid; gap: 14px; }
.v-section h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--muted);
}
.v-eyes, .v-metrics, .v-health {
  display: grid;
  gap: 10px;
}
.v-eyes { grid-template-columns: 1fr 1fr; }
.v-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.v-health { grid-template-columns: 1fr 1fr; }
.v-field {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  min-height: 74px;
}
.v-field.on { border-color: #c5dbb8; background: #f4faf4; }
.v-lab {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--muted);
}
.v-val {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  word-break: break-word;
  line-height: 1.35;
}
.v-val.empty { color: #b8b1a4; font-weight: 600; }
.v-eyes .v-val {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: clamp(16px, 2.2vw, 22px);
}
.v-notes { min-height: 64px; }
.v-notes .v-val { font-size: 15px; font-weight: 500; line-height: 1.65; }
.v-health .v-field {
  min-height: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.v-health .v-lab { margin: 0; font-size: 13px; letter-spacing: 0; font-weight: 700; color: var(--ink); }
.v-health .v-val { font-size: 14px; }
.v-yes { color: var(--ok); }
.v-no { color: var(--muted); font-weight: 700; }
.v-sub {
  margin: 16px 0 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--muted);
}
.first-visit { border-color: rgba(14,110,122,.22); }
.first-visit-hint { margin: -4px 0 14px; font-size: 13px; }
.health-checks label {
  display: flex; align-items: center; gap: 8px;
  margin: 0; padding: 10px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  font-size: 13px; font-weight: 700; color: var(--ink);
}
.health-checks input { width: auto; margin: 0; }
.hint {
  margin: 4px 0 0; padding: 28px 10px; text-align: center;
  color: var(--muted); font-size: 14px; font-weight: 500;
}
.hint[hidden] { display: none !important; }
.badge { display: inline-flex; padding: 3px 9px; border-radius: 999px; font-size: 12px; background: #eee7da; font-weight: 700; }
.badge.paid { background: #e8f7ee; color: var(--ok); }
.badge.unpaid { background: #fdecea; color: var(--danger); }
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(800px 400px at 80% 0%, rgba(212,162,76,.35), transparent),
    linear-gradient(160deg, #061418, #0e5b66);
}
.login-box {
  width: min(420px, 100%); background: rgba(255,255,255,.94); padding: 28px;
  border-radius: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.28);
}
.filters { display: none; }
.filters.open { display: block; padding: 8px 0 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px 7px 8px;
  font-size: 13px; font-weight: 700;
}
.chip button { border: 0; background: #f1ece3; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; }
.composer { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; }
.counter {
  display: flex; justify-content: space-between; gap: 8px; margin-top: 8px;
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.counter strong { color: var(--brand-d); }
.client-cards, .mobile-card { display: none; }
.pager { display: flex; gap: 8px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.check { width: 18px; height: 18px; accent-color: var(--brand); }
.channel { display: flex; background: #efe9dc; padding: 4px; border-radius: 14px; gap: 4px; }
.channel button { flex: 1; border: 0; background: transparent; border-radius: 11px; padding: 10px; font-weight: 800; cursor: pointer; }
.channel button.on { background: #fff; box-shadow: var(--shadow); }
.preview-list { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.preview-list table { min-width: 520px; }
.preview-row {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.preview-row:last-child { border-bottom: 0; }
.confirm-sheet {
  position: fixed; inset: 0; z-index: 80; background: rgba(6,16,20,.55);
  display: grid; place-items: center; padding: 16px;
}
.confirm-sheet[hidden] { display: none !important; }
.confirm-card {
  width: min(720px, 100%); max-height: min(86vh, 800px); overflow: auto;
  background: #fff; border-radius: 24px; padding: 20px; box-shadow: var(--shadow);
}
.send-banner {
  background: #e8f4f2; border: 1px solid #b7d9d3; color: #0a4d56;
  border-radius: 14px; padding: 10px 14px; margin: 0 0 14px; font-size: 13px; line-height: 1.55;
}
.send-banner.done { background: #eef6ea; border-color: #c5dbb8; }
.send-banner.err { background: #fdecee; border-color: #f3c4ca; color: #8a1f2a; }
.btn.on-filter { background: var(--brand); color: #fff; }
.mobile-card b { font-size: 16px; }
@media (max-width: 1100px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .composer, .grid-4 { grid-template-columns: 1fr; }
  .v-metrics { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .nav {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, 320px); z-index: 50;
    transform: translateX(110%); transition: transform .25s ease; height: 100dvh;
  }
  .nav.open { transform: none; }
  .nav-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(6,16,20,.45); z-index: 40;
  }
  .nav-backdrop.open { display: block; }
  .menu-btn { display: inline-flex; }
  .main { padding: 16px 14px calc(92px + var(--safe-b)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; inset: auto 0 0 0; z-index: 30;
    background: rgba(8, 38, 45, .96); color: #fff; padding: 8px 6px calc(8px + var(--safe-b));
    backdrop-filter: blur(16px);
  }
  .bottom-nav a { color: #c5dcdf; text-align: center; font-size: 11px; font-weight: 700; padding: 6px 4px; border-radius: 12px; }
  .bottom-nav a.active { color: #fff; background: rgba(255,255,255,.1); }
  .grid-2, .grid-3, .cards, .client-sheet { grid-template-columns: 1fr; }
  .v-metrics, .v-health { grid-template-columns: 1fr 1fr; }
  table { min-width: 0; }
  .clients-table { min-width: 640px; }
  .topbar .live-search { max-width: none; }
}
