:root {
  color-scheme: light;
  --bg: #f5f8f6;
  --surface: #ffffff;
  --surface-strong: #eef4f1;
  --text: #182321;
  --muted: #5e6f69;
  --line: #d9e4df;
  --primary: #096b72;
  --primary-strong: #07545a;
  --primary-soft: #e1f2f2;
  --accent: #9a5a18;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --success: #237a4d;
  --shadow: 0 16px 38px rgba(18, 35, 32, 0.12);
  --radius: 8px;
  --tap: 44px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(9, 107, 114, 0.08), transparent 220px),
    var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.15;
}

.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;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  place-items: center;
}

.login-panel {
  width: 300px;
  max-width: calc(100% - 36px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  font-size: 1.6rem;
}

.login-panel .brand-mark {
  width: 52px;
  height: 52px;
}

@media (min-width: 600px) {
  .login-panel {
    width: 430px;
  }

  .login-panel h1 {
    font-size: 1.8rem;
  }

  .login-panel .brand-mark {
    width: 58px;
    height: 58px;
  }
}

.brand-row,
.topbar-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
}

.topbar-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.subtle {
  color: var(--muted);
  font-size: 0.9rem;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.check-row span {
  color: #32433f;
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid #cbd8d2;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(9, 107, 114, 0.16);
}

.check-row {
  display: flex;
  min-height: var(--tap);
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--primary);
}

.button,
.icon-button,
.nav-button {
  min-height: var(--tap);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
}

.button.full {
  width: 100%;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.primary:active,
.button.primary:hover {
  background: var(--primary-strong);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--primary);
}

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

.message {
  min-height: 22px;
  color: var(--danger);
  font-size: 0.92rem;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(9px, env(safe-area-inset-top)) 14px 9px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.topbar-title {
  display: grid;
  gap: 1px;
}

.topbar-title strong {
  font-size: 1rem;
}

.topbar-title span {
  color: var(--muted);
  font-size: 0.78rem;
}

.icon-button {
  min-width: 76px;
  padding: 8px 10px;
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--primary);
  font-size: 0.82rem;
}

.workspace {
  width: min(100%, 1024px);
  margin: 0 auto;
}

.screen {
  display: none;
  padding: 16px 14px 24px;
}

.screen.active {
  display: block;
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.search-row {
  position: sticky;
  z-index: 8;
  top: 66px;
  padding: 0 0 12px;
  background: linear-gradient(180deg, var(--bg) 80%, rgba(245, 248, 246, 0));
}

.search-field input {
  min-height: 48px;
  border-color: var(--line);
  background: var(--surface);
}

.record-list {
  display: grid;
  gap: 10px;
}

.client-card,
.note-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.client-card,
.note-card {
  width: 100%;
  padding: 13px;
  text-align: left;
}

.client-card {
  display: grid;
  gap: 9px;
}

.client-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.client-card-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.client-name,
.note-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid #cbd8d2;
  border-radius: 999px;
  background: #f8faf8;
  color: #31423e;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 750;
}

.pill.follow-up {
  border-color: #e7c388;
  background: #fff7e8;
  color: #7a4715;
}

.pill.status {
  border-color: #b9d7cc;
  background: #eaf8f2;
  color: var(--success);
}

.empty-state {
  padding: 22px 16px;
  color: var(--muted);
  text-align: center;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.section-divider {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.wide {
  grid-column: 1 / -1;
}

.sticky-actions {
  margin: 8px 0 0;
  padding: 0;
}

.note-form {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.note-card {
  display: grid;
  gap: 8px;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.note-body {
  display: -webkit-box;
  overflow: hidden;
  color: #2b3a36;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.account-panel {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

dl div {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(14px);
}

.nav-button {
  display: grid;
  min-width: 0;
  min-height: 50px;
  place-items: center;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.77rem;
}

.nav-button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.toast {
  position: fixed;
  z-index: 30;
  right: 12px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 12px;
  display: none;
  max-width: 520px;
  margin: 0 auto;
  border-radius: var(--radius);
  background: #172622;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

@media (min-width: 720px) {
  .app-shell {
    padding-bottom: 0;
  }

  .topbar {
    padding-right: 24px;
    padding-left: 24px;
  }

  .workspace {
    padding: 0 8px;
  }

  .screen {
    padding: 22px 18px 34px;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sticky-actions {
    grid-column: 1 / -1;
  }

  .button.full {
    width: auto;
    min-width: 180px;
  }

  .bottom-nav {
    right: auto;
    bottom: auto;
    left: 50%;
    top: 8px;
    width: min(460px, 42vw);
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: 0 10px 24px rgba(18, 35, 32, 0.08);
  }

  .nav-button {
    min-height: 40px;
  }
}
