:root {
  --bg: #f4f6f5; --panel: #fff; --ink: #1d2a2a; --muted: #687675; --line: #e1e7e5;
  --brand: #1f7a6d; --brand-ink: #fff; --brand-soft: #e3f1ee; --warn: #b7791f; --warn-soft: #fdf3e1;
  --bad: #c0392b; --bad-soft: #fbe9e7; --good: #2f855a; --good-soft: #e6f4ec;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #173f3a; color: #cfe3df; padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; color: #fff; font-weight: 650; line-height: 1.2; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: #2a9d8f; display: grid; place-items: center; font-size: 19px; flex: none; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #cfe3df; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.on { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav .ic { width: 18px; text-align: center; opacity: .9; }
.nav .badge { margin-left: auto; background: #e76f51; color: #fff; border-radius: 99px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.side .foot { margin-top: 18px; padding: 10px; font-size: 11px; color: #8fb2ac; line-height: 1.5; }
.main { min-width: 0; }
.top { display: flex; gap: 12px; align-items: center; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 14px; }
.search::before { content: "⌕"; position: absolute; left: 11px; top: 6px; font-size: 18px; color: var(--muted); }
.results { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.12); max-height: 420px; overflow: auto; }
.results a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.results a:hover, .results a.hl { background: var(--brand-soft); text-decoration: none; }
.demo-pill { font-size: 12px; background: var(--warn-soft); color: var(--warn); padding: 5px 10px; border-radius: 99px; white-space: nowrap; }
.page { padding: 22px 24px 60px; max-width: 1400px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* building blocks */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.tile { padding: 14px 16px; }
.tile .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font-size: 26px; font-weight: 680; margin-top: 4px; }
.tile a { display: block; color: inherit; } .tile a:hover { text-decoration: none; }
.tile.warn .v { color: var(--warn); } .tile.bad .v { color: var(--bad); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b9c6c3; text-decoration: none; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.pri:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f8fbfa; }
tbody tr:last-child td { border-bottom: none; }

.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #eef1f0; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); } .tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); } .tag.brand { background: var(--brand-soft); color: var(--brand); }
.alert { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 8px 12px; font-weight: 600; }
.note { background: var(--warn-soft); color: #7a5414; border-radius: 8px; padding: 10px 12px; }
.species { font-size: 15px; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd3ca; border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox] { width: auto; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink); font-weight: 400; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: none; background: none; padding: 9px 12px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* diary */
.diary { display: grid; position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.diary .colh { position: sticky; top: 0; background: #fff; z-index: 2; padding: 10px; font-weight: 600; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.diary .colh i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.diary .times { position: relative; }
.diary .times div { position: absolute; right: 8px; font-size: 11px; color: var(--muted); transform: translateY(-6px); }
.diary .col { position: relative; border-left: 1px solid var(--line); }
.diary .slot { position: absolute; left: 0; right: 0; border-top: 1px solid #f0f3f2; cursor: pointer; }
.diary .slot.hour { border-top-color: var(--line); }
.diary .slot:hover { background: var(--brand-soft); }
.diary .slot.closed { background: repeating-linear-gradient(45deg, #fafbfb, #fafbfb 6px, #f2f4f4 6px, #f2f4f4 12px); cursor: default; }
.appt { position: absolute; left: 4px; right: 4px; border-radius: 7px; padding: 4px 7px; font-size: 12px; overflow: hidden; cursor: pointer; border-left: 4px solid; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); z-index: 1; line-height: 1.3; }
.appt:hover { box-shadow: 0 2px 10px rgba(0,0,0,.18); z-index: 3; }
.appt b { font-weight: 650; }
.appt.done { opacity: .55; } .appt.no-show { opacity: .5; text-decoration: line-through; }
.appt .st { float: right; }
.nowline { position: absolute; left: 0; right: 0; border-top: 2px solid #e76f51; z-index: 2; pointer-events: none; }

/* today list */
.agenda .item { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); align-items: center; }
.agenda .item:last-child { border-bottom: none; }
.agenda .t { font-weight: 650; font-variant-numeric: tabular-nums; }
.agenda .who { min-width: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* timeline */
.tl .entry { border-left: 3px solid var(--brand-soft); padding: 2px 0 14px 14px; position: relative; }
.tl .entry::before { content: ""; position: absolute; left: -7px; top: 5px; width: 11px; height: 11px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.soap { display: grid; grid-template-columns: 22px 1fr; gap: 3px 8px; margin-top: 6px; }
.soap b { color: var(--brand); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,30,28,.45); display: grid; place-items: start center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal .mh { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .mb { padding: 18px 20px; }
.modal .mf { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #173f3a; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

.bars .b { display: grid; grid-template-columns: 150px 1fr 80px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13px; }
.bars .track { background: #eef2f1; border-radius: 4px; height: 12px; }
.bars .fill { background: var(--brand); height: 12px; border-radius: 4px; }
.sms { background: #e9f4f2; border-radius: 14px 14px 14px 4px; padding: 10px 12px; max-width: 420px; white-space: pre-wrap; }

.picker { position: relative; }
.picker .results { top: 40px; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: flex; overflow-x: auto; padding: 8px; gap: 4px; }
  .side .brand, .side .foot { display: none; }
  .nav { display: flex; gap: 2px; } .nav a { white-space: nowrap; }
  .g2, .g3, .g4, .g-side { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}

@media print {
  .side, .top, .no-print { display: none !important; }
  .shell { display: block; } .card { box-shadow: none; border: none; }
}
