/* PureHome.iq – one stylesheet for every page.
   Colours and sizes are set once here (the --variables) and used everywhere. */
:root {
  --bg: #f3f6f7;
  --card: #ffffff;
  --text: #17262d;
  --muted: #607581;
  --faint: #8fa1aa;
  --line: #e2e9ec;
  --brand: #0f8b8d;
  --brand-dark: #0a6c6e;
  --brand-soft: #e3f4f4;
  --green: #1d8a4c;
  --green-soft: #e4f5ea;
  --red: #c23b2e;
  --red-soft: #fcebe9;
  --orange: #b86e0a;
  --orange-soft: #fff3df;
  --blue: #1f63b8;
  --blue-soft: #e5effb;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(16, 40, 48, .05), 0 2px 8px rgba(16, 40, 48, .04);
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); }
h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 4px 8px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.ic { width: 20px; height: 20px; flex-shrink: 0; vertical-align: middle; }
.plus { color: var(--green); }
.minus, .owes { color: var(--red); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Top bar and navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 19px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; background: #fff2; }
.brand .name span { opacity: .75; font-weight: 500; }
.topnav { display: none; gap: 4px; margin-left: 12px; flex: 1; }
.topnav a {
  display: flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px;
  color: #ffffffd9; text-decoration: none; font-weight: 600; font-size: 15px;
}
.topnav a:hover { background: #ffffff1f; color: #fff; }
.topnav a.on { background: #ffffff2e; color: #fff; }
.topbar .who {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  color: #fff; text-decoration: none; font-size: 15px; padding: 6px 10px; border-radius: 10px;
}
.topbar .who:hover { background: #ffffff1f; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fffffff2; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--nav-h); color: var(--faint); text-decoration: none; font-size: 11.5px; font-weight: 600;
}
.tabbar a .ic { width: 23px; height: 23px; }
.tabbar a.on { color: var(--brand); }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(var(--nav-h) + 40px + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  main { padding: 28px 24px 60px; }
}

/* ---------- Page header ---------- */
.back {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 0 10px -4px; padding: 4px;
  color: var(--brand-dark); text-decoration: none; font-weight: 600; font-size: 15px;
}
.back .ic { width: 18px; height: 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-head .actions-inline { display: flex; gap: 8px; }
.sub { color: var(--muted); margin-top: 4px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 28px 4px 8px; }
.section-head h2 { margin: 0; }
.section-head a { font-size: 14px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Cards and lists ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin-top: 12px;
}
.card.flush { padding: 0; overflow: hidden; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-top: 1px solid var(--line); color: var(--text); text-decoration: none; min-height: 60px;
}
.row:first-child { border-top: none; }
a.row:hover { background: #fafcfc; }
a.row:active { background: var(--brand-soft); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; }
.row .meta { display: block; color: var(--muted); font-size: 14px; margin-top: 1px; }
.row .end { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.row .chev { color: var(--faint); width: 18px; height: 18px; }
.row .when { width: 64px; flex-shrink: 0; font-weight: 700; color: var(--brand-dark); font-size: 15px; line-height: 1.2; }
.row .when small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; }
.row .lead {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; background: var(--brand-soft); color: var(--brand-dark);
}
.row .lead.green { background: var(--green-soft); color: var(--green); }
.row .lead.red { background: var(--red-soft); color: var(--red); }
.row .lead.orange { background: var(--orange-soft); color: var(--orange); }
.row .lead.blue { background: var(--blue-soft); color: var(--blue); }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.kv:first-child { border-top: none; padding-top: 0; }
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { text-align: right; font-weight: 600; }
.kv.total { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 12px; font-size: 18px; }
.kv.total > span:first-child { color: var(--text); font-weight: 700; }
.block { margin-top: 14px; }
.block strong { display: block; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }

/* ---------- Badges and chips ---------- */
.badge {
  display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: #eef2f4; color: var(--muted); white-space: nowrap;
}
.badge.scheduled, .badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.done, .badge.active, .badge.green { background: var(--green-soft); color: var(--green); }
.badge.cancelled, .badge.missed, .badge.red { background: var(--red-soft); color: var(--red); }
.badge.paused, .badge.orange { background: var(--orange-soft); color: var(--orange); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; margin: 14px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 8px 14px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; font-size: 14.5px; font-weight: 600; border: none; cursor: pointer; font-family: inherit;
}
.chip.on { background: var(--text); color: #fff; }
.chip .count { opacity: .6; margin-left: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 18px; min-height: 52px;
  font: inherit; font-size: 17px; font-weight: 700; border: none; border-radius: 14px;
  background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: var(--card); color: var(--brand-dark); box-shadow: inset 0 0 0 1.5px var(--brand); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.ghost { background: transparent; color: var(--brand-dark); box-shadow: none; }
.btn.danger { background: var(--card); color: var(--red); box-shadow: inset 0 0 0 1.5px #e6b3ad; }
.btn.danger:hover { background: var(--red-soft); }
.btn.whatsapp { background: #1fae54; }
.btn.small { width: auto; min-height: 0; padding: 9px 14px; font-size: 15px; border-radius: 11px; }
.btn + .btn, .btn + form, form + .btn { margin-top: 10px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.btn-row > *, .btn-row form .btn { margin-top: 0 !important; }
.btn-row form { margin: 0; }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.quick a, .quick button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 74px; padding: 10px 6px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; font: inherit; font-weight: 600; font-size: 14.5px; border: none; cursor: pointer; text-align: center;
}
.quick .ic { width: 24px; height: 24px; color: var(--brand); }
.quick a:hover, .quick button:hover { box-shadow: 0 0 0 2px var(--brand-soft), var(--shadow); }
.quick.two { grid-template-columns: 1fr 1fr; }
.quick form { margin: 0; }
.quick form button { width: 100%; height: 100%; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 14px;
  min-height: 104px; padding: 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 15.5px; line-height: 1.25;
}
.tile .ic { width: 26px; height: 26px; padding: 7px; box-sizing: content-box; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark); }
.tile.green .ic { background: var(--green-soft); color: var(--green); }
.tile.red .ic { background: var(--red-soft); color: var(--red); }
.tile.orange .ic { background: var(--orange-soft); color: var(--orange); }
.tile.blue .ic { background: var(--blue-soft); color: var(--blue); }
.tile:hover { box-shadow: 0 0 0 2px var(--brand-soft), var(--shadow); }

/* ---------- Numbers ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.stat span { display: block; font-size: 13.5px; color: var(--muted); }
.stat strong { display: block; font-size: 24px; letter-spacing: -.02em; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.stat small { font-size: 12.5px; color: var(--muted); }
.stat.hero { background: var(--brand); color: #fff; }
.stat.hero span, .stat.hero small { color: #ffffffc4; }
.change { font-size: 12.5px; font-weight: 700; margin-top: 2px; }
.change.up { color: var(--green); }
.change.down { color: var(--red); }

.progress { height: 8px; background: #e8eef0; border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar-row { margin: 12px 0; }
.bar-row:first-child { margin-top: 0; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.bar { height: 8px; background: #e8eef0; border-radius: 999px; overflow: hidden; margin-top: 5px; }
.bar span { display: block; height: 100%; background: var(--brand); }
.bar.red span { background: var(--red); }
.amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amt.in { color: var(--green); }
.amt.out { color: var(--red); }

/* ---------- Notices ---------- */
.notice { display: flex; gap: 10px; align-items: flex-start; border-radius: 14px; padding: 12px 14px; margin-top: 12px; font-weight: 600; }
.notice .ic { margin-top: 1px; }
.notice.ok { background: var(--green-soft); color: var(--green); }
.notice.warn { background: var(--orange-soft); color: var(--orange); }
.notice.bad { background: var(--red-soft); color: var(--red); }
.notice.info { background: var(--blue-soft); color: var(--blue); }
.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li {
  display: flex; gap: 10px; align-items: center; border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
  background: var(--green-soft); color: var(--green); font-weight: 600; animation: pop .25s ease-out;
}
.messages li.error { background: var(--red-soft); color: var(--red); }
.messages li.warning { background: var(--orange-soft); color: var(--orange); }
.messages li.info { background: var(--blue-soft); color: var(--blue); }
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Forms ---------- */
form.card { padding: 18px; }
.field { margin-bottom: 18px; }
.field:last-of-type { margin-bottom: 20px; }
label, .label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 15px; }
.optional { font-weight: 500; color: var(--faint); font-size: 13.5px; }
.help { font-size: 13.5px; color: var(--muted); margin-top: 5px; }
.money-hint { font-size: 14px; color: var(--brand-dark); font-weight: 700; margin-top: 5px; min-height: 1em; }
.field-error { color: var(--red); font-size: 14px; margin-top: 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 17px; padding: 12px 14px; min-height: 50px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23607581' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px #0f8b8d24; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
input[type="radio"], input[type="checkbox"] {
  width: 20px; height: 20px; min-height: 0; padding: 0; margin: 0; flex-shrink: 0;
  -webkit-appearance: auto; appearance: auto; accent-color: var(--brand);
}
.error-box { background: var(--red-soft); color: var(--red); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-weight: 600; }

/* Choice buttons: radios and checkboxes shown as tappable pills */
.choices > div[id] { display: flex; flex-wrap: wrap; gap: 8px; }
.choices > div[id] label {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px; min-height: 46px;
  border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 600; background: #fff;
}
.choices > div[id] label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.choices.days > div[id] label { min-width: 64px; justify-content: center; }
.choices.days > div[id] input { display: none; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
.check-line { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 0; cursor: pointer; }

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.presets button { font: inherit; font-size: 14px; padding: 7px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; }
.presets button:hover { border-color: var(--brand); }

details.more { margin: 4px 0 18px; }
details.more summary {
  cursor: pointer; font-weight: 700; color: var(--brand-dark); padding: 8px 0; list-style: none; display: flex; align-items: center; gap: 6px;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 6px; background: var(--brand-soft); }
details.more[open] summary::before { content: "–"; }
.form-section { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 6px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); }
form > .form-section:first-of-type { border-top: none; padding-top: 0; }

/* ---------- Search, day navigation ---------- */
.search { display: flex; gap: 8px; margin: 14px 0 10px; }
.search input { flex: 1; }
.search select { width: auto; }
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; }
.day-nav .arrow {
  display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 12px;
  background: var(--card); box-shadow: var(--shadow); color: var(--text);
}
.day-nav .arrow.disabled { opacity: .3; pointer-events: none; }
.day-title { text-align: center; font-weight: 700; font-size: 18px; }
.day-title span, .day-title a { display: block; font-weight: 500; font-size: 14px; color: var(--muted); }
.day-title a { color: var(--brand-dark); }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 12px 0 16px; }
.strip a {
  text-align: center; padding: 8px 0 7px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow);
  color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 600;
}
.strip a strong { display: block; font-size: 18px; color: var(--text); }
.strip .dot { display: block; height: 16px; font-size: 12px; color: var(--brand-dark); }
.strip a.today { box-shadow: inset 0 0 0 2px var(--brand); }
.strip a.on { background: var(--brand); color: #ffffffcc; }
.strip a.on strong, .strip a.on .dot { color: #fff; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo img { width: 76px; height: 76px; border-radius: 20px; box-shadow: var(--shadow); }
.login-logo h1 { margin-top: 12px; }

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  h1 { font-size: 23px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat.wide { grid-column: span 2; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .quick { grid-template-columns: repeat(3, 1fr); }
  .stat strong { font-size: 21px; }
}

/* ---------- Printing (monthly report) ---------- */
@media print {
  .topbar, .tabbar, .back, .no-print, .messages { display: none !important; }
  body { background: #fff; font-size: 13px; }
  main { max-width: none; padding: 0; }
  .card, .stat, .list { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}

.quick.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 560px) { .quick.four { grid-template-columns: repeat(2, 1fr); } }
a.stat { display: block; }
