:root {
  --bg: #f6f4f0;
  --bg-deep: #efeae3;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --ink: #282e24;
  --muted: #6f746c;
  --line: #e4ddd3;
  --brand: #6f7d66;
  --brand-dark: #4f5b48;
  --brand-soft: #e8ebe4;
  --accent: #c79182;
  --accent-dark: #b37a6b;
  --accent-soft: #f6ebe7;
  --gold: #c2a46b;
  --gold-soft: #f4ecda;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --warning: #9a6700;
  --warning-soft: #fff4d6;
  --info: #5b7c99;
  --info-soft: #e8f0f6;
  --success: #4f6f52;
  --success-soft: #e7f0e8;
  --shadow: 0 18px 40px rgba(40, 46, 36, 0.08);
  --shadow-soft: 0 8px 24px rgba(40, 46, 36, 0.05);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Source Serif 4", Georgia, serif;
  --num: "Source Sans 3", "Segoe UI", sans-serif;
  --sidebar: #2a3228;
  --sidebar-2: #3a4437;
}

* { box-sizing: border-box; }
html {
  margin: 0;
  padding: 0;
  scrollbar-gutter: stable;
}
body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--accent-dark); }
h1, h2, h3 {
  font-family: var(--display);
  font-weight: 400;
  margin: 0 0 .45rem;
  letter-spacing: 0.01em;
  color: var(--ink);
}
p { margin-top: 0; color: var(--muted); line-height: 1.55; }

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  align-items: start;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #f4f1ea;
  padding: 1.35rem 1rem 1.15rem;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  border-right: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: column;
  align-self: start;
  overflow: hidden;
}

.brand {
  display: block;
  padding: .65rem .85rem 1.1rem;
  font-family: var(--display);
  font-size: 1.5rem;
  color: #fff;
  line-height: 1.15;
  flex: 0 0 auto;
}
.brand small {
  display: block;
  margin-top: .4rem;
  font-family: var(--font);
  font-size: .72rem;
  opacity: .78;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #e7d7b3;
}

.nav-link {
  display: block;
  padding: .58rem .85rem;
  border-radius: 12px;
  color: rgba(255,255,255,.84);
  margin-bottom: .2rem;
  transition: background .15s ease, color .15s ease;
  font-weight: 500;
  font-size: .94rem;
  line-height: 1.3;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}

