/* CoolCare - mobile first. Small screens are the default; wider screens are added below. */
:root {
  --ink: #12263f; --muted: #5a6b82; --line: #d9e3f0; --bg: #f2f7fd; --card: #fff;
  --blue: #1556b8; --blue-dark: #0e3f8a; --blue-soft: #e6f0fd; --bar: #2a78d6;
  --good: #0b6b3a; --good-bg: #e2f5ea; --warn: #8a5200; --warn-bg: #fff2d9; --bad: #a8231d; --bad-bg: #fde8e6;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5;
  font: 16px/1.5 system-ui, "Segoe UI", "Nirmala UI", "Noto Sans Devanagari", "Noto Sans Gujarati", Roboto, sans-serif;
}
a { color: var(--blue); }
h1 { font-size: 1.4rem; margin: 0 0 1rem; line-height: 1.25; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; overflow-wrap: anywhere; }
.icon { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 3px solid #7fb1f5; outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px; z-index: 99; }

/* --- Frame --- */
.banner { background: #fff2d9; color: #6b4200; text-align: center; font-size: .8rem; font-weight: 600; padding: 6px 12px; }
.top { position: sticky; top: 0; z-index: 20; background: var(--blue); color: #fff; display: flex; align-items: center; gap: 8px; padding: 6px 12px; min-height: 56px; }
.top .brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; gap: 8px; align-items: center; margin-right: auto; }
.top .brand img { width: 30px; height: 30px; }
.top a.iconbtn, .top button.iconbtn { color: #fff; background: none; border: 0; min-width: 44px; min-height: 44px; display: grid; place-items: center; position: relative; border-radius: 10px; cursor: pointer; padding: 0; }
.top .iconbtn:hover { background: rgba(255,255,255,.15); }
.top select { background: var(--blue-dark); color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 8px; min-height: 40px; padding: 0 6px; font: inherit; font-size: .875rem; width: auto; }
.count { background: #c62828; color: #fff; border-radius: 99px; font-size: .7rem; font-weight: 700; padding: 0 6px; min-width: 18px; text-align: center; }
.iconbtn .count { position: absolute; top: 3px; right: 1px; }
.side { display: none; background: #fff; border-right: 1px solid var(--line); padding: 12px; }
.side.open { display: block; position: fixed; inset: 56px 0 0 0; z-index: 30; overflow: auto; }
.side a, .side button { display: flex; gap: 12px; align-items: center; padding: 10px 12px; min-height: 48px; border-radius: 10px; color: var(--ink); text-decoration: none; width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.side a:hover, .side button:hover { background: var(--bg); }
.side a.active { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }
.side .who { padding: 4px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.side .count { margin-left: auto; }
main { padding: 16px 16px 110px; max-width: 1180px; margin: 0 auto; min-width: 0; }
.bottom { position: fixed; inset: auto 0 0 0; z-index: 20; background: #fff; border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.bottom a { flex: 1; min-width: 0; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .72rem; }
.bottom a.active { color: var(--blue); font-weight: 700; }
@media (min-width: 960px) {
  .frame { display: grid; grid-template-columns: 230px minmax(0, 1fr); }
  .side { display: block; position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto; }
  .bottom, .menubtn { display: none !important; }
  main { padding: 24px 28px 60px; width: 100%; }
  h1 { font-size: 1.6rem; }
}

/* --- Pieces --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; min-width: 0; }
.card.link { display: block; color: inherit; text-decoration: none; }
.card.link:hover { border-color: #9dbfea; }
.narrow { max-width: 560px; margin-inline: auto; }
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid2, .grid3 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-bottom: 16px; }
.grid2 > .card, .grid3 > .card { margin: 0; }
@media (min-width: 760px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: inherit; text-decoration: none; }
.tile b { display: block; font-size: 1.5rem; line-height: 1.2; }
.tile span { color: var(--muted); font-size: .85rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 18px; border-radius: 10px; border: 1px solid var(--blue); background: var(--blue); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--blue-dark); }
.btn.light { background: #fff; color: var(--blue); }
.btn.light:hover { background: var(--blue-soft); }
.btn.danger { background: #fff; color: var(--bad); border-color: #e2a6a2; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { min-height: 40px; padding: 4px 12px; font-size: .9rem; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .55; cursor: wait; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.msg { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; background: var(--blue-soft); color: var(--blue-dark); overflow-wrap: anywhere; }
.msg.success { background: var(--good-bg); color: var(--good); }
.msg.error { background: var(--bad-bg); color: var(--bad); }
.msg.warning { background: var(--warn-bg); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; }
.demo { border: 2px dashed #e0a43a; background: var(--warn-bg); color: #5d3900; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: #e9eef5; color: #3c4b60; white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.b-requested, .b-pending, .b-callback { background: var(--warn-bg); color: var(--warn); }
.b-quoted { background: #efe8fc; color: #56309b; }
.b-scheduled, .b-contact { background: var(--blue-soft); color: var(--blue-dark); }
.b-on_the_way { background: #dff3f7; color: #0b5c6d; }
.b-in_progress { background: #ffe9dc; color: #93410b; }
.b-completed, .b-approved, .b-active { background: var(--good-bg); color: var(--good); }
.b-paid { background: #0b6b3a; color: #fff; }
.b-rejected, .b-inactive, .b-escalation, .b-flag { background: var(--bad-bg); color: var(--bad); }

/* --- Forms --- */
.field { margin-bottom: 14px; }
label, .label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .95rem; }
input, select, textarea { width: 100%; min-height: 46px; padding: 9px 12px; border: 1px solid #b7c6da; border-radius: 10px; font: inherit; color: inherit; background: #fff; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; accent-color: var(--blue); flex: none; margin: 0; }
textarea { resize: vertical; }
.help { color: var(--muted); font-size: .85rem; margin-top: 3px; }
.help ul { margin: 0; padding-left: 18px; }
.errorlist { color: var(--bad); list-style: none; margin: 4px 0 0; padding: 0; font-size: .9rem; font-weight: 600; }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--bad); }
.checks div, .field > div[id] > div { margin: 0; }
.field > div[id] label { font-weight: 400; display: flex; gap: 10px; align-items: center; min-height: 44px; margin: 0; }
.filters { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
.filters label { font-size: .8rem; color: var(--muted); }
.filters .wide { grid-column: 1 / -1; }
@media (min-width: 760px) { .filters { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); align-items: end; } .filters .wide { grid-column: auto; } }
.stars-input { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.stars-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars-input label { font-size: 2.2rem; line-height: 1; min-width: 44px; text-align: center; color: #b9c4d3; cursor: pointer; margin: 0; }
.stars-input label:hover, .stars-input label:hover ~ label, .stars-input input:checked ~ label { color: #e09a00; }
.stars-input input:focus-visible + label { outline: 3px solid #7fb1f5; border-radius: 8px; }
.stars { color: #b87900; letter-spacing: 1px; white-space: nowrap; }

/* --- Tables: cards on phones --- */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 759px) {
  table.cards thead { display: none; }
  table.cards tr { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 12px; background: #fff; }
  table.cards td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 0; text-align: right; overflow-wrap: anywhere; }
  table.cards td::before { content: attr(data-l); color: var(--muted); font-size: .85rem; text-align: left; flex: none; }
  table.cards td:empty { display: none; }
  .card > table.cards, .card > .scroll > table.cards { margin: 0; }
}
dl.facts { margin: 0; display: grid; grid-template-columns: minmax(100px, auto) minmax(0, 1fr); gap: 6px 14px; }
dl.facts dt { color: var(--muted); font-size: .9rem; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 8px 0 16px; }

/* --- Timeline --- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 34px; color: var(--muted); }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 3px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #b7c6da; background: #fff; z-index: 1; }
.timeline li::after { content: ""; position: absolute; left: 11px; top: 14px; bottom: -6px; width: 2px; background: #d0dbe9; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline .done, .timeline .now { color: var(--ink); }
.timeline .done::before { background: var(--blue); border-color: var(--blue); }
.timeline .now { font-weight: 700; }
.timeline .now::before { border: 5px solid var(--blue); }
.timeline time { display: block; font-size: .82rem; color: var(--muted); font-weight: 400; }

/* --- Charts: one colour, value printed at each bar --- */
.bars { display: grid; gap: 8px; }
.bars .b { display: grid; grid-template-columns: minmax(0, 8.5rem) minmax(0, 1fr); gap: 10px; align-items: center; font-size: .9rem; border-radius: 6px; }
.bars .b:hover { background: var(--bg); }
.bars .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .track { display: flex; align-items: center; gap: 8px; border-left: 1px solid #b7c6da; min-width: 0; padding-right: 4.5rem; }
.bars .fill { display: block; height: 16px; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; flex: none; max-width: 100%; }
.bars .val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols { display: flex; align-items: flex-end; gap: 16px; height: 190px; border-bottom: 1px solid #b7c6da; }
.cols .c { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.cols .fill { width: 24px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 2px; }
.cols .val { font-size: .85rem; white-space: nowrap; }
.colnames { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); padding-top: 4px; }
.colnames span { flex: 1; text-align: center; }

/* --- Calendar --- */
.cal { min-width: 900px; table-layout: fixed; }
.cal th:first-child, .cal td:first-child { width: 130px; position: sticky; left: 0; background: #fff; z-index: 1; }
.cal td { border: 1px solid var(--line); padding: 5px; }
.cal .today { background: var(--blue-soft); }
.cal a.job { display: block; padding: 5px 7px; border-radius: 8px; font-size: .78rem; text-decoration: none; margin-bottom: 5px; line-height: 1.35; overflow-wrap: anywhere; border-left: 4px solid currentColor; }

/* --- Chat --- */
.chatbtn { position: fixed; right: 16px; bottom: 76px; z-index: 25; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 14px rgba(14,63,138,.35); }
.chatbox { position: fixed; inset: 0; z-index: 40; background: #fff; display: flex; flex-direction: column; }
.chatbox[hidden] { display: none; }
.chatbox header { background: var(--blue); color: #fff; padding: 8px 8px 8px 16px; display: flex; align-items: center; justify-content: space-between; }
.chatbox header button { background: none; border: 0; color: #fff; font-size: 1.7rem; min-width: 44px; min-height: 44px; cursor: pointer; line-height: 1; }
.chatlog { flex: 1; overflow: auto; padding: 14px; background: var(--bg); display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 85%; padding: 9px 13px; border-radius: 14px; white-space: pre-line; overflow-wrap: anywhere; background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.bubble.user { background: var(--blue); color: #fff; border-color: var(--blue); align-self: flex-end; }
.bubble.wait { color: var(--muted); font-style: italic; }
.chatbox form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
@media (min-width: 960px) { .chatbtn { bottom: 24px; right: 24px; } .chatbox { inset: auto 24px 24px auto; width: 380px; height: 560px; max-height: 85vh; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(14,63,138,.25); } }
body.plain .chatbtn { bottom: 20px; }

/* --- Login --- */
.login { display: grid; gap: 16px; }
.demo-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.demo-list button { width: 100%; text-align: left; background: #fff; border: 1px solid #e6c98c; border-radius: 10px; padding: 8px 12px; min-height: 48px; font: inherit; cursor: pointer; color: inherit; }
.demo-list code { font-size: .9rem; }
.part { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 8px; }
.previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.previews img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* --- Invoice --- */
.invoice { background: #fff; max-width: 820px; margin: 0 auto; padding: 24px; border: 1px solid var(--line); }
.invoice .head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 2px solid var(--blue); padding-bottom: 14px; margin-bottom: 14px; }
.invoice .sums { margin-left: auto; max-width: 340px; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 12px; }
  .banner, .top, .side, .bottom, .chatbtn, .chatbox, .noprint, .msg { display: none !important; }
  .frame { display: block; } main { padding: 0; max-width: none; } .invoice { border: 0; padding: 0; }
}

/* --- Very small phones (360px): keep every top button inside the screen --- */
@media (max-width: 479px) {
  .top { gap: 2px; padding-inline: 8px; }
  .top select { max-width: 92px; }
  body:not(.plain) .top .brand { gap: 0; font-size: 0; }
}
