/* Headquarters responsive visual system — loaded after feature styles. */
.app-icon-sprite {
  height: 0;
  overflow: hidden;
  position: absolute;
  width: 0;
}

@media (max-width: 1180px), (max-width: 1400px) and (pointer: coarse) {
  :root {
    --hq-surface: #ffffff;
    --hq-canvas: #f2f5f8;
    --hq-border: #dce4ec;
    --hq-navy: #12263f;
    --hq-teal: #087f75;
    --hq-teal-soft: #e8f5f2;
    --hq-shadow: 0 10px 28px rgba(21, 39, 58, 0.08);
  }

  body {
    background: var(--hq-canvas);
    color: var(--hq-navy);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  }

  .workspace {
    background:
      radial-gradient(circle at 92% 0%, rgba(8, 127, 117, 0.07), transparent 32%),
      var(--hq-canvas);
  }

  .topbar,
  .panel,
  .dashboard-home-header,
  .billing-hub-card,
  .mobile-settings-card {
    border-color: var(--hq-border);
    box-shadow: var(--hq-shadow);
  }

  .topbar {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--hq-border);
    border-radius: 16px;
    padding: 14px 16px;
  }

  .topbar h1 {
    color: var(--hq-navy);
    font-size: clamp(20px, 3vw, 27px);
    letter-spacing: -0.02em;
  }

  .panel {
    border-radius: 16px;
  }

  button,
  input,
  select,
  textarea {
    border-radius: 10px;
  }

  input,
  select,
  textarea {
    border-color: #cfd9e4;
    background-color: #fff;
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: var(--hq-teal);
    box-shadow: 0 0 0 3px rgba(8, 127, 117, 0.12);
    outline: 0;
  }

  .mobile-home-button {
    background: rgba(255, 255, 255, 0.96);
    border-color: #cfd9e4;
    box-shadow: 0 7px 18px rgba(21, 39, 58, 0.09);
    color: var(--hq-navy);
    font-weight: 750;
  }

  .dashboard-shortcuts {
    gap: clamp(10px, 1.4vw, 16px);
    margin: 0;
  }

  .dashboard-home-header {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--hq-border);
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(21, 39, 58, 0.08);
    padding: clamp(10px, 1.5vw, 16px);
  }

  .dashboard-home-brand .brand-mark {
    background: linear-gradient(145deg, #087f75, #075f59);
    border-radius: 13px;
    box-shadow: 0 7px 16px rgba(8, 127, 117, 0.22);
    color: #fff;
  }

  .dashboard-home-brand strong {
    color: var(--hq-navy);
    font-size: clamp(16px, 2.2vw, 21px);
    font-weight: 800;
    letter-spacing: -0.02em;
  }

  .dashboard-home-brand #dashboard-admin-user-label {
    color: #708093;
    font-size: clamp(10px, 1.45vw, 13px);
  }

  .launcher-header-actions {
    background: #f5f7fa;
    border-color: #e0e7ef;
    border-radius: 13px;
    gap: 2px;
    padding: 3px;
  }

  .launcher-header-actions > button {
    min-height: 36px;
  }

  .launcher-header-actions [data-hq-inbox] {
    background: var(--hq-teal);
    border-color: var(--hq-teal);
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(8, 127, 117, 0.18);
    font-weight: 750;
  }

  .dashboard-home-header .launcher-language-toggle {
    color: #2457c5;
  }

  .dashboard-shortcut-grid {
    gap: clamp(9px, 1.35vw, 14px);
  }

  .dashboard-shortcut-grid .dashboard-shortcut {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--hq-border);
    border-radius: 17px;
    box-shadow: 0 8px 22px rgba(21, 39, 58, 0.07);
    color: var(--hq-navy);
    position: relative;
    transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
  }

  .dashboard-shortcut-grid .dashboard-shortcut::after {
    background: #cbd7e3;
    border-radius: 999px;
    content: "";
    height: 3px;
    left: clamp(10px, 1.4vw, 17px);
    position: absolute;
    top: 0;
    width: 30px;
  }

  .dashboard-shortcut-grid .dashboard-shortcut:active {
    border-color: #9bcac5;
    box-shadow: 0 4px 12px rgba(21, 39, 58, 0.09);
    transform: scale(0.985);
  }

  .dashboard-shortcut .nav-icon {
    background: var(--hq-teal-soft);
    border: 1px solid rgba(8, 127, 117, 0.08);
    border-radius: 11px;
    color: var(--hq-teal);
  }

  .dashboard-shortcut .nav-icon svg {
    fill: none;
    height: 55%;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 55%;
  }

  .sidebar-nav .nav-icon {
    background: var(--hq-teal-soft);
    border: 1px solid rgba(8, 127, 117, 0.08);
    color: var(--hq-teal);
  }

  .sidebar-nav .nav-icon svg {
    fill: none;
    height: 55%;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 55%;
  }

  .sidebar-nav .nav-icon svg use[href="#icon-dashboard"] {
    fill: currentColor;
    stroke: none;
  }

  .dashboard-shortcut .nav-icon svg use[href="#icon-dashboard"] {
    fill: currentColor;
    stroke: none;
  }

  .dashboard-shortcut .nav-copy strong {
    color: var(--hq-navy);
    font-weight: 780;
    letter-spacing: -0.015em;
  }

  .dashboard-shortcut .nav-copy small {
    color: #718096;
  }

  .dashboard-shortcut-grid .dashboard-shortcut.active,
  .dashboard-shortcut-grid .dashboard-shortcut.active:hover {
    background: linear-gradient(145deg, #0d837a, #086a63);
    border-color: #08756d;
    box-shadow: 0 10px 24px rgba(8, 127, 117, 0.2);
  }

  .dashboard-shortcut.active::after {
    background: rgba(255, 255, 255, 0.62);
  }

  .dashboard-shortcut.active .nav-copy strong {
    color: #fff;
  }
}