.sidebar nav {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  margin-bottom: .7rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar nav::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.sidebar-footer {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 1rem .85rem 0;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .92rem;
}
.sidebar-footer .btn {
  padding: .55rem 1rem;
  font-size: .88rem;
}

.main {
  padding: 1.75rem 2rem 2.75rem;
  min-width: 0;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.4rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid rgba(228, 221, 211, .9);
}
.topbar h1 {
  margin: 0;
  font-size: clamp(1.9rem, 2.4vw, 2.35rem);
}
.topbar p {
  margin: .35rem 0 0;
  max-width: 42rem;
}

.grid { display: grid; gap: 1.1rem; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat, .panel {
  background: var(--surface-solid);
  border: 1px solid rgba(228, 221, 211, .95);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.stat {
  padding: 1.25rem 1.3rem;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(194,164,107,.18), transparent 70%);
}
.stat .label {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.stat .value {
  font-family: var(--num);
  font-variant-numeric: lining-nums tabular-nums;
  font-size: 2.1rem;
  font-weight: 700;
  margin-top: .4rem;
  color: var(--ink);
}

.panel { padding: 1.35rem 1.4rem; }
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel-header h2 { font-size: 1.35rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 0;
  border-radius: 999px;
  padding: .78rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, box-shadow .15s ease;
}
.btn:hover { box-shadow: var(--shadow-soft); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #d3a294 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(199, 145, 130, .28);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-dark), #c79182); color: #fff; }
.btn-secondary {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: .48rem .85rem; font-size: .86rem; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: .95rem .65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
}
tr:hover td { background: rgba(246, 244, 240, .75); }
.muted { color: var(--muted); }
.contact-link {
  color: #3a4437;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: .15em;
  word-break: break-word;
}
.contact-link:hover { color: #b37a6b; }
.muted .contact-link { color: inherit; font-weight: 600; }
.overdue { color: var(--danger); font-weight: 700; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: .28rem .65rem;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 700;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #eef0ec; color: #5f655c; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.05rem 1.15rem;
}
.form-grid .full { grid-column: 1 / -1; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: .45rem;
  font-size: .9rem;
  color: #3a4036;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #ddd5c9;
  border-radius: var(--radius-sm);
  padding: .82rem .95rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #b7c0ae;
  box-shadow: 0 0 0 4px rgba(111, 125, 102, .14);
}
textarea { min-height: 120px; resize: vertical; }
.actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-top: .25rem;
}
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  margin-bottom: 1.1rem;
  padding: 1rem;
  background: rgba(255,255,255,.55);
  border: 1px solid var(--line);
  border-radius: 16px;
  align-items: stretch;
}
.filters > .btn {
  align-self: stretch;
  min-height: 46px;
}
.filters-compact {
  grid-template-columns: 1fr auto;
}

.desktop-only { display: block !important; }
.mobile-only { display: none !important; }
.desktop-only.table-wrap { display: block !important; }
.mobile-only.m-card-list { display: none !important; }

.m-card-list {
  display: grid;
  gap: .75rem;
}
.m-card {
  display: block;
  background: #faf8f4;
  border: 1px solid #ddd6cb;
  border-radius: 14px;
  padding: .95rem 1rem;
  color: inherit;
}
a.m-card:hover {
  border-color: #4f5b48;
  color: inherit;
  background: #fff;
}
.m-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .65rem;
  margin-bottom: .55rem;
}
.m-card-top strong {
  font-size: 1.02rem;
  color: var(--ink);
  line-height: 1.3;
}
.m-card-meta {
  display: grid;
  gap: .35rem;
  margin: .55rem 0 .75rem;
}
.m-card-meta div {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  font-size: .88rem;
}
.m-card-meta span {
  color: var(--muted);
  font-weight: 600;
  flex: 0 0 auto;
}
.m-card-meta b {
  color: var(--ink);
  font-weight: 600;
  text-align: right;
}
.m-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.m-card-actions .btn {
  flex: 1 1 auto;
  min-height: 42px;
}
.m-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .35rem;
}
.m-tag {
  display: inline-flex;
  padding: .28rem .55rem;
  border-radius: 999px;
  background: #e8ebe4;
  color: #4f5b48;
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.2;
}

.alert {
  padding: .95rem 1.05rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  font-weight: 600;
}
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(194,164,107,.22), transparent 30%),
    linear-gradient(145deg, #2a3228 0%, #3f4a3b 45%, #5a4a43 100%);
}
.auth-card {
  width: min(440px, 100%);
  background: rgba(255,255,255,.97);
  border-radius: 28px;
  padding: 2.2rem;
  box-shadow: 0 30px 70px rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.4);
}
.auth-card h1 {
  font-size: 2.15rem;
  margin-bottom: .35rem;
}
.auth-card .field { margin-bottom: 1rem; }
.auth-meta {
  margin-top: 1.1rem;
  font-size: .88rem;
  color: var(--muted);
  padding-top: .9rem;
  border-top: 1px solid var(--line);
}

.list-item {
  padding: .95rem 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item strong { display: block; margin-bottom: .25rem; }
.empty { padding: 1rem 0; color: var(--muted); }

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.1rem;
}
.meta-list { display: grid; gap: .8rem; }
.meta-list div {
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--line);
}
.meta-list span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: .25rem;
  font-weight: 700;
}

