/* Gemini-created mobile styling, adapted to the existing drawer, forms and roles. */
.nj-bottom-nav,.nj-mobile-home,.nj-app-name { display:none; }
.topbar .signout { color:#334052; }
[hidden] { display:none!important; }
:root {
  --nj-charcoal: #181c23;
  --nj-ink: #20262f;
  --nj-crimson: #bd2031;
  --nj-pale: #f3f5f7;
  --nj-white: #ffffff;
  --nj-border: #e2e5e9;
  --nj-success: #198754;
  --nj-warning: #ffc107;
  --nj-orange: #fd7e14;
  --nj-danger: #dc3545;
  --nj-info: #0dcaf0;
  --nj-focus-ring: rgba(189, 32, 49, 0.4);
}

@media (max-width: 760px) {
  /* TWA Base & Safe Areas */
  html, body {
    background-color: var(--nj-pale);
    color: var(--nj-ink);
    font-family: system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
    margin: 0; padding: 0;
  }
  
  /* Reset Workspace & Hide Desktop Sidebar */
  .workspace {
    width: 100%;
    margin: 0;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  /* Top Bar (App Header) */
  header.topbar, .nj-app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--nj-charcoal);
    color: var(--nj-white);
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--nj-crimson);
  }
  header.topbar #menu-toggle {
    min-height: 48px;
    min-width: 48px;
    background: transparent;
    border: none;
    color: var(--nj-white);
    padding: 0;
  }

  /* Bottom Navigation (Replaces Sidebar) */
  .nj-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--nj-white);
    border-top: 1px solid var(--nj-border);
    display: flex;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 20;
  }
  .nj-bottom-nav a, .nj-bottom-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    color: var(--nj-ink);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
  }
  .nj-bottom-nav a.active { color: var(--nj-crimson); }

  /* Headings & Page Architecture */
  .page-heading {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--nj-white);
    border-bottom: 1px solid var(--nj-border);
  }
  .page-heading h1 { margin: 0; font-size: 1.5rem; color: var(--nj-charcoal); }
  .page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  /* Touch & Accessibility Standards */
  button, .btn, .page-actions a {
    min-height: 48px;
    padding: 0 16px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
  }
  .btn-primary { background: var(--nj-crimson); color: var(--nj-white); border: none; }
  .btn-secondary { background: var(--nj-pale); color: var(--nj-ink); border: 1px solid var(--nj-border); }
  
  /* Form Inputs (Strict 16px to prevent zoom) */
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea, .form-control {
    width: 100%;
    font-size: 16px;
    padding: 12px 16px;
    min-height: 48px;
    border: 1px solid var(--nj-border);
    border-radius: 6px;
    background: var(--nj-white);
    color: var(--nj-ink);
    box-sizing: border-box;
  }
  input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--nj-crimson);
    outline-offset: -1px;
    border-color: var(--nj-crimson);
  }

  /* Office Mobile Home Grid */
  .nj-mobile-home {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
  }
  .nj-mobile-home .module-card {
    background: var(--nj-white);
    border: 1px solid var(--nj-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: var(--nj-charcoal);
    min-height: 100px;
  }

  /* Installer Job List & Rows */
  .install-filter { padding: 16px; background: var(--nj-white); border-bottom: 1px solid var(--nj-border); }
  .job-list { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
  .job-row {
    background: var(--nj-white);
    border: 1px solid var(--nj-border);
    border-radius: 12px;
    overflow: hidden;
  }
  .job-row .job-main {
    display: flex;
    flex-direction: column;
    padding: 16px;
    text-decoration: none;
    color: var(--nj-ink);
  }
  .job-row strong.title { font-size: 1.125rem; color: var(--nj-charcoal); margin-bottom: 4px; }
  .job-row span.summary { font-size: 0.875rem; color: #555; }
  .job-row small.ref { margin-top: 8px; font-size: 0.75rem; font-weight: 600; color: var(--nj-crimson); }
  .job-state { padding: 8px 16px; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; border-top: 1px solid var(--nj-border); }
  
  /* Installer Form Accordions & Scanner */
  form#job-form.install-form { padding: 0; padding-bottom: 150px; }
  details.job-section {
    background: var(--nj-white);
    border: 1px solid var(--nj-border);
    border-radius: 12px;
    margin-bottom: 12px;
  }
  details.job-section > summary {
    min-height: 48px;
    padding: 0 16px;
    font-weight: 600;
    display: list-item;
    align-content: center;
    cursor: pointer;
  }
  details.job-section[open] > summary { border-bottom: 1px solid var(--nj-border); }
  .job-fields { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
  /* Fixed Save Bar (Installer Form) */
  .save-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--nj-white);
    border-top: 2px solid var(--nj-charcoal);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 21;
  }
  .save-bar .status { font-size: 0.875rem; font-weight: 600; }
  
  /* Data Tables (Fallback for un-carded views) */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { border-collapse: collapse; }
  .table-wrap th, .table-wrap td { padding: 12px; border-bottom: 1px solid var(--nj-border); text-align: left; }

  /* Reduced Motion */
  @media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  }
}