/* Phone: compact two-column launcher that remains fully visible. */
@media (max-width: 599px) {
  body.home-launcher-open .workspace {
    padding-left: max(9px, env(safe-area-inset-left));
    padding-right: max(9px, env(safe-area-inset-right));
  }

  body.home-launcher-open .dashboard-home-header {
    border-radius: 16px;
    gap: 7px;
    padding: clamp(8px, 1.15dvh, 12px);
  }

  body.home-launcher-open .dashboard-home-brand {
    gap: 8px;
  }

  body.home-launcher-open .dashboard-home-brand .brand-mark {
    flex-basis: clamp(34px, 5.3dvh, 42px);
    height: clamp(34px, 5.3dvh, 42px);
    width: clamp(34px, 5.3dvh, 42px);
  }

  body.home-launcher-open .launcher-header-actions {
    gap: 1px;
  }

  body.home-launcher-open .launcher-header-actions > button {
    font-size: clamp(10px, 1.7dvh, 13px);
    min-height: clamp(32px, 4.7dvh, 38px);
    padding: 4px 8px;
  }

  body.home-launcher-open .dashboard-home-header .launcher-language-toggle {
    width: clamp(60px, 17vw, 76px);
  }

  body.home-launcher-open .dashboard-shortcut-grid .dashboard-shortcut {
    border-radius: 15px;
  }
}

/* iPad portrait: two balanced columns avoid an orphaned final card. */
@media (min-width: 600px) and (max-width: 1180px) and (orientation: portrait) {
  body.home-launcher-open .workspace {
    padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  body.home-launcher-open .dashboard-shortcut-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
  }

  body.home-launcher-open .dashboard-shortcut-grid .dashboard-shortcut {
    align-content: center;
    justify-items: center;
    padding: clamp(12px, 1.8vw, 19px);
    text-align: center;
  }
}

/* iPad landscape: a concise two-row command center. */
@media (min-width: 760px) and (max-width: 1400px) and (orientation: landscape) and (pointer: coarse) {
  body.home-launcher-open .workspace {
    padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  body.home-launcher-open .dashboard-shortcut-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  body.home-launcher-open .dashboard-shortcut-grid .dashboard-shortcut {
    align-content: center;
    justify-items: center;
    padding: clamp(10px, 1.4vw, 17px);
    text-align: center;
  }
}

/* Invoice folders and review forms must shrink within a phone viewport. */
@media (max-width: 900px) {
  :is(#scanned-invoices-view, #warehouse-invoices-view),
  :is(#scanned-invoices-view, #warehouse-invoices-view) :is(.panel, .scanned-invoice-groups, .invoice-browser-week-page, .invoice-browser-invoice-page, .invoice-browser-week-summary, .scanned-admin-card, .invoice-original-preview, .invoice-original-pages, figure) {
    min-width: 0;
    max-width: 100%;
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) :is(.invoice-browser-week-page, .invoice-browser-invoice-page, .invoice-original-pages) {
    grid-template-columns: minmax(0, 1fr);
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-groups {
    grid-template-columns: minmax(0, 1fr);
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) :is(p, small, strong, span, h3) {
    overflow-wrap: anywhere;
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-review {
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) :is(input, select, textarea, button) {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 16px;
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-review > * {
    width: 100%;
    min-width: 0;
    grid-column: 1 / -1;
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) :is(.scanned-admin-card-main, .scanned-admin-files, .inline-header) {
    flex-wrap: wrap;
    min-width: 0;
    gap: 10px;
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-admin-card-main > div { min-width: 0; flex: 1 1 180px; }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-admin-facts span { max-width: 100%; }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-original-pages :is(img, iframe) {
    width: 100%; min-width: 0; max-width: 100%;
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-browser-toolbar {
    width: 100%; min-width: 0; flex-wrap: wrap;
  }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .invoice-browser-toolbar > div { width: 100%; }
  :is(#scanned-invoices-view, #warehouse-invoices-view) .scanned-invoice-filters { grid-template-columns: minmax(0, 1fr); }
  body:has(:is(#scanned-invoices-view, #warehouse-invoices-view).active) .mobile-home-button {
    position: absolute;
    top: max(52px, calc(env(safe-area-inset-top, 0px) + 12px));
  }
  body:has(:is(#scanned-invoices-view, #warehouse-invoices-view).active) .workspace {
    min-width: 0;
    width: 100%;
    padding-top: max(112px, calc(env(safe-area-inset-top, 0px) + 72px));
  }
}

/* Tablets have room for more launcher entries than phones. */
@media (min-width:768px) and (max-width:1400px) {
 body.home-launcher-open .dashboard-shortcut-grid{grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:none;grid-auto-rows:minmax(100px,1fr);overflow-y:auto;touch-action:pan-y}
}
@media (min-width:1024px) and (max-width:1400px) {
 body.home-launcher-open .dashboard-shortcut-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
}
