:root{
  --bg:#f3f4f6;
  --card:#ffffff;
  --text:#0b0f17;
  --muted:#5b6472;
  --border:#e2e6ec;
  --shadow: 0 6px 18px rgba(10, 20, 30, 0.06);

  --accent:#0ea5a8;        /* teal vibe like Tradify */
  --accent-weak:#e6fbfb;

  --radius:16px;
  --pad:14px;

  --bottomnav-h: 62px;
}

*{box-sizing:border-box}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.topbar{
  position:sticky; top:0;
  background:rgba(243,244,246,0.92);
  backdrop-filter:saturate(120%) blur(10px);
  border-bottom:1px solid var(--border);
  z-index:5;
}

.topbar-inner{padding:12px var(--pad);}

.brand-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.brand-left{
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 0;
}

.brand-logo{
  width:36px;
  height:36px;
  object-fit:contain;
  border-radius:10px;
  background:#fff;
  border:1px solid var(--border);
}

.brand-text{line-height:1.05; min-width:0;}
.brand-name{font-weight:900; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.brand-sub{font-weight:700; font-size:12px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}

.page-title{
  font-weight:900;
  font-size:14px;
  color:var(--muted);
  white-space:nowrap;
}

.content{
  padding: var(--pad);
  padding-bottom: calc(var(--bottomnav-h) + var(--pad) + env(safe-area-inset-bottom));
}

h1{
  margin: 6px 0 12px 0;
  font-size: 22px;
  letter-spacing: -0.2px;
}

/* Search bar */
.search{
  display:flex;
  gap:10px;
  margin:10px 0 12px 0;
}
.search input{
  flex:1;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius: 14px;
  background:#fff;
  color:var(--text);
  outline:none;
  box-shadow: var(--shadow);
}
.search input::placeholder{ color:#8b95a5; }
.search button{
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius: 14px;
  background:#fff;
  color:var(--text);
  font-weight:900;
  box-shadow: var(--shadow);
}
.search button:active{ transform: translateY(1px); }

/* Segmented controls */
.seg{
  display:flex;
  gap:10px;
  margin:6px 0 12px 0;
  flex-wrap:wrap;
}
.segitem{
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:999px;
  text-decoration:none;
  color:var(--text);
  background:#fff;
  font-weight:900;
  box-shadow: var(--shadow);
}
.segitem.active{
  background: var(--accent-weak);
  border-color: rgba(14,165,168,0.35);
  color: #065f61;
}

/* Lists/cards */
.list{display:flex; flex-direction:column; gap:12px;}

.card{
  display:block;
  padding:14px 14px;
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  text-decoration:none;
  color:var(--text);
  box-shadow: var(--shadow);
}

.title{
  font-weight:950;
  margin-bottom:6px;
  font-size:16px;
}

.meta{
  color:var(--muted);
  font-size:13px;
  line-height:1.35;
}

.empty{
  padding:14px;
  color:var(--muted);
  background:#fff;
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Panels */
.panel{
  padding:14px;
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.kv{display:flex; justify-content:space-between; gap:10px; padding:8px 0;}
.k{color:var(--muted); font-size:13px;}
.v{font-weight:900; font-size:13px;}
.big{font-size:34px; font-weight:950;}

/* Bottom tab bar */
.bottomnav{
  position:fixed; left:0; right:0; bottom:0;
  display:flex;
  border-top:1px solid var(--border);
  background: rgba(255,255,255,0.92);
  backdrop-filter:saturate(120%) blur(10px);

  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 1000;
}

.navitem{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  color:#6b7280;
  font-weight:900;
  white-space:nowrap;
}
.navitem.active{
  color: var(--accent);
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:999px;
  background:#fff;
  color:var(--text);
  font-weight:900;
  text-decoration:none;
  box-shadow: var(--shadow);
  white-space:nowrap;
}

.sched-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin: 6px 0 12px 0;
}

.sched-title{
  font-weight:950;
  font-size:16px;
  color:var(--muted);
}

.sched-wrap{
  overflow:auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sched-grid{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  background:#fff;
  border:1px solid var(--border);
}

.sched-grid thead th{
  position:sticky;
  top:0;
  background:#fff;
  z-index:2;
  border-bottom:1px solid var(--border);
}

.time-col{
  width:72px;
  min-width:72px;
  padding:10px 10px;
  font-weight:900;
  color:var(--muted);
  border-right:1px solid var(--border);
  background:#fff;
  position:sticky;
  left:0;
  z-index:3;
}

.day-col{
  min-width:120px;
  padding:10px 8px;
  text-align:center;
}

.day-hdr .dow{
  font-weight:900;
  color:var(--muted);
  font-size:12px;
}
.day-hdr .dom{
  font-weight:950;
  font-size:16px;
}

.cell{
  height:54px;
  padding:8px;
  border-right:1px solid var(--border);
  border-bottom:1px solid var(--border);
  vertical-align:top;
}

.appt{
  background: var(--accent-weak);
  border:1px solid rgba(14,165,168,0.35);
  border-radius:12px;
  padding:8px 8px;
}

.appt-title{
  font-weight:950;
  font-size:13px;
  margin-bottom:2px;
}

.appt-sub{
  font-size:12px;
  color:var(--muted);
}

/* Day view */
.sched-day{ display:flex; flex-direction:column; gap:10px; }
.day-row{
  display:grid;
  grid-template-columns: 72px 1fr;
  gap:10px;
  align-items:stretch;
}
.day-time{
  padding:10px 10px;
  font-weight:900;
  color:var(--muted);
}
.day-slot{
  background:#fff;
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:10px;
  box-shadow: var(--shadow);
  min-height:44px;
}
.appt-day{ max-width:520px; }

/* =========================
   Scheduler (week/day grid2)
   ========================= */

.sched-wrap { margin-top: 12px; }

.sched-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin: 10px 0 14px;
}

.sched-title{
  font-weight:800;
  letter-spacing:0.2px;
}

/* Grid shell */
.sched-grid2{
  display:grid;
  grid-template-columns: 78px repeat(7, minmax(160px, 1fr));
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  width: 100%;
}

/* Day view: time + single day */
.sched-grid2-day{
  grid-template-columns: 78px minmax(280px, 1fr);
}

/* Columns are (header, body) */
.time-col2, .day-col2{
  display:grid;
  grid-template-rows: 56px 1fr;
}

.time-col2-head, .day-col2-head{
  display:flex;
  align-items:center;
  justify-content:center;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: rgba(0,0,0,0.02);
}

.time-col2-body{
  position: relative;
  background:#fff;
}

.time-tick{
  height: var(--slot-px, 72px);
  display:flex;
  align-items:flex-start;
  justify-content:flex-end;
  padding: 10px 10px 0 8px;
  font-weight: 700;
  opacity: 0.75;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.day-col2-body{
  position: relative;
  background:#fff;
  border-left: 1px solid rgba(0,0,0,0.06);
}

.day-hdr{
  text-align:center;
  line-height:1.1;
}
.day-hdr .dow{ font-weight:800; opacity:0.75; }
.day-hdr .dom{ font-weight:900; font-size:16px; }

/* Canvas with hour gridlines */
.day-canvas{
  position: relative;
  height: var(--cal-h, 600px);
  min-height: 520px;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0.06) 0px,
      rgba(0,0,0,0.06) 1px,
      transparent 1px,
      transparent var(--slot-px, 72px)
    );
}

/* Appointment block */
.appt2{
  position:absolute;
  left: 10px;
  right: 10px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(18, 184, 200, 0.12);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
  padding: 10px 10px;
  overflow:hidden;
}

.appt2-title{
  font-weight: 900;
  font-size: 14px;
  line-height: 1.15;
}

.appt2-sub{
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.85;
}

/* ===== Mobile: show full week (Tradify-style) ===== */
@media (max-width: 720px){

  /* No sideways scroll: fit to viewport */
  .sched-wrap{
    overflow: hidden;
  }

  /* Narrow time gutter + 7 equal day columns that are allowed to shrink */
  .sched-grid2{
    grid-template-columns: 44px repeat(7, minmax(0, 1fr));
    width: 100%;
  }

  /* Ensure day columns can actually shrink inside CSS grid */
  .day-col2{ min-width: 0; }
  .day-col2-body{ overflow: hidden; }

  /* Tighten headers */
  .time-col2-head, .day-col2-head{
    height: 44px;
  }
  .day-hdr .dow{ font-size: 10px; }
  .day-hdr .dom{ font-size: 12px; }

  /* Tight time labels */
  .time-tick{
    font-size: 10px;
    padding: 6px 6px 0 4px;
  }

  /* Appointment blocks: smaller + clamp */
  .appt2{
    left: 2px;
    right: 2px;
    padding: 6px 6px;
    border-radius: 10px;
  }

  .appt2-title{
    font-size: 11px;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .appt2-sub{
    margin-top: 3px;
    font-size: 10px;
    line-height: 1.1;
  }

  /* Hide 2nd sub-line (your template uses it for location) */
  .appt2-sub + .appt2-sub{ display:none; }
}

/* =========================================================
   Scheduler Appointment Modal (Tradify-style light sheet)
   ========================================================= */

.ao-modal-backdrop{
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  padding: 0;
}

.ao-modal-backdrop.is-open{
  display: flex;
}

.ao-modal{
  width: 100%;
  max-width: 720px;
  background: #ffffff;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
  animation: aoModalUp 0.18s ease-out;
}

@keyframes aoModalUp{
  from{ transform: translateY(24px); opacity:0; }
  to{ transform: translateY(0); opacity:1; }
}

.ao-modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
}

.ao-modal-cancel{
  background:none;
  border:0;
  font-weight:800;
  color:var(--muted);
  font-size:14px;
}

.ao-modal-title{
  font-weight:900;
  font-size:16px;
}

.ao-modal-primary{
  background: var(--accent);
  color:#fff;
  padding:8px 12px;
  border-radius:999px;
  text-decoration:none;
  font-weight:900;
  font-size:13px;
}

.ao-modal-body{
  padding:16px;
}

/* Job header */
.ao-job-header{
  text-align:center;
  margin-bottom:14px;
}

.ao-job-customer{
  font-weight:950;
  font-size:18px;
  margin-bottom:6px;
  overflow-wrap:anywhere;
}

.ao-job-badges{
  display:flex;
  gap:8px;
  justify-content:center;
  margin-bottom:6px;
}

.ao-badge{
  background:#40484f;
  color:#fff;
  padding:5px 10px;
  border-radius:999px;
  font-size:11px;
  font-weight:900;
}

.ao-badge-ok{
  background:#10b981;
}

.ao-job-address{
  font-size:13px;
  color:var(--muted);
  overflow-wrap:anywhere;
}

/* Action strip */
.ao-action-strip{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:10px;
  margin:14px 0;
}

.ao-action-btn{
  display:block;
  text-align:center;
  padding:10px 8px;
  border-radius:14px;
  background: var(--accent-weak);
  border:1px solid rgba(14,165,168,0.35);
  color:#065f61;
  text-decoration:none;
  font-weight:900;
  font-size:12px;
}

/* Detail grid */
.ao-detail-grid{
  border:1px solid var(--border);
  border-radius:16px;
  overflow:hidden;
}

.ao-detail-row{
  display:grid;
  grid-template-columns:110px 1fr;
  gap:10px;
  padding:12px 14px;
  border-top:1px solid var(--border);
}

.ao-detail-row:first-child{
  border-top:0;
}

.ao-detail-k{
  font-size:12px;
  color:var(--muted);
  font-weight:800;
}

.ao-detail-v{
  font-size:13px;
  font-weight:800;
  overflow-wrap:anywhere;
}

/* Desktop: center modal vertically */
@media (min-width: 721px){
  .ao-modal-backdrop{
    align-items: center;
  }
  .ao-modal{
    border-radius: 18px;
  }
}

/* =========================
   Jobs (production finish)
   ========================= */

.jobs-list {
  display: grid;
  gap: 14px;
}

a.job-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;

  text-decoration: none;
  background: #fff;
  border-radius: 14px;
  padding: 16px 18px;

  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);

  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  color: #111;
}

