:root {
  --portal-bg: #001914;
  --portal-panel: #062b34;
  --portal-line: rgba(104, 190, 205, .2);
  --portal-text: #edf9fb;
  --portal-muted: #9dc6cf;
  --portal-accent: #3495d0;
}

.mobile-nav-toggle,
.mobile-quick-expense { display: none; }

.pwa-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 10, 12, .78);
  backdrop-filter: blur(8px);
}

.pwa-modal.hidden { display: none; }

.pwa-modal-card {
  position: relative;
  width: min(440px, 100%);
  padding: 26px;
  border: 1px solid rgba(115, 196, 213, .3);
  border-radius: 18px;
  background: linear-gradient(150deg, #0a3440, #041c23);
  color: var(--portal-text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .58);
}

.pwa-modal-card h2 { margin: 4px 38px 10px 0; font-size: 24px; }
.pwa-modal-card p, .pwa-modal-card li { color: var(--portal-muted); line-height: 1.55; }
.pwa-eyebrow { margin: 0; color: #66d0e7 !important; font-size: 11px; font-weight: 800; letter-spacing: 1.5px; }
.pwa-modal-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border: 1px solid #40616a; border-radius: 9px; background: #143a43; color: white; font-size: 22px; }
.pwa-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.pwa-primary { background: #288fcf !important; color: white !important; }

/* Keep the install prompt visually consistent with the glass login panel.
   These rules are self-contained because the login page does not load the
   authenticated navbar stylesheet that normally defines .control-btn. */
.login-v2 .pwa-modal {
  background: rgba(0, 7, 8, .84);
  backdrop-filter: blur(12px) saturate(125%);
}

.login-v2 .pwa-modal-card {
  width: min(520px, 100%);
  padding: 31px 32px 28px;
  overflow: hidden;
  border: 1px solid rgba(230, 247, 244, .28);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .10), transparent 34%),
    linear-gradient(155deg, rgba(5, 35, 38, .90), rgba(2, 15, 18, .95));
  color: #f5faf9;
  box-shadow:
    0 34px 100px rgba(0, 0, 0, .68),
    inset 0 1px rgba(255, 255, 255, .15);
  backdrop-filter: blur(22px) saturate(135%);
}

.login-v2 .pwa-modal-card::before {
  position: absolute;
  top: 0;
  right: 12%;
  left: 12%;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .82), transparent);
}

