/* CatchyMinds CRM styles. CSS variables (--name) keep brand colours in one place. */
:root {
  --teal: #009688;
  --teal-dark: #00695C;
  --teal-soft: #e0f2f1;
  --ink: #1d2b2a;
  --muted: #667573;
  --line: #dfe7e6;
  --bg: #f5f8f8;
  --card: #ffffff;
  --danger: #c62828;
  --warn-bg: #fff3e0;
  --warn: #b45309;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
}
a { color: var(--teal-dark); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Top bar */
.topbar {
  background: var(--teal-dark); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.5rem; flex-wrap: wrap; gap: .5rem;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand span { color: #80cbc4; }
.topbar nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: #e0f2f1; text-decoration: none; }
.topbar nav a.active { color: #fff; font-weight: 600; border-bottom: 2px solid #80cbc4; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: var(--radius); padding: 1rem; }
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--teal-dark); }
.stat-label { color: var(--muted); font-size: .85rem; }

/* Buttons */
.btn {
  display: inline-block; background: var(--teal); color: #fff; border: 0; border-radius: 8px;
  padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--teal-dark); }
.btn-small { padding: .35rem .8rem; background: #fff; color: var(--teal-dark) !important; }
.btn-light { background: var(--teal-soft); color: var(--teal-dark); }
.btn-light:hover { background: #b2dfdb; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: #ffebee; }

/* Forms */
.form label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .8rem; }
input, select, textarea {
  width: 100%; margin-top: .3rem; padding: .55rem .65rem; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #80cbc4; border-color: var(--teal); }
.actions { display: flex; gap: 1rem; align-items: center; }
.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; margin: 0; }
.filters input[type=search] { min-width: 220px; }

/* Tables */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; }

/* Badges, flags, keywords */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .2rem .55rem; border-radius: 99px; background: #eceff1; }
.stage-new-enquiry { background: #e3f2fd; color: #1565c0; }
.stage-contacted { background: #ede7f6; color: #5e35b1; }
.stage-assessment-booked { background: #fff8e1; color: #a16207; }
.stage-assessment-done { background: #fce4ec; color: #ad1457; }
.stage-enrolled { background: #e8f5e9; color: #2e7d32; }
.stage-lost { background: #eceff1; color: #546e7a; }
.flag { display: inline-block; font-size: .72rem; font-weight: 600; background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: .15rem .45rem; margin: .15rem .2rem 0 0; }
.kw { font-size: .72rem; font-weight: 700; background: var(--teal-soft); color: var(--teal-dark); border-radius: 4px; padding: .1rem .35rem; }

/* Flash messages */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-success { background: #e8f5e9; color: #2e7d32; }
.flash-error { background: #ffebee; color: var(--danger); }

/* Lead detail */
.details { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
.details dt { color: var(--muted); font-size: .88rem; }
.details dd { margin: 0; }
.history, .timeline { list-style: none; padding: 0; margin: 0; }
.history li { padding: .3rem 0; font-size: .88rem; }
.timeline li { border-left: 3px solid var(--teal-soft); padding: .3rem 0 .8rem .8rem; }
.tl-head { font-size: .82rem; margin-bottom: .2rem; }
.kind { font-weight: 700; color: var(--teal-dark); }
.danger-zone { margin-top: 2rem; text-align: right; }

/* Kanban board */
.board { display: grid; grid-template-columns: repeat(6, minmax(175px, 1fr)); gap: .8rem; overflow-x: auto; padding-bottom: 1rem; }
.column { background: #eaf0ef; border-radius: var(--radius); min-height: 60vh; display: flex; flex-direction: column; }
.column.drop-target { outline: 2px dashed var(--teal); }
.col-head { margin: 0; padding: .6rem .8rem; border-radius: var(--radius) var(--radius) 0 0; font-size: .9rem; display: flex; justify-content: space-between; }
.col-body { padding: .6rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.lead-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .65rem; cursor: grab; }
.lead-card a { text-decoration: none; color: var(--ink); }
.lead-card.dragging { opacity: .5; }

@media (max-width: 640px) {
  .topbar { padding: .7rem 1rem; }
  h1 { font-size: 1.3rem; }
}

/* ---- Module 2: login + staff ---- */
.narrow { max-width: 440px; margin: 2rem auto; }
.btn-block { width: 100%; }
.user-menu { position: relative; }
.user-menu summary { cursor: pointer; color: #fff; list-style: none; display: flex; align-items: center; gap: .4rem; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .role { font-size: .7rem; background: rgba(255,255,255,.18); padding: .1rem .45rem; border-radius: 99px; }
.user-menu .menu {
  position: absolute; right: 0; top: 2rem; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; min-width: 180px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: .4rem; z-index: 10;
}
.user-menu .menu a, .link-btn {
  display: block; width: 100%; text-align: left; padding: .5rem .6rem; border-radius: 6px;
  color: var(--ink) !important; text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer;
}
.user-menu .menu a:hover, .link-btn:hover { background: var(--teal-soft); }
.role-badge { background: var(--teal-soft); color: var(--teal-dark); }
tr.inactive td { color: var(--muted); }

/* ---- Custom roles ---- */
.center { text-align: center !important; }
.perm-table th.center { font-size: .72rem; max-width: 140px; }
.narrow-left { max-width: 560px; }
.perm-checks { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem; margin: 0 0 .8rem; }
.perm-checks legend { font-weight: 600; font-size: .88rem; padding: 0 .3rem; }
.form label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin: .35rem 0; }
.check input { width: auto; margin: 0; }

/* ---- Module 3: tasks ---- */
.nav-badge { background: #ff7043; color: #fff; font-size: .7rem; font-weight: 700; border-radius: 99px; padding: .05rem .4rem; margin-left: .15rem; }
.count { font-size: .8rem; color: var(--muted); font-weight: 600; margin-left: .3rem; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; color: var(--ink); text-decoration: none; }
.task-title:hover { color: var(--teal-dark); text-decoration: underline; }
.task-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .25rem; }
.is-done .task-title, .struck { text-decoration: line-through; color: var(--muted); }
.tick-form { margin: 0; }
.tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--teal); background: #fff; cursor: pointer; padding: 0; line-height: 1; color: #fff; font-weight: 700; margin-top: .1rem; }
.tick:hover { background: var(--teal-soft); }
.tick.done { background: var(--teal); }
.prio-high { background: #ffebee; color: var(--danger); }
.prio-medium { background: #fff8e1; color: #a16207; }
.prio-low { background: #eceff1; color: #546e7a; }
.badge.auto { background: #e3f2fd; color: #1565c0; }
.due { font-size: .8rem; }
.due.overdue { color: var(--danger); font-weight: 700; }
.due.today { color: var(--warn); font-weight: 700; }
.group-overdue h2 { color: var(--danger); }
.group-today h2 { color: var(--warn); }
.grid-team { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 1rem; align-items: start; }
@media (max-width: 760px) { .grid-team { grid-template-columns: 1fr; } }
tr.selected td { background: var(--teal-soft); }
.status-buttons { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.status-buttons form { margin: 0; }
.btn[disabled] { cursor: default; }
.desc { white-space: pre-wrap; border-top: 1px solid var(--line); padding-top: .8rem; }
.page-head h2 { margin-bottom: .6rem; }
.btn-small-inline { padding: .35rem .8rem; font-size: .85rem; }
.filters .check.inline { display: flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .9rem; }
.filters .check.inline input { width: auto; margin: 0; }

/* ---- Module 4: students + attendance ---- */
code { background: var(--teal-soft); color: var(--teal-dark); padding: .1rem .35rem; border-radius: 4px; font-size: .85rem; }
.scan-status { font-size: .85rem; margin: .4rem 0 0; min-height: 1.1em; }
.scan-status.ok { color: #2e7d32; }
.scan-status.error { color: var(--danger); }
.card-widget h3 { margin-top: 1rem; }
.spacer { flex: 1; }
.pad { padding: 1rem; }
.of { font-size: 1rem; color: var(--muted); font-weight: 600; }
.checkin-grid { display: grid; grid-template-columns: 1fr minmax(240px, 320px); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 760px) { .checkin-grid { grid-template-columns: 1fr; } }
.result { border-radius: 16px; min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center;
          text-align: center; padding: 2rem; transition: background .2s; border: 2px dashed var(--line); background: #fff; }
.result h2 { font-size: 2.2rem; margin: .5rem 0; }
.result p { font-size: 1.15rem; margin: 0; color: var(--muted); }
.result-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--teal-soft); }
.result.idle .result-icon::after { content: "📇"; font-size: 2.4rem; line-height: 72px; }
.result.check_in { background: #e8f5e9; border: 2px solid #43a047; }
.result.check_in .result-icon::after { content: "✅"; font-size: 2.4rem; line-height: 72px; }
.result.check_out { background: #e3f2fd; border: 2px solid #1e88e5; }
.result.check_out .result-icon::after { content: "👋"; font-size: 2.4rem; line-height: 72px; }
.result.duplicate { background: #fff8e1; border: 2px solid #f9a825; }
.result.duplicate .result-icon::after { content: "⏱"; font-size: 2.4rem; line-height: 72px; }
.result.error { background: #ffebee; border: 2px solid var(--danger); }
.result.error .result-icon::after { content: "⚠️"; font-size: 2.4rem; line-height: 72px; }
.recent { list-style: none; padding: 0; margin: 0; max-height: 300px; overflow-y: auto; }
.recent li { padding: .4rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .5rem; align-items: center; }
.recent .muted { margin-left: auto; font-size: .85rem; }
.tag { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tag.check_in { background: #43a047; }
.tag.check_out { background: #1e88e5; }
.stat-link { text-decoration: none; color: inherit; }
.stat-link:hover { border-color: var(--teal); }

/* ---- Delete buttons ---- */
.inline-form { display: inline; margin: 0; }
.link-delete { background: none; border: 0; padding: 0 .2rem; margin-left: .4rem; font: inherit; font-size: .78rem;
               color: var(--danger); cursor: pointer; text-decoration: underline; opacity: .75; }
.link-delete:hover { opacity: 1; }

/* ---- Module 5: fees ---- */
.subnav { display: flex; gap: .3rem; flex-wrap: wrap; margin: 0 0 1rem; border-bottom: 1px solid var(--line); }
.subnav a { padding: .45rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a.active { color: var(--teal-dark); border-color: var(--teal); font-weight: 600; }
.inv-paid { background: #e8f5e9; color: #2e7d32; }
.inv-partly-paid { background: #fff8e1; color: #a16207; }
.inv-overdue { background: #ffebee; color: var(--danger); }
.inv-unpaid { background: #e3f2fd; color: #1565c0; }
.inv-cancelled { background: #eceff1; color: #546e7a; text-decoration: line-through; }
.fee-blocked { background: var(--danger); color: #fff; }
.fee-warn { background: #fff3e0; color: var(--warn); }
.fee-ok { background: #eceff1; color: #546e7a; }
.stat-alert { border-left-color: var(--danger); }
.stat-alert .stat-num { color: var(--danger); }
.access-banner { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; }
.access-banner.blocked { background: #ffebee; color: var(--danger); }
.access-banner.extension { background: #fff8e1; color: #a16207; }
.access-banner.ok { background: #e8f5e9; color: #2e7d32; }
.inline-edit summary { cursor: pointer; color: var(--teal-dark); font-weight: 600; font-size: .88rem; }
.inline-edit[open] { background: #fff; }
.inline-edit .form { margin-top: .6rem; min-width: 240px; }
.inline-row { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.inline-row label { flex: 1; margin: 0; }

/* ---- Module 6: expenses ---- */
.month-bar { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.month-bar strong { min-width: 9rem; text-align: center; }
.filters-inline select { width: auto; margin: 0; }
.month-total { font-size: 1rem; }
.nowrap { white-space: nowrap; }
.cat-badge { background: #f3e5f5; color: #6a1b9a; }
.recurring-box { background: #fff8e1; border-color: #ffe082; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.cat-grid { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 0 .4rem; }
.chip { border: 1px solid var(--line); background: var(--teal-soft); color: var(--teal-dark); border-radius: 99px; padding: .25rem .7rem; font: inherit; font-size: .82rem; cursor: pointer; }
.chip-off { background: #eceff1; color: #90a4ae; text-decoration: line-through; }
.inline-check { display: inline-flex !important; gap: .3rem; font-weight: 400 !important; margin: 0 !important; }
.inline-check input { width: auto; margin: 0; }
.stat-out { border-left-color: #8e24aa; }
.stat-out .stat-num { color: #6a1b9a; }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { margin-bottom: .7rem; }
.bar-label { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: .2rem; }
.bar-track { background: #f1f4f4; border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, #8e24aa, #ba68c8); height: 100%; border-radius: 6px; }
td.neg { color: var(--danger); font-weight: 600; }
td.pos { color: #2e7d32; font-weight: 600; }
.mini-chart { display: flex; gap: .6rem; align-items: flex-end; height: 140px; margin-top: 1rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.mini-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.mini-bars { flex: 1; width: 100%; display: flex; gap: 3px; align-items: flex-end; justify-content: center; }
.mini-in, .mini-out { width: 40%; border-radius: 3px 3px 0 0; min-height: 2px; }
.mini-in { background: var(--teal); }
.mini-out { background: #ba68c8; }
.mini-label { font-size: .75rem; color: var(--muted); margin-top: .2rem; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 .2rem 0 .6rem; vertical-align: middle; }
.key-in { background: var(--teal); } .key-out { background: #ba68c8; }

/* GPS check-in (attend page on phones) and the Devices box */
.attend { max-width: 460px; margin: 0 auto; }
.attend .result { min-height: 240px; margin-bottom: 1rem; padding: 1rem; text-align: center; }
.result.idle .result-icon::after { content: "📍"; }
.btn-big { display: block; width: 100%; font-size: 1.25rem; padding: 1rem; border-radius: 12px; margin-bottom: .6rem; }
.btn-big:disabled { opacity: .6; }
.center { text-align: center; }
.steps { margin: 0; padding-left: 1.2rem; line-height: 1.6; }
.device-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.device-list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem;
  padding: .5rem 0; border-bottom: 1px solid var(--line); }
.device-list .ua { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite { background: var(--teal-soft); border-radius: 8px; padding: .7rem; margin-bottom: .8rem; }
.invite p { margin: 0 0 .4rem; }
.invite-link { width: 100%; font-family: monospace; font-size: .8rem; margin-bottom: .4rem; }
.invite .actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.invite form { margin: 0; }

/* Visible Log out button in the top bar */
.logout-form { margin: 0; }
.btn-logout { background: transparent; color: #fff; border: 1px solid #80cbc4; padding: .35rem .8rem; }
.btn-logout:hover { background: rgba(255,255,255,.12); }

/* Terms of Use + Privacy Policy pages (legal.py) */
.legal { max-width: 820px; margin: 0 auto 1rem; line-height: 1.6; }
.legal h2 { color: var(--teal-dark); margin: 1.4rem 0 .4rem; }
.legal ol, .legal ul { padding-left: 1.3rem; }
.legal table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.legal th { background: var(--teal); color: #fff; text-align: left; padding: .5rem; }
.legal td { border-bottom: 1px solid var(--line); padding: .5rem; vertical-align: top; }
.legal-scroll { max-height: 55vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 0 1rem; margin: 1rem 0; }
.legal-agreed { color: var(--teal-dark); font-weight: 600; margin-top: 1.2rem; }
.site-footer { text-align: center; font-size: .82rem; color: var(--muted); padding: 1rem 0 2rem; }
.site-footer a { color: var(--muted); }
/* "I agree" pop-up (templates/legal/agree.html) */
.legal-backdrop { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 20, 19, .65);
                  display: flex; align-items: center; justify-content: center; padding: 1rem; }
.legal-modal { background: var(--card, #fff); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
               width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column; padding: 1.4rem; }
.legal-modal .legal-scroll { flex: 1; max-height: none; min-height: 0; margin: .6rem 0 1rem; }
.legal-modal h1 { color: var(--teal-dark); margin-bottom: .4rem; }
.legal-decline { text-align: center; margin-top: .4rem; }