a.job-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0,0,0,0.12);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.job-ref {
  min-width: 92px;
  font-size: 13px;
  font-weight: 700;
  color: #444;
  opacity: 0.9;
  padding-top: 2px;
}

.job-main {
  flex: 1;
  min-width: 0; /* enables ellipsis */
}

.job-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 6px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-sub {
  font-size: 13px;
  color: #666;
  line-height: 1.3;
  margin-top: 2px;

  /* allow wrapping but keep it tidy */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.job-right {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  min-width: 110px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;

  background: #eee;
  color: #333;
  border: 1px solid rgba(0,0,0,0.08);
  text-transform: capitalize;
}

/* Status colour map (add more as needed) */
.pill-lead {
  background: #e3f2fd;
  color: #0d47a1;
  border-color: rgba(13,71,161,0.18);
}

.pill-active,
.pill-in-progress {
  background: #e8f5e9;
  color: #1b5e20;
  border-color: rgba(27,94,32,0.18);
}

.pill-on-hold,
.pill-on_hold {
  background: #fff3e0;
  color: #e65100;
  border-color: rgba(230,81,0,0.18);
}

.pill-to-invoice,
.pill-to_invoice {
  background: #fce4ec;
  color: #880e4f;
  border-color: rgba(136,14,79,0.18);
}

.pill-unknown {
  background: #f5f5f5;
  color: #555;
}

/* Job view (read-only) */
.job-panel { padding: 16px; }
.job-header { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.job-title { font-size: 18px; font-weight: 700; }
.job-meta { margin-top: 4px; color: #667085; font-size: 13px; display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.job-meta .dot { opacity: 0.6; }

.job-actions { display:flex; gap:10px; flex-wrap:wrap; margin: 14px 0 6px; }
.btn { display:inline-flex; align-items:center; justify-content:center; padding:10px 12px; border-radius: 12px; font-weight:600; text-decoration:none; }
.btn-soft { background:#EEF2F6; color:#111827; }
.btn-soft.disabled { opacity:0.55; pointer-events:none; }

.job-subnav { margin: 10px 0 14px; display:flex; gap:10px; overflow:auto; padding-bottom: 4px; }
.subnav-item { white-space:nowrap; padding:10px 12px; border-radius: 12px; background:#F7F8FA; color:#111827; text-decoration:none; font-weight:600; }
.subnav-item.active { background:#E6F4F1; }

.kv-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-top: 12px; }
.kv .k { color:#667085; font-size:12px; }
.kv .v { font-weight:600; color:#111827; margin-top: 2px; word-break: break-word; }

.section { margin-top: 14px; padding-top: 14px; border-top: 1px solid #EEF2F6; }
.section-title { font-weight:700; margin-bottom: 6px; }
.section-body .line { margin: 2px 0; }
.subnav-item.disabled { opacity:0.55; pointer-events:none; }

/* =========================
   Sales (Tradify-ish)
   ========================= */

.page-head{
  margin: 6px 0 12px 0;
}

.head-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}

a.link{
  text-decoration:none;
  font-weight:900;
  color: var(--accent);
}
a.link.muted{
  color: var(--muted);
}

.section{
  margin-bottom: 14px;
}

.section-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 10px;
}

.section-head .title{
  margin:0;
  font-size: 16px;
  font-weight: 950;
}

.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  text-decoration:none;
  color: var(--text);
}
.row:first-of-type{
  border-top: 0;
}
.row:active{
  transform: translateY(1px);
}

.row .left{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}
.row .label{
  font-weight:900;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.row .right{
  display:flex;
  align-items:center;
  gap:10px;
}
.count{
  font-weight:950;
}
.chev{
  font-size: 20px;
  color: #9aa3b2;
  line-height: 1;
}

.dot{
  width:10px;
  height:10px;
  border-radius:999px;
  display:inline-block;
  border: 1px solid rgba(0,0,0,0.10);
  background: #d1d5db;
}
.dot-muted{ background:#cfd6df; }
.dot-info{ background: rgba(14,165,168,0.70); border-color: rgba(14,165,168,0.35); }
.dot-warn{ background:#f59e0b; border-color: rgba(245,158,11,0.35); }
.dot-danger{ background:#ef4444; border-color: rgba(239,68,68,0.35); }

.section-foot{
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
  display:flex;
  justify-content:flex-start;
}

.btn.secondary[disabled]{
  opacity: 0.55;
  cursor: not-allowed;
}

/* Status Pills */
.pill{
  display:inline-block;
  padding:4px 8px;
  border-radius:999px;
  font-size:12px;
  font-weight:900;
  line-height:1;
  border:1px solid var(--border);
  background:#eef1f6;
}

.pill.draft{
  background:#e5e7eb;
}

.pill.awaiting{
  background:rgba(14,165,168,0.15);
  border-color:rgba(14,165,168,0.35);
  color:#0e7490;
}

.pill.unpaid{
  background:rgba(245,158,11,0.15);
  border-color:rgba(245,158,11,0.35);
  color:#92400e;
}

.pill.overdue{
  background:rgba(239,68,68,0.15);
  border-color:rgba(239,68,68,0.35);
  color:#991b1b;
}

/* Document Detail View */

.doc-header{
  padding:16px;
}

.doc-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
}

.doc-ref{
  font-size:18px;
  font-weight:950;
  margin-bottom:6px;
}

.doc-total{
  font-size:22px;
  font-weight:950;
  text-align:right;
}

.doc-section{
  padding:16px;
  margin-top:12px;
}

.doc-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap:14px 18px;
}

.label{
  font-size:12px;
  font-weight:900;
  color: var(--muted);
  text-transform:uppercase;
  letter-spacing:0.4px;
}

.value{
  font-size:14px;
  font-weight:900;
  margin-top:4px;
}

.doc-actions{
  margin-top:14px;
  display:flex;
  gap:10px;
  justify-content:flex-start;
}

/* Customer detail polish */
.doc-section { padding:16px; margin-top:12px; }
.doc-grid { display:grid; grid-template-columns: repeat(2, 1fr); gap:14px 18px; }
.label { font-size:12px; font-weight:900; color: var(--muted); text-transform:uppercase; letter-spacing:0.4px; }
.value { font-size:14px; font-weight:900; margin-top:4px; }
