/* ── Home Therapist App — Global Styles ──────────────────────────────────────── */
:root {
  --bg: #0a0f1a;
  --surface: #111827;
  --surface2: #1a2234;
  --border: #1e2d45;
  --accent: #00c2ff;
  --accent2: #00e5a0;
  --accent3: #ff6b6b;
  --accent4: #ffc94d;
  --text: #e8edf5;
  --muted: #6b7fa3;
  --white: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LOGIN PAGE ─────────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--white);
  margin-bottom: 6px;
}
.login-logo span { color: var(--accent); }
.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 32px;
}
.form-group {
  margin-bottom: 16px;
  text-align: left;
}
.form-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 6px;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--muted); opacity: .6; }

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #0099cc);
  border: none;
  border-radius: 10px;
  color: var(--bg);
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  margin-top: 8px;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,194,255,.35);
}
.btn-primary:active { transform: translateY(0); }

.login-error {
  color: var(--accent3);
  font-size: 12px;
  margin-top: 12px;
  min-height: 18px;
}

/* ── APP SHELL ──────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: var(--white);
}
.app-logo span { color: var(--accent); }

.app-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-user-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.app-user-role {
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
}
.app-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #0077aa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: var(--white);
}
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
}
.btn-logout:hover {
  color: var(--accent3);
  border-color: var(--accent3);
}

/* ── DASHBOARD ──────────────────────────────────────────────────────────────── */
.dashboard {
  padding: 28px 24px;
  max-width: 1200px;
  margin: 0 auto;
}
.dash-greeting {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}
.dash-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.section-label {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  cursor: pointer;
  transition: border-color .2s, transform .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  display: block;
  color: inherit;
}
.tool-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.tool-card:hover {
  border-color: #2a3f60;
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  text-decoration: none;
}
.tool-card.blue::before    { background: var(--accent); }
.tool-card.green::before   { background: var(--accent2); }
.tool-card.yellow::before  { background: var(--accent4); }
.tool-card.red::before     { background: var(--accent3); }
.tool-card.purple::before  { background: #a78bfa; }

.tool-icon {
  font-size: 28px;
  margin-bottom: 14px;
}
.tool-name {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 6px;
}
.tool-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.tool-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
}
.tool-badge.hvac     { background: rgba(0,194,255,.1);  color: var(--accent); }
.tool-badge.plumbing { background: rgba(167,139,250,.1); color: #a78bfa; }
.tool-badge.all      { background: rgba(0,229,160,.1);   color: var(--accent2); }
.tool-badge.admin    { background: rgba(255,201,77,.1);   color: var(--accent4); }

/* ── TOOL PAGE WRAPPER ──────────────────────────────────────────────────────── */
.tool-page {
  padding: 0;
}
.tool-topbar {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
  font-family: 'DM Sans', sans-serif;
}
.btn-back:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.tool-topbar-title {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.tool-frame {
  width: 100%;
  border: none;
  min-height: calc(100vh - 120px);
  background: var(--bg);
}

/* ── SAVED CALCULATIONS ─────────────────────────────────────────────────────── */
.saved-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.saved-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.saved-item-info { flex: 1; }
.saved-item-tool {
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
}
.saved-item-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.saved-item-actions {
  display: flex;
  gap: 8px;
}
.btn-sm {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  transition: all .15s;
}
.btn-sm:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.btn-sm.danger:hover {
  color: var(--accent3);
  border-color: var(--accent3);
}

/* ── PWA INSTALL BANNER ─────────────────────────────────────────────────────── */
.pwa-banner {
  display: none;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  align-items: center;
  gap: 14px;
}
.pwa-banner.show { display: flex; }
.pwa-banner-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}
.pwa-banner-text strong {
  color: var(--accent);
  font-family: 'Syne', sans-serif;
}
.btn-install {
  padding: 8px 20px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: var(--bg);
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}

/* ── PROFILE DROPDOWN ───────────────────────────────────────────────────────── */
.profile-trigger {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.profile-menu {
  display: none;
  position: absolute;
  top: 52px;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 0;
  min-width: 220px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.profile-menu.show { display: block; }
.profile-menu-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.profile-menu-photo {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--white);
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), #0077aa);
}
.profile-menu-name {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--white);
}
.profile-menu-role {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.pm-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background .15s;
  border: none;
  background: none;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
}
.pm-item:hover { background: rgba(255,255,255,.04); }
.pm-item.danger { color: var(--accent3); }
.pm-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* ── MODALS ─────────────────────────────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5,10,20,.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 20px;
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.mbtn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border: none;
}
.mbtn-cancel { background: none; border: 1px solid var(--border) !important; color: var(--muted); }
.mbtn-save { background: var(--accent); color: var(--bg); }
.mbtn-green { background: var(--accent2); color: var(--bg); }
.photo-upload {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0 auto 8px;
  overflow: hidden;
  transition: border-color .2s;
}
.photo-upload:hover { border-color: var(--accent); }
.msg-error { color: var(--accent3); font-size: 12px; min-height: 16px; margin-top: 8px; }
.msg-success { color: var(--accent2); font-size: 12px; min-height: 16px; margin-top: 8px; }

/* ── LOGO LINK ──────────────────────────────────────────────────────────────── */
.app-logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.app-logo-link:hover { text-decoration: none; }
.app-logo-img { height: 40px; width: auto; }
.app-logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--white);
  line-height: 1.2;
}
.app-logo-sub {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
}

/* ── LOGIN LOGO (centered image) ───────────────────────────────────────────── */
.login-logo-img {
  display: block;
  height: 64px;
  width: auto;
  margin: 0 auto 12px;
}

/* ── AVATAR IMAGES ─────────────────────────────────────────────────────────── */
.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.avatar-img-lg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.app-user-info { text-align: right; }

/* ── INSTALL BUTTON ───────────────────────────────────────────────────────── */
.install-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, var(--accent2), #00b4cc);
  border: none;
  border-radius: 8px;
  color: var(--bg);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-right: 12px;
}
.install-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 229, 160, 0.3);
}
.install-btn svg { flex-shrink: 0; }

/* ── iOS INSTALL BANNER ────────────────────────────────────────────────────── */
.ios-install-banner {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #1a2234, #111827);
  border-bottom: 1px solid var(--accent);
  padding: 12px 16px;
  gap: 12px;
  z-index: 150;
}
.ios-banner-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.ios-banner-text strong {
  color: var(--accent);
  font-family: 'Syne', sans-serif;
}
.ios-share-icon {
  display: inline-block;
  font-size: 15px;
  vertical-align: middle;
}
.ios-banner-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 22px;
  padding: 4px 8px;
  line-height: 1;
}
.ios-banner-dismiss:hover { color: var(--text); }

/* ── SW UPDATE BANNER ──────────────────────────────────────────────────────── */
.sw-update-banner {
  background: var(--accent);
  color: var(--bg);
  text-align: center;
  padding: 10px 16px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  z-index: 200;
  transition: background .2s;
}
.sw-update-banner:hover { background: #00d4ff; }

/* ── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .app-header { padding: 0 16px; }
  .dashboard { padding: 20px 16px; }
  .tools-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 24px; }
  .app-user-name, .app-user-role { display: none; }
  .dash-greeting { font-size: 18px; }
}