.field-hint {
  display: block;
  margin-top: .35rem;
  font-size: .8rem;
  color: var(--muted);
}
input.is-locked,
textarea.is-locked,
select.is-locked {
  background: #f3f4f6;
  color: #374151;
  cursor: not-allowed;
  border-style: dashed;
}
.city-other { display: none; margin-top: .65rem; }
.city-other.is-visible { display: block; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: .55rem;
}
.calendar-dow {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: .35rem .4rem;
}
.calendar-day {
  min-height: 118px;
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .55rem;
}
.calendar-day.is-empty {
  background: transparent;
  border-color: transparent;
}
.calendar-day.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(199, 145, 130, .16);
}
.calendar-day-num {
  font-family: var(--display);
  font-size: 1.05rem;
  margin-bottom: .4rem;
}
.calendar-events { display: grid; gap: .28rem; }
.cal-event {
  display: block;
  font-size: .72rem;
  line-height: 1.25;
  padding: .28rem .4rem;
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #2f342c;
  background: #eef1ea;
}
.cal-event.visit { background: #e7f0e8; }
.cal-event.reminder { background: var(--gold-soft); }
.cal-event.task { background: var(--info-soft); }
.cal-event.activity { background: #ebe7f2; }
.cal-event.followup { background: var(--accent-soft); }
.cal-event.overdue { background: var(--danger-soft); color: var(--danger); }
.cal-more { font-size: .72rem; color: var(--muted); padding-left: .2rem; }
.cal-legend { display: flex; flex-wrap: wrap; gap: .4rem; }
.cal-pill {
  display: inline-flex;
  align-items: center;
  padding: .22rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: #eef1ea;
}
.cal-pill.visit { background: #e7f0e8; color: var(--success); }
.cal-pill.reminder { background: var(--gold-soft); color: #7a6230; }
.cal-pill.task { background: var(--info-soft); color: var(--info); }
.cal-pill.activity { background: #ebe7f2; color: #5b4d78; }
.cal-pill.followup { background: var(--accent-soft); color: var(--accent-dark); }
.cal-pill.overdue { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 1100px) {
  .grid-4, .grid-3, .detail-grid { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
}
.urgency-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-radius: 16px;
  margin-bottom: 1.1rem;
  border: 1px solid transparent;
  box-shadow: var(--shadow-soft);
}
.urgency-banner strong {
  display: block;
  font-size: 1.05rem;
  margin-bottom: .2rem;
}
.urgency-banner span { color: inherit; opacity: .9; font-size: .92rem; }
.urgency-banner.is-danger {
  background: linear-gradient(135deg, #fde8e6, #fff5f4);
  border-color: #f0b4ae;
  color: #8f1d16;
}
.urgency-banner.is-warning {
  background: linear-gradient(135deg, #fff4d6, #fffaf0);
  border-color: #ecd089;
  color: #7a5200;
}
.urgency-banner.is-success {
  background: linear-gradient(135deg, #e7f0e8, #f4faf5);
  border-color: #b9d4be;
  color: #2f5534;
}
.urgency-banner.is-info {
  background: linear-gradient(135deg, #e8f0f6, #f5f9fc);
  border-color: #bfd0e0;
  color: #2a4154;
}
.view-notes {
  background: #f7f4ee;
  border: 1px solid #ddd6cb;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  line-height: 1.55;
  color: var(--ink);
}

.stat-urgent {
  border-color: #f0b4ae;
  background: linear-gradient(180deg, #fff7f6, #fff);
}
.stat-urgent .value { color: var(--danger); }
.stat-urgent::after { background: radial-gradient(circle, rgba(180,35,24,.16), transparent 70%); }

.stat-warning {
  border-color: #ecd089;
  background: linear-gradient(180deg, #fffaf0, #fff);
}
.stat-warning .value { color: var(--warning); }
.stat-warning::after { background: radial-gradient(circle, rgba(154,103,0,.16), transparent 70%); }

.stat-info {
  border-color: #bfd0e0;
  background: linear-gradient(180deg, #f3f8fc, #fff);
}
.stat-info .value { color: var(--info); }
.stat-info::after { background: radial-gradient(circle, rgba(91,124,153,.16), transparent 70%); }

.alert-card {
  display: block;
  padding: .95rem 1rem;
  border-radius: 14px;
  margin-bottom: .65rem;
  border: 1px solid var(--line);
  background: #fff;
  transition: box-shadow .15s ease, border-color .15s ease;
  color: inherit;
}
.alert-card:hover {
  box-shadow: var(--shadow-soft);
  border-color: #d5cabb;
  color: inherit;
}
.alert-card strong {
  display: block;
  margin: .35rem 0 .2rem;
  color: var(--ink);
}
.alert-card > span:last-child {
  display: block;
  color: var(--muted);
  font-size: .9rem;
}
.alert-card-tag {
  display: inline-flex;
  align-items: center;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.alert-card.is-danger {
  background: linear-gradient(90deg, rgba(180,35,24,.08), #fff 42%);
  border-color: #f0b4ae;
  box-shadow: inset 4px 0 0 var(--danger);
}
.alert-card.is-danger .alert-card-tag { background: var(--danger-soft); color: var(--danger); }
.alert-card.is-warning {
  background: linear-gradient(90deg, rgba(154,103,0,.08), #fff 42%);
  border-color: #ecd089;
  box-shadow: inset 4px 0 0 var(--warning);
}
.alert-card.is-warning .alert-card-tag { background: var(--warning-soft); color: var(--warning); }
.alert-card.is-info {
  background: linear-gradient(90deg, rgba(91,124,153,.08), #fff 42%);
  border-color: #bfd0e0;
  box-shadow: inset 4px 0 0 var(--info);
}
.alert-card.is-info .alert-card-tag { background: var(--info-soft); color: var(--info); }

.panel.tone-danger { border-color: #f0b4ae; box-shadow: inset 0 3px 0 var(--danger); }
.panel.tone-warning { border-color: #ecd089; box-shadow: inset 0 3px 0 var(--warning); }
.panel.tone-info { border-color: #bfd0e0; box-shadow: inset 0 3px 0 var(--info); }

/* Dashboard — sectioned (restored) */
.dash-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.35rem;
  padding: 1.15rem 1.25rem;
  border-radius: 16px;
  background: #2a3228;
  color: #fff;
  border: 1px solid #1f261d;
}
.dash-kicker {
  margin: 0 0 .25rem;
  color: #e7d7b3;
  font-size: .74rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
}
.dash-top h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.2vw, 2rem);
  color: #fff;
}
.dash-top p {
  margin: .35rem 0 0;
  font-size: .92rem;
  color: rgba(255,255,255,.82);
}
.dash-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: flex-end;
}
.dash-top-actions .btn-secondary {
  background: rgba(255,255,255,.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
}
.dash-top-actions .btn-secondary:hover {
  background: rgba(255,255,255,.22);
  color: #fff;
}

.dash-block {
  background: #fff;
  border: 1px solid #cfc7ba;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(40, 46, 36, 0.08);
  margin-bottom: 1.35rem;
}
.dash-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: #3a4437;
  border-bottom: 3px solid #c2a46b;
}
.dash-block-head h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #fff;
}
.dash-block-head span {
  color: rgba(255,255,255,.78);
  font-size: .86rem;
  font-weight: 600;
}
.dash-block-head a {
  color: #e7d7b3;
  font-size: .88rem;
  font-weight: 700;
  white-space: nowrap;
}
.dash-block-head a:hover { color: #fff; }
.dash-block-body {
  padding: 1.2rem 1.25rem 1.3rem;
  background: #fff;
}

.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .8rem;
}
.dash-kpi-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dash-list { display: grid; gap: .35rem; }
.dash-kpi {
  background: #fff;
  border: 2px solid #d8d0c4;
  border-radius: 14px;
  padding: 1.05rem 1.1rem;
}
.dash-kpi small {
  display: block;
  margin-top: .4rem;
  color: #4f5b48;
  font-size: .78rem;
  line-height: 1.35;
  font-weight: 500;
}
.dash-kpi-label {
  display: block;
  color: #4f5b48;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: .45rem;
}
.dash-kpi strong,
.cold-pill b,
.occ-summary b,
.stat .value {
  font-family: var(--num);
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.dash-kpi strong {
  display: block;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  color: #1f261d;
}
.dash-kpi.is-danger {
  border-color: #b42318;
  background: #fdecea;
}
.dash-kpi.is-danger .dash-kpi-label,
.dash-kpi.is-danger strong { color: #8f1d14; }
.dash-kpi.is-warning {
  border-color: #9a6700;
  background: #fff3d6;
}
.dash-kpi.is-warning .dash-kpi-label,
.dash-kpi.is-warning strong { color: #7a5200; }

.cold-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
}
.cold-pill {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: 1.05rem 1.1rem;
  border-radius: 14px;
  border: 2px solid #d8d0c4;
  background: #fff;
  color: inherit;
}
.cold-pill:hover { color: inherit; border-color: #3a4437; }
.cold-pill span {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .45rem .6rem;
  border-radius: 10px;
  text-align: center;
  min-width: 70px;
  color: #fff;
  background: #3a4437;
}
.cold-pill b {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  color: #1f261d;
  margin-right: .2rem;
}
.cold-pill small {
  color: #4f5b48;
  font-size: .86rem;
  font-weight: 600;
}
.cold-pill.is-info {
  border-color: #3d5a73;
  background: #eef4f8;
}
.cold-pill.is-info span { background: #3d5a73; }
.cold-pill.is-info b { color: #2a4154; }
.cold-pill.is-warning {
  border-color: #9a6700;
  background: #fff3d6;
}
.cold-pill.is-warning span { background: #9a6700; }
.cold-pill.is-warning b { color: #7a5200; }
.cold-pill.is-danger {
  border-color: #b42318;
  background: #fdecea;
}
.cold-pill.is-danger span { background: #b42318; }
.cold-pill.is-danger b { color: #8f1d14; }

.dash-equal {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .9rem;
  align-items: stretch;
}
.dash-equal-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-panel {
  padding: 1rem 1.05rem;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  margin: 0;
  box-shadow: none;
  background: #f3f1ec;
  border: 1px solid #d8d0c4;
}
.dash-panel .panel-header {
  margin-bottom: .7rem;
  flex: 0 0 auto;
  padding-bottom: .55rem;
  border-bottom: 2px solid #cfc7ba;
}
.dash-panel .panel-header h3 {
  margin: 0;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 700;
  color: #1f261d;
}
.dash-panel .panel-header a {
  color: #3a4437;
  font-weight: 700;
}
.dash-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.dash-row {
  display: block;
  padding: .75rem .8rem;
  border-radius: 10px;
  border: 1px solid #d8d0c4;
  margin-bottom: .4rem;
  background: #fff;
  color: inherit;
}
.dash-row:hover {
  border-color: #3a4437;
  color: inherit;
}
.dash-row.static { cursor: default; }
.dash-row.static:hover { border-color: #d8d0c4; }
.dash-row strong {
  display: block;
  margin-bottom: .15rem;
  color: #1f261d;
  font-size: .95rem;
  font-weight: 700;
}
.dash-row small {
  display: block;
  color: #4f5b48;
  font-size: .8rem;
  font-weight: 500;
}
.dash-row.is-danger {
  background: #fdecea;
  border-color: #b42318;
  border-left-width: 5px;
}
.dash-row.is-warning {
  background: #fff3d6;
  border-color: #9a6700;
  border-left-width: 5px;
}
.dash-row.is-info {
  background: #eef4f8;
  border-color: #3d5a73;
  border-left-width: 5px;
}

.dash-empty {
  flex: 1;
  display: flex;
  align-items: center;
  padding: .95rem;
  min-height: 90px;
  border-radius: 10px;
  background: #fff;
  border: 2px dashed #b9b1a4;
}
.dash-empty p {
  margin: 0;
  color: #4f5b48;
  font-size: .92rem;
  font-weight: 600;
}

.home-occ-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .85rem;
}
.occ-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .7rem;
  margin-bottom: 1rem;
}
.occ-summary div {
  background: #3a4437;
  border: 1px solid #2a3228;
  border-radius: 12px;
  padding: .85rem .55rem;
  text-align: center;
  color: #fff;
}
.occ-summary b {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: #fff;
}
.occ-summary span {
  display: block;
  margin-top: .2rem;
  font-size: .7rem;
  color: #e7d7b3;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
}
.home-occ {
  margin: 0;
  padding: .95rem 1rem;
  border-radius: 12px;
  background: #fff;
  border: 2px solid #d8d0c4;
}
.home-occ-head {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .45rem;
}
.home-occ-head strong { color: #1f261d; font-size: .98rem; }
.home-occ-head span { color: #4f5b48; font-size: .82rem; font-weight: 600; }
.home-occ small { color: #4f5b48; font-size: .8rem; font-weight: 600; }
.stack-bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #d8d0c4;
  margin-bottom: .4rem;
}
.stack-bar i { display: block; height: 100%; }
.stack-bar .occ { background: #3a4437; }
.stack-bar .hold { background: #b0892e; }
.stack-bar .free { background: #b37a6b; }

.mobile-bar,
.mobile-tabbar,
.drawer-close {
  display: none;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30, 34, 28, .5);
  z-index: 45;
}
.sidebar-drawer-head {
  display: block;
}
.drawer-close {
  border: 0;
  background: rgba(255,255,255,.12);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.1rem;
  cursor: pointer;
}

@media (max-width: 1200px) {
  .dash-kpi-grid,
  .dash-kpi-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-equal { grid-template-columns: 1fr; }
  .dash-equal-2 { grid-template-columns: 1fr 1fr; }
  .home-occ-grid, .cold-strip { grid-template-columns: 1fr; }
  .occ-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  html, body {
    overscroll-behavior-y: none;
  }
  body {
    background: #efeae3;
  }
  body.nav-open {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }

  .mobile-bar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 40;
    align-items: center;
    justify-content: space-between;
    gap: .65rem;
    padding: .7rem .9rem;
    padding-top: calc(.7rem + env(safe-area-inset-top, 0px));
    background: #2a3228;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .mobile-bar-title {
    flex: 1;
    min-width: 0;
    text-align: center;
  }
  .mobile-bar-title strong {
    display: block;
    font-family: var(--display);
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.1;
  }
  .mobile-bar-title span {
    display: block;
    margin-top: .15rem;
    font-size: .74rem;
    color: rgba(255,255,255,.72);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .menu-toggle,
  .mobile-bar-action {
    border: 0;
    background: rgba(255,255,255,.12);
    color: #fff;
    border-radius: 12px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    flex: 0 0 auto;
  }
  .mobile-bar-action:hover { color: #fff; }

  .sidebar-drawer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
  }
  .drawer-close { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar .brand { padding-right: .25rem; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 88vw);
    height: 100dvh;
    max-height: 100dvh;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform .22s ease;
    overflow: hidden;
    min-height: 0;
    align-self: auto;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 12px 0 40px rgba(0,0,0,.28);
  }
  .sidebar nav {
    overflow-y: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-backdrop { display: block; }

  .main {
    padding: .85rem .85rem calc(5.6rem + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: 100%;
  }

  .mobile-tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 42;
    background: rgba(42, 50, 40, .97);
    border-top: 1px solid rgba(255,255,255,.1);
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 24px rgba(40, 46, 36, .18);
  }
  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    min-height: 52px;
    border: 0;
    background: transparent;
    color: rgba(255,255,255,.68);
    font-family: inherit;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-decoration: none;
    cursor: pointer;
    border-radius: 12px;
    padding: .25rem .15rem;
  }
  .tab-item:hover { color: #fff; }
  .tab-item.active {
    color: #e7d7b3;
    background: rgba(255,255,255,.08);
  }
  .tab-icon {
    font-size: 1.05rem;
    line-height: 1;
    font-weight: 700;
  }

  .grid-4, .grid-3, .grid-2, .detail-grid, .form-grid, .filters {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: .75rem;
    margin-bottom: 1rem;
    padding-bottom: .85rem;
  }
  .topbar h1 { font-size: 1.55rem; }
  .topbar .btn,
  .topbar > a.btn {
    width: 100%;
  }
  .topbar .actions {
    width: 100%;
    margin: 0;
  }
  .topbar .actions .btn { flex: 1 1 auto; }

  .panel {
    border-radius: 16px;
    padding: 1rem;
  }
  .panel-header {
    flex-wrap: wrap;
    gap: .5rem;
  }

  .desktop-only,
  .desktop-only.table-wrap { display: none !important; }
  .mobile-only { display: block !important; }
  .mobile-only.m-card-list { display: grid !important; }

  .filters {
    padding: .85rem;
    gap: .65rem;
    border-radius: 14px;
    grid-template-columns: 1fr !important;
  }
  .filters-compact {
    grid-template-columns: 1fr !important;
  }
  .filters .btn { width: 100%; min-height: 46px; }
  .filters > div:empty { display: none; }

  .panel > .table-wrap + .m-card-list,
  .panel > .m-card-list {
    margin-top: 0;
  }
  .panel {
    min-height: 0;
  }
  .m-card {
    background: #fff;
    padding: 1rem 1.05rem;
  }
  .m-card-top strong {
    font-size: 1.08rem;
  }
  .m-card-meta div {
    font-size: .95rem;
    padding: .2rem 0;
  }
  .m-card-meta span {
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
  }
  .m-tag {
    font-size: .84rem;
    padding: .32rem .6rem;
  }
  .grid-4 .stat,
  .stat {
    border-radius: 14px;
  }
  .badge {
    font-size: .78rem;
    padding: .28rem .55rem;
  }
  .empty {
    padding: 1.25rem .25rem;
    font-size: .98rem;
  }

  input, select, textarea {
    font-size: 16px; /* prevents iOS zoom */
    min-height: 48px;
    border-radius: 14px;
  }
  textarea { min-height: 130px; }
  .actions {
    flex-direction: column;
  }
  .actions .btn {
    width: 100%;
    min-height: 48px;
  }
  .btn {
    min-height: 46px;
    border-radius: 14px;
  }

  .table-wrap {
    margin: 0 -.15rem;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
  }
  table {
    min-width: 640px;
  }
  th, td {
    padding: .8rem .55rem;
    font-size: .9rem;
  }

  .list-item {
    padding: .85rem .15rem;
  }

  .calendar-grid { grid-template-columns: 1fr; }
  .calendar-dow { display: none; }
  .calendar-day.is-empty { display: none; }
  .calendar-day {
    min-height: auto;
    padding: .75rem;
  }

  .urgency-banner { flex-direction: column; align-items: flex-start; }

  .dash-top {
    flex-direction: column;
    align-items: flex-start;
    border-radius: 16px;
    padding: 1rem;
  }
  .dash-top h1 { font-size: 1.45rem; }
  .dash-top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: .55rem;
  }
  .dash-top-actions .btn { width: 100%; }
  .dash-block {
    border-radius: 16px;
    margin-bottom: 1rem;
  }
  .dash-block-head {
    flex-direction: column;
    align-items: flex-start;
    gap: .35rem;
    padding: .9rem 1rem;
  }
  .dash-block-body { padding: .9rem; }
  .dash-kpi-grid,
  .dash-kpi-4,
  .dash-equal,
  .dash-equal-2,
  .cold-strip,
  .home-occ-grid,
  .occ-summary {
    grid-template-columns: 1fr;
  }
  .dash-kpi {
    padding: .95rem 1rem;
  }
  .dash-kpi strong { font-size: 2rem; }
  .dash-panel { min-height: 0; }
  .cold-pill {
    width: 100%;
  }
  .nav-link, .dash-row, .cold-pill, .tab-item {
    min-height: 44px;
  }

  .auth-page {
    padding: 1.25rem .85rem;
    min-height: 100dvh;
  }
  .auth-card {
    width: 100%;
    max-width: 100%;
    border-radius: 18px;
    padding: 1.35rem 1.15rem;
  }
}

@media (max-width: 560px) {
  .stat .value { font-size: 1.7rem; }
  .dash-block-head h2 { font-size: 1.12rem; }
}

.is-hidden { display: none !important; }

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: .35rem;
}
.choice-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .45rem .9rem;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}
.choice-pill input { margin: 0; }

.note-compose textarea {
  min-height: 88px;
}
.note-timeline {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: 1rem;
}
.note-entry {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .85rem 1rem;
  background: rgba(255,255,255,.88);
}
.note-entry header {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  align-items: baseline;
  margin-bottom: .35rem;
}
.note-entry time {
  color: var(--muted);
  font-size: .85rem;
  white-space: nowrap;
}
.note-meta {
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: .45rem;
}
.note-body {
  white-space: pre-wrap;
  line-height: 1.45;
}