/* Application integration and existing component compatibility. */
@media (max-width:760px) {
  body { --nj-nav-height:72px; }
  body:has(#job-form),body.nj-keyboard-open { --nj-nav-height:0px; }
  .workspace { padding-bottom:calc(var(--nj-nav-height) + env(safe-area-inset-bottom)); min-width:0; }
  #main-content { padding:20px 16px 0; }
  header.topbar { flex-wrap:wrap; height:auto; min-height:76px; gap:4px 12px; padding:8px 16px; }
  .nj-app-name { display:block; flex:1; font-size:17px; font-weight:700; letter-spacing:-.02em; }
  header.topbar .account { flex-basis:100%; justify-content:flex-end; margin:0; gap:16px; border-top:1px solid #39404a; }
  header.topbar .identity { margin-right:auto; max-width:150px; color:#fff; font-size:12px; }
  header.topbar .identity small { color:#c6ccd5; }
  header.topbar .text-link,header.topbar .signout { color:#fff; min-height:44px; font-size:12px; }
  header.topbar .signout { background:#262d37; border-color:#556171; }
  header.topbar .signout:hover { background:#39404a; }
  header.topbar #menu-toggle:hover { background:#303742; }
  .page-heading { background:transparent; padding:0 0 20px; margin:8px 0 24px; }
  .page-heading h1 { font-size:26px; line-height:1.2; letter-spacing:-.025em; }
  .page-actions:empty { display:none; }
  .page-actions { gap:8px; }
  button,.button,.page-actions a { font-size:14px; }
  .nj-bottom-nav { min-height:72px; box-shadow:0 -4px 16px rgb(24 28 35 / .04); }
  .nj-bottom-nav a,.nj-bottom-nav button { gap:4px; border:0; border-radius:0; background:#fff; padding:8px 4px; font-size:12px; min-width:0; }
  .nj-bottom-nav svg { width:22px; height:22px; display:block; }
  .nj-bottom-nav a.active,.nj-bottom-nav button.active { color:var(--nj-crimson); background:#fcf1f3; box-shadow:none; }
  .nj-bottom-nav a:hover,.nj-bottom-nav button:hover { background:#f3f5f7; }
  .nj-bottom-nav :focus-visible,.nj-mobile-home a:focus-visible { outline:3px solid var(--nj-crimson); outline-offset:-3px; }
  body:has(#job-form) .nj-bottom-nav,.nj-keyboard-open .nj-bottom-nav { display:none; }
  .nj-home-heading { grid-column:1/-1; padding:0 0 6px; }
  .nj-home-heading h2 { font-size:20px; margin:0 0 6px; }
  .nj-home-heading p { font-size:14px; color:#586371; margin:0; }
  .nj-mobile-home { padding:0; gap:10px; margin-bottom:32px; }
  .nj-mobile-home .module-card { align-items:flex-start; text-align:left; padding:18px; gap:8px; min-width:0; }
  .nj-mobile-home strong { font-size:15px; font-weight:650; }
  .nj-mobile-home small { font-size:12px; color:#586371; }
  .module-icon { color:var(--nj-crimson); margin-bottom:8px; }
  .nj-mobile-home svg { width:22px; height:22px; flex-shrink:0; display:block; }
  .module-row { grid-column:1/-1; display:flex; align-items:center; gap:12px; padding:16px; min-height:60px; background:#fff; color:var(--nj-ink); border:1px solid var(--nj-border); border-radius:10px; text-decoration:none; }
  .module-row strong { flex:1; }
  .module-row>span:first-child { color:#586371; }
  .module-row>svg { width:18px; }
  .module-count { font-variant-numeric:tabular-nums; color:#586371; font-size:13px; }
  .nj-mobile-home a:hover { background:#f9fafb; text-decoration:none; }
  main:has(.nj-mobile-home) .welcome { display:none; }
  .installation-app .install-intro { margin:0 0 16px; font-size:14px; color:#586371; }
  .install-help { margin-bottom:16px; }
  .install-filter { border:1px solid var(--nj-border); border-radius:12px; margin:16px 0; }
  .install-filter button { width:100%; }
  .installation-app .job-list { padding:0; border:0; border-radius:0; background:transparent; overflow:visible; gap:12px; }
  .installation-app .job-row { padding:0; gap:0; border:1px solid var(--nj-border); border-radius:12px; overflow:visible; }
  .job-row .job-main { width:100%; box-sizing:border-box; padding:20px; }
  .job-row .job-main:focus-visible { outline-offset:-3px; border-radius:12px; }
  .job-row strong.title { font-size:18px; overflow-wrap:anywhere; }
  .job-row small.ref { color:#586371; font-size:12px; line-height:1.6; }
  .job-row-actions { padding:0 20px 18px; width:100%; box-sizing:border-box; justify-content:space-between; }
  .job-state { padding:6px 10px; text-transform:none; border:0; font-weight:600; }
  .installation-app details.job-section { border-radius:12px; margin:16px 0; }
  .installation-app details.job-section>summary { min-height:60px; padding:16px; font-size:17px; box-sizing:border-box; }
  .installation-app .job-fields { padding:18px; gap:22px; }
  .installation-app .save-bar { border-radius:0; margin:0; display:block; padding:12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .save-bar .install-actions { margin-top:8px; }
  .save-bar>span { font-size:12px; }
  .nj-keyboard-open .save-bar { position:static; }
  .installation-app input[type=radio],.installation-app input[type=checkbox] { min-height:22px; width:22px; height:22px; accent-color:var(--nj-crimson); }
  .installation-app .test-option { min-height:48px; }
  .login-body { background:var(--nj-charcoal); }
  .login-art { padding:28px 24px 22px; background:var(--nj-charcoal); }
  .login-art .brand-image { width:220px; height:104px; object-fit:contain; }
  .login-panel { background:#fff; border-radius:24px 24px 0 0; padding:32px 24px max(32px,env(safe-area-inset-bottom)); min-height:calc(100dvh - 180px); }
  .login-form h1 { font-size:28px; line-height:1.2; letter-spacing:-.025em; margin-bottom:12px; }
  .login-form>p { line-height:1.6; }
  .login-form form { margin-top:28px; }
  .login-form input:not([type=checkbox]) { min-height:52px; }
  .login-form .remember-login { gap:12px; min-height:48px; align-items:center; font-size:14px; }
  .login-form input[type=checkbox] { width:20px; height:20px; min-height:20px; flex-shrink:0; accent-color:var(--nj-crimson); }
  .login-form .primary { min-height:52px; }
  .login-help { font-size:13px; line-height:1.6; }
  .table-wrap { max-width:100%; }
  a { text-underline-offset:3px; }
  .nj-keyboard-open .topbar { position:static; }
}
@media (min-width:761px) and (max-width:1024px) {
  .installation-app .install-filter { flex-wrap:wrap; }
  .installation-app .job-fields { grid-template-columns:1fr; }
}
@media print { .nj-bottom-nav,.nj-mobile-home,.nj-app-name,#app-connection { display:none!important; } }