.login-v2 .pwa-modal-card h2,
.login-v2 .pwa-modal-card p,
.login-v2 .pwa-modal-card li { color: #b6cac9 !important; }
.login-v2 .pwa-modal-card h2 {
  margin: 6px 44px 10px 0;
  color: #fff !important;
  font-size: 29px;
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.15;
}
.login-v2 .pwa-modal-card > p:not(.pwa-eyebrow) { margin: 0; font-size: 14px; }
.login-v2 .pwa-eyebrow {
  color: #ffc928 !important;
  font-size: 10px;
  letter-spacing: .18em;
}
.login-v2 .pwa-modal-close {
  display: grid;
  place-items: center;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(221, 240, 238, .20);
  border-radius: 11px;
  color: #dce8e7;
  background: rgba(28, 58, 61, .76);
  font: 400 27px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.login-v2 .pwa-modal-close:hover {
  border-color: rgba(255, 201, 40, .58);
  color: #fff;
  background: rgba(43, 78, 81, .92);
  transform: translateY(-1px);
}
.login-v2 .pwa-modal-actions { gap: 11px; margin-top: 24px; }
.login-v2 .pwa-modal-actions .control-btn {
  min-width: 112px;
  min-height: 46px;
  padding: 10px 18px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(221, 240, 238, .20);
  border-radius: 11px;
  color: #f4fbfa !important;
  background: rgba(28, 58, 61, .76);
  box-shadow: inset 0 1px rgba(255, 255, 255, .06);
  font: 700 14px/1.2 Inter, system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
  transition: filter .18s ease, transform .18s ease, border-color .18s ease, background .18s ease;
}
.login-v2 .pwa-modal-actions .control-btn:hover {
  border-color: rgba(221, 240, 238, .34);
  background: rgba(43, 78, 81, .92);
  transform: translateY(-1px);
}
.login-v2 .pwa-modal-actions .pwa-primary {
  border-color: #ffd45b;
  color: #111 !important;
  background: linear-gradient(105deg, #f3b91c, #ffd75f 52%, #f4bc20) !important;
  box-shadow: 0 12px 28px rgba(245, 190, 31, .18), inset 0 1px rgba(255, 255, 255, .48);
}
.login-v2 .pwa-modal-actions .pwa-primary:hover { filter: brightness(1.06); }
.login-v2 .pwa-modal-close:focus-visible,
.login-v2 .pwa-modal-actions .control-btn:focus-visible {
  outline: 3px solid rgba(255, 201, 40, .24);
  outline-offset: 2px;
}

@media (max-width: 560px) {
  .login-v2 .pwa-modal { align-items: flex-end; padding: 10px; }
  .login-v2 .pwa-modal-card { padding: 27px 20px 21px; border-radius: 20px; }
  .login-v2 .pwa-modal-card h2 { font-size: 25px; }
  .login-v2 .pwa-modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .login-v2 .pwa-modal-actions .control-btn { width: 100%; min-width: 0; }
}

@media (max-width: 980px) {
  .glass-navbar {
    top: 6px;
    min-height: 62px;
    margin: 6px 8px;
    padding: 10px 12px;
  }
  .nav-left { min-width: 0; }
  .logo-img { max-width: min(70vw, 330px); height: 32px; }
  .mobile-nav-toggle {
    display: grid;
    gap: 4px;
    width: 42px;
    height: 40px;
    place-content: center;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 9px;
    background: #1f2937;
  }
  .mobile-nav-toggle span { display: block; width: 20px; height: 2px; background: #fff; }
  .nav-center,
  .nav-right {
    display: none;
    flex: 0 0 100%;
    width: 100%;
    padding: 12px;
    border-inline: 1px solid rgba(255,255,255,.16);
    background: #06151a;
  }
  .mobile-nav-open { flex-wrap: wrap; }
  .nav-center { order: 3; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
  .nav-right { order: 4; align-items: stretch; flex-direction: column; border-bottom: 1px solid rgba(255,255,255,.16); border-radius: 0 0 14px 14px; }
  .mobile-nav-open .nav-center { display: grid; }
  .mobile-nav-open .nav-right { display: flex; }
  .mobile-quick-expense { display: block; background: #167ab6; }
  .nav-btn, .control-btn, .logout-btn, .user-box { min-height: 42px; padding: 11px 12px; text-align: center; }
  .control-panel { top: 74px; right: 10px; }
  .panel-card { width: min(270px, calc(100vw - 20px)); }
  body { min-width: 0; overflow-x: hidden; }
  input, select, textarea, button { font-size: 16px; }
  .finance-page, .supplier-accounts-page, .file-explorer-page { width: auto !important; max-width: none !important; margin-inline: 8px !important; }
  .finance-hero, .panel-heading, .hero-actions, .actionbar { align-items: stretch !important; flex-direction: column !important; }
  .hero-actions, .panel-actions { display: grid !important; grid-template-columns: 1fr 1fr; width: 100%; }
  .kpi-grid, .account-grid { grid-template-columns: 1fr 1fr !important; }
  .filter-grid, .form-grid.three { grid-template-columns: 1fr !important; }
  .table-wrap { overflow-x: auto; }
  .finance-table { min-width: 900px; }
  .finance-modal { align-items: flex-end !important; padding: 0 !important; }
  .finance-modal-card { width: 100% !important; max-width: none !important; max-height: 92vh; border-radius: 18px 18px 0 0 !important; }
}

@media (max-width: 560px) {
  .finance-page .kpi-grid,
  .finance-page .account-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .finance-page .hero-actions,
  .finance-page .panel-actions { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .logo-img { max-width: 72vw; height: 28px; }
  .nav-center { grid-template-columns: 1fr; max-height: 56vh; overflow-y: auto; }
}

@media print {
  .mobile-nav-toggle, .pwa-modal, .pwa-install-button { display: none !important; }
}
