/* GlassTech Professional Window Cleaning — admin app styles. Mobile-first: phone = bottom tab bar, tablet = icon rail, desktop = sidebar. */
:root { --nav-w-rail: 76px; --nav-w-side: 248px; --sa-b: env(safe-area-inset-bottom, 0px); --sa-t: env(safe-area-inset-top, 0px); --red-ink: #8a4b06; }
body { font-family: 'Mulish', sans-serif; background: var(--snow); color: var(--ink); margin: 0; min-height: 100dvh; -webkit-text-size-adjust: 100%; }
body.app { overscroll-behavior-y: none; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── shell ── */
.app-top { position: sticky; top: 0; z-index: 50; background: var(--slate); color: var(--white); display: flex; align-items: center; gap: 8px; padding: calc(var(--sa-t) + 6px) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); min-height: 56px; }
.app-top .back { width: 44px; height: 44px; display: grid; place-items: center; color: var(--white); text-decoration: none; margin-left: -8px; }
.app-top .back svg { width: 24px; height: 24px; }
.app-top .ttl { font: 700 15px 'Unbounded', sans-serif; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-top .brand { display: none; }
.app-main { padding: clamp(14px, 3vw, 32px); padding-bottom: calc(88px + var(--sa-b)); max-width: 1500px; margin-inline: auto; }
.app-nav { position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; background: var(--white); border-top: 1px solid var(--border); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 0 env(safe-area-inset-right) var(--sa-b) env(safe-area-inset-left); }
.app-nav a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; padding: 6px 2px; color: var(--gray); text-decoration: none; font-size: 11px; font-weight: 700; }
.app-nav a svg { width: 24px; height: 24px; flex: none; }
.app-nav a[aria-current="page"] { color: var(--ink); }
.app-nav a[aria-current="page"]::before { content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; background: var(--red); }
.app-nav .badge-n { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #b91c1c; color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.nav-brand, .nav-user { display: none; }
@media (max-width: 1099px) { body.app .app-main > h1, body.app .app-main > .adm-wrap > h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } body.app .app-main .adm-link.backlink { display: none; } }
@media (min-width: 768px) {
  .app-top, .app-main { margin-left: var(--nav-w-rail); }
  .app-main { padding-bottom: 40px; }
  .app-nav { top: 0; right: auto; width: var(--nav-w-rail); grid-auto-flow: row; grid-auto-rows: min-content; align-content: start; border-top: 0; border-right: 1px solid var(--border); padding: var(--sa-t) 0 var(--sa-b) env(safe-area-inset-left); overflow-y: auto; }
  .app-nav a { min-height: 68px; font-size: 10px; }
  .app-nav a[aria-current="page"]::before { top: 14%; bottom: 14%; left: 0; right: auto; width: 3px; height: auto; }
  .app-nav .badge-n { left: calc(50% + 4px); }
}
@media (min-width: 1100px) {
  .app-top, .app-main { margin-left: var(--nav-w-side); }
  .app-top { display: none; }
  .app-nav { width: var(--nav-w-side); padding-inline: 12px; gap: 2px; }
  .nav-brand { display: block; font: 400 17px 'Krona One', sans-serif; padding: 20px 8px 4px; }
  .nav-brand span { color: var(--red); }
  .nav-brand small { display: block; font: 700 10px 'Mulish', sans-serif; letter-spacing: 2px; text-transform: uppercase; color: var(--gray); margin-top: 4px; }
  .app-nav a { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 46px; padding: 0 12px; font-size: 14px; border-radius: 6px; }
  .app-nav a:hover { background: var(--mist); }
  .app-nav a[aria-current="page"] { background: var(--mist); }
  .app-nav a[aria-current="page"]::before { top: 20%; bottom: 20%; left: 0; }
  .app-nav .badge-n { position: static; margin-left: auto; }
  .nav-user { display: block; margin-top: auto; padding: 16px 8px; border-top: 1px solid var(--border); font-size: 13px; color: var(--gray); }
  .nav-user strong { display: block; color: var(--ink); overflow-wrap: anywhere; }
  .nav-user form { margin: 10px 0 0; }
  .app-nav { grid-auto-flow: row; }
  .app-nav { display: flex; flex-direction: column; }
}

/* ── status banners / toasts ── */
.offline-bar { position: fixed; z-index: 100; top: 0; left: 0; right: 0; background: #7f1d1d; color: #fff; text-align: center; font-size: 13px; font-weight: 700; padding: calc(var(--sa-t) + 8px) 12px 8px; }
.toast { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(76px + var(--sa-b)); width: min(92vw, 420px); background: var(--slate); color: #fff; padding: 12px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.3); display: flex; gap: 12px; align-items: center; font-size: 14px; }
.toast button { margin-left: auto; min-height: 40px; padding: 0 14px; border-radius: 4px; border: 0; background: var(--red); color: #243541; font-weight: 800; cursor: pointer; }
@media (min-width: 768px) { .toast { bottom: 24px; left: calc(50% + var(--nav-w-rail) / 2); } }
@media (min-width: 1100px) { .toast { left: calc(50% + var(--nav-w-side) / 2); } }

/* ── content ── */
.adm-wrap { padding: 0; }
h1 { font-family: 'Unbounded', sans-serif; font-size: clamp(18px, 4.5vw, 24px); margin: 0 0 6px; overflow-wrap: anywhere; }
.adm-sub { color: var(--gray); font-size: 13px; margin: 0 0 20px; line-height: 1.6; }
.adm-card { max-width: 560px; background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: clamp(16px, 4vw, 24px); }
.adm-card.narrow { margin: 6vh auto 0; }
.adm-card h2 { font: 700 13px 'Unbounded', sans-serif; margin: 0 0 14px; }
.adm-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.adm-row label { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gray); }
.adm-row small { color: var(--gray); font-size: 12px; line-height: 1.5; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: 16px 'Mulish', sans-serif; padding: 11px 12px; min-height: 46px; border: 1.5px solid var(--lgray); border-radius: 6px; color: var(--ink); width: 100%; min-width: 0; background: var(--white); }
textarea { resize: vertical; min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--red); outline-offset: 1px; border-color: var(--ink); }
.adm-check { display: flex; gap: 10px; align-items: center; font-size: 14px; margin-bottom: 16px; min-height: 44px; }
.adm-check input { width: 22px; height: 22px; flex: none; }
.adm-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.adm-btn { font: 700 12px 'Unbounded', sans-serif; letter-spacing: .5px; text-transform: uppercase; padding: 0 20px; min-height: 46px; border-radius: 6px; border: 1.5px solid var(--red); background: var(--red); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.adm-btn:hover { background: var(--red-dark); }
.adm-btn:disabled { opacity: .6; cursor: progress; }
.adm-btn.alt { background: var(--white); color: var(--ink); border-color: var(--lgray); }
.adm-btn.alt:hover { background: var(--mist); }
.adm-btn.danger { color: #b91c1c; border-color: #b91c1c; background: var(--white); }
@media (max-width: 480px) { .adm-btns .adm-btn { flex: 1 1 100%; } }
.adm-msg { font-size: 14px; padding: 12px 16px; border-radius: 6px; margin-bottom: 18px; max-width: 720px; line-height: 1.5; }
.adm-ok { background: rgba(34,197,94,.12); border: 1px solid var(--green); }
.adm-err { background: rgba(239,68,68,.1); border: 1px solid #b91c1c; color: #7f1d1d; }
.adm-link { color: var(--gray); font-size: 14px; display: inline-block; padding: 10px 0; }

/* ── dashboard / list ── */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
@media (min-width: 768px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; } }
.kpi { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 14px; text-decoration: none; display: block; }
.kpi b { display: block; font: 700 clamp(24px, 6vw, 32px) 'Unbounded', sans-serif; line-height: 1.1; }
.kpi span { font-size: 12px; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: .5px; }
.kpi.alert b { color: #b91c1c; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar form { display: flex; gap: 8px; flex: 1 1 260px; min-width: 0; }
.toolbar input[type=search] { flex: 1; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin: 0 calc(-1 * clamp(14px, 3vw, 32px)) 14px; padding-inline: clamp(14px, 3vw, 32px); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; font-size: 13px; font-weight: 700; padding: 0 14px; min-height: 44px; display: inline-flex; align-items: center; border: 1.5px solid var(--lgray); background: var(--white); color: var(--ink); text-decoration: none; border-radius: 22px; }
.chip.on { background: var(--slate); color: var(--white); border-color: var(--slate); }
.chip.due { border-color: #b91c1c; color: #b91c1c; } .chip.due.on { background: #b91c1c; color: #fff; }
.st { display: inline-block; padding: 3px 9px; border-radius: 3px; font-size: 11px; font-weight: 800; text-transform: uppercase; background: var(--mist); color: var(--slate); }
.st-new { background: rgba(237,16,36,.25); color: #6b3a06; } .st-won { background: rgba(34,197,94,.2); color: #14532d; } .st-lost { background: #eee; color: var(--gray); }
.fu-due { color: #b91c1c; font-weight: 800; }
.leads { width: 100%; border-collapse: collapse; background: var(--white); }
.leads th { text-align: left; background: var(--slate); color: #fff; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; padding: 12px 14px; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.leads td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; overflow-wrap: break-word; }
.leads td[data-label="Email"], .leads td[data-label="Phone"], .leads td[data-label="Date"] { white-space: nowrap; }
.leads .msg { color: var(--gray); max-width: 280px; white-space: pre-wrap; }
.leads a.name { font-weight: 800; text-decoration: none; }
.leads a.name:hover { text-decoration: underline; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (min-width: 900px) { .row-actions { flex-wrap: nowrap; } .leads .msg { min-width: 220px; } }
.row-actions form { margin: 0; }
.act { font: 700 12px 'Mulish', sans-serif; text-transform: uppercase; letter-spacing: .5px; min-height: 44px; padding: 0 12px; display: inline-flex; align-items: center; border: 1.5px solid var(--lgray); border-radius: 6px; background: var(--white); color: var(--ink); text-decoration: none; cursor: pointer; }
.act.del { color: #b91c1c; border-color: #b91c1c; }
@media (max-width: 899px) {
  .leads, .leads tbody { display: block; background: transparent; }
  .leads thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .leads tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
  .leads td { display: block; padding: 0; border: 0; grid-column: 1 / -1; font-size: 14px; }
  .leads .msg { max-width: none; }
  .leads td[data-label="Email"], .leads td[data-label="Phone"], .leads td[data-label="Date"] { white-space: normal; overflow-wrap: anywhere; }
  .leads td[data-label="Name"] { grid-column: 1; font-size: 17px; }
  .leads td[data-label="Status"] { grid-column: 2; grid-row: 1; justify-self: end; }
  .leads td[data-label]:not([data-label="Name"]):not([data-label="Status"])::before { content: attr(data-label) ": "; font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--gray); letter-spacing: .5px; }
  .leads td[data-label="Alert email"] { display: none; }
  .leads td[data-label="Message"] { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .leads td.row-actions-cell { margin-top: 8px; }
}
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; font-size: 14px; color: var(--gray); }
.empty { padding: 48px 16px; text-align: center; color: var(--gray); background: var(--white); border: 1px dashed var(--lgray); border-radius: 8px; }
.install-card { margin-top: 18px; }
.install-card ol { padding-left: 20px; line-height: 1.8; font-size: 14px; }
