/* ═══════════════════════════════════════════════════════════════
   Skucast unified topbar — single source of truth
   Used across all 10 pages (dashboard, forecaster, POs, etc.)
   ═══════════════════════════════════════════════════════════════ */

/* Reset for body so topbar sits flush */
body { margin: 0; }

.topbar{
  background:#fff;
  border-bottom:1px solid #e5e7eb;
  position:sticky;
  top:0;
  z-index:50;
  box-shadow:0 1px 2px rgba(0,0,0,.02);
}
.topbar-inner{
  max-width:1400px;
  margin:0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 16px;
  gap:14px;
  height:54px;
}
.topbar-brand{
  display:flex;
  align-items:center;
  gap:10px;
  text-decoration:none;
  flex-shrink:0;
}
.topbar-logo-img{
  height:36px;
  width:auto;
  display:block;
  /* SVG aspect is 10:3; ~120px wide at 36px tall */
}
.topbar-merchant{
  font-size:10px;
  font-weight:700;
  letter-spacing:.12em;
  background:#1a1a1a;
  color:#fff;
  padding:3px 8px;
  border-radius:3px;
  white-space:nowrap;
}
.topbar-nav{
  display:flex;
  align-items:center;
  gap:4px;
  flex:1;
  justify-content:center;
  /* No more overflow scroll needed — grouped dropdowns keep top-level items
     down to 5 max, which fits any viewport. */
}
/* Direct top-level link (Dashboard) */
.topbar-direct,
.topbar-dropdown-trigger{
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:8px 12px;
  border:none;
  border-radius:6px;
  background:transparent;
  color:#444;
  text-decoration:none;
  font-size:13px;
  font-weight:600;
  font-family:inherit;
  cursor:pointer;
  transition:background .12s, color .12s;
  white-space:nowrap;
}
.topbar-direct:hover,
.topbar-dropdown-trigger:hover{ background:#f4f4f6; color:#222; }
.topbar-direct.active,
.topbar-dropdown-trigger.active{ color:#cc0000; background:#fbeaea; }
.topbar-dropdown-trigger .caret{
  font-size:10px;
  margin-left:1px;
  opacity:.6;
  transition:transform .15s;
}
.topbar-dropdown.open .topbar-dropdown-trigger .caret{ transform:rotate(180deg); opacity:1; }

/* Dropdown menu */
.topbar-dropdown{ position:relative; }
.topbar-dropdown-menu{
  position:absolute;
  top:100%;
  left:0;
  margin-top:4px;
  min-width:200px;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:8px;
  box-shadow:0 6px 20px rgba(0,0,0,.10);
  padding:4px 0;
  z-index:120;
  display:none;
}
.topbar-dropdown.open > .topbar-dropdown-menu{ display:block; }
/* Hover-open on devices with a fine pointer (desktop mouse) */
@media (hover:hover) and (pointer:fine){
  .topbar-dropdown:hover > .topbar-dropdown-menu{ display:block; }
}
.topbar-dropdown-menu a{
  display:block;
  padding:8px 14px;
  color:#1a1a1a;
  text-decoration:none;
  font-size:13px;
  font-weight:500;
  white-space:nowrap;
}
.topbar-dropdown-menu a:hover{ background:#f4f4f6; color:#1a1a1a; }
.topbar-dropdown-menu a.active{ color:#cc0000; background:#fbeaea; font-weight:600; }

/* On narrower viewports collapse the merchant tag + hide the user badge
   so nav has more room. */
@media(max-width:1100px){
  .topbar-user{ display:none; }
  .topbar-merchant{ display:none; }
}
@media(max-width:880px){
  .topbar-time{ display:none; }
}
.topbar-right{
  display:flex;
  align-items:center;
  gap:10px;
  font-size:11px;
  color:#666;
  flex-shrink:0;
}
.topbar-time{ color:#666; font-size:11px; white-space:nowrap; }
.topbar-user{ color:#1a1a1a; font-size:12px; font-weight:600; white-space:nowrap; padding:4px 10px; background:#f4f4f6; border-radius:14px; }

/* Alerts bell — always visible, badge appears when there are unread alerts */
.topbar-bell{
  position:relative;
  background:transparent;
  border:1px solid #e5e7eb;
  border-radius:6px;
  padding:5px 8px;
  font-size:15px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  min-width:34px;
  height:30px;
  line-height:1;
}
.topbar-bell:hover{ background:#f4f4f6; }
.topbar-bell-badge{
  position:absolute;
  top:-5px;
  right:-5px;
  background:#cc0000;
  color:#fff;
  font-size:10px;
  font-weight:700;
  min-width:18px;
  height:18px;
  border-radius:9px;
  padding:0 4px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:2px solid #fff;
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
}

/* Alerts inbox modal (used on every page via topbar bell) */
.skucast-modal-bd{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.5);
  display:none;
  align-items:flex-start;
  justify-content:center;
  z-index:200;
  padding:60px 20px 20px;
}
.skucast-modal-bd.show{ display:flex; }
.skucast-modal-card{
  background:#fff;
  border-radius:10px;
  box-shadow:0 10px 40px rgba(0,0,0,.3);
  max-height:calc(100vh - 80px);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
/* (.topbar-user hidden via the 1180px breakpoint below near .topbar-nav a) */
.topbar-btn{
  background:transparent;
  border:1px solid #e5e7eb;
  border-radius:6px;
  padding:5px 10px;
  font-size:11px;
  font-weight:600;
  color:#444;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:5px;
  white-space:nowrap;
}
.topbar-btn:hover{ background:#f4f4f6; }

/* Hamburger button — hidden on desktop, shown on mobile */
.topbar-hamburger{
  display:none;
  background:transparent;
  border:1px solid #e5e7eb;
  border-radius:7px;
  padding:7px 10px;
  cursor:pointer;
  align-items:center;
  justify-content:center;
  width:40px;
  height:36px;
  position:relative;
}
.topbar-hamburger:hover{ background:#f4f4f6; }
.topbar-hamburger .bar{
  display:block;
  width:18px;
  height:2px;
  background:#1a1a1a;
  border-radius:1px;
  position:absolute;
  left:11px;
  transition:transform .2s, opacity .15s, top .2s;
}
.topbar-hamburger .bar:nth-child(1){ top:11px; }
.topbar-hamburger .bar:nth-child(2){ top:17px; }
.topbar-hamburger .bar:nth-child(3){ top:23px; }
body.mobile-menu-open .topbar-hamburger .bar:nth-child(1){ top:17px; transform:rotate(45deg); }
body.mobile-menu-open .topbar-hamburger .bar:nth-child(2){ opacity:0; }
body.mobile-menu-open .topbar-hamburger .bar:nth-child(3){ top:17px; transform:rotate(-45deg); }

/* Mobile drawer backdrop */
.topbar-backdrop{
  display:none;
  position:fixed;
  inset:54px 0 0 0;
  background:rgba(0,0,0,.45);
  z-index:48;
  opacity:0;
  transition:opacity .2s;
}
body.mobile-menu-open .topbar-backdrop{ display:block; opacity:1; }

/* Mobile */
@media (max-width:780px){
  .topbar-inner{ height:54px; padding:0 12px; gap:10px; }
  .topbar-merchant{ font-size:9px; padding:3px 6px; letter-spacing:.08em; }
  .topbar-logo-img{ height:30px; }
  .topbar-time{ display:none; }
  /* Hamburger replaces inline nav */
  .topbar-hamburger{ display:flex; }
  .topbar-nav{
    position:fixed;
    top:54px;
    right:0;
    bottom:0;
    width:84%;
    max-width:320px;
    background:#fff;
    flex-direction:column;
    align-items:stretch;
    justify-content:flex-start;
    overflow-y:auto;
    overflow-x:hidden;
    padding:8px 0 24px;
    gap:0;
    box-shadow:-4px 0 16px rgba(0,0,0,.10);
    transform:translateX(100%);
    transition:transform .22s cubic-bezier(.4,0,.2,1);
    z-index:49;
  }
  body.mobile-menu-open .topbar-nav{ transform:translateX(0); }
  /* Mobile: dropdowns expand inline — show as group headers with items
     stacked beneath. No hover-open or click-toggle needed. */
  .topbar-dropdown{ display:flex; flex-direction:column; }
  .topbar-dropdown-trigger{
    padding:10px 20px;
    font-size:11px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:.06em;
    color:#888;
    background:transparent !important;
    pointer-events:none;     /* mobile = always-open, click does nothing */
    border-bottom:1px solid #f1f3f5;
  }
  .topbar-dropdown-trigger .caret{ display:none; }
  .topbar-dropdown-trigger.active{ color:#cc0000; background:transparent !important; }
  .topbar-dropdown-menu{
    position:static;
    display:block !important;
    border:none;
    box-shadow:none;
    padding:0 0 6px 0;
    margin:0;
    background:transparent;
    min-width:0;
  }
  .topbar-direct,
  .topbar-dropdown-menu a{
    display:block;
    padding:13px 20px;
    font-size:14px;
    font-weight:600;
    border-radius:0;
    min-height:44px;     /* iOS HIG tap target */
    border-bottom:1px solid #f7f8fa;
  }
  .topbar-direct.active,
  .topbar-dropdown-menu a.active{
    background:#fbeaea;
    border-left:3px solid #cc0000;
    padding-left:17px;
    color:#cc0000;
  }
  .topbar-direct:hover,
  .topbar-dropdown-menu a:hover{ background:#f4f4f6; }
  /* Right-side: shrink/hide some controls. Keep Refresh (sticky, useful) but
     compress padding and hide the logout button — pages have their own auth flow. */
  .topbar-right{ gap:6px; }
  .topbar-btn{ padding:6px 9px; font-size:11px; }
  /* Hide logout glyph on mobile — too cramped, too easy to mis-tap */
  .topbar-right a.topbar-btn[href*="logout"]{ display:none; }
}

/* ═══════════════════════════════════════════════════════════════
   Page header — replaces old dark .panel-hdr with a real <h1>
   ═══════════════════════════════════════════════════════════════ */
.page-header{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:12px;
  padding:18px 0 14px 0;
}
.page-header h1{
  margin:0;
  font-size:20px;
  font-weight:800;
  letter-spacing:-.01em;
  color:#1a1a1a;
}
.page-header .page-sub{
  font-size:12px;
  color:#666;
  margin-top:2px;
}
.page-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

/* ═══════════════════════════════════════════════════════════════
   Site-wide mobile polish
   Loaded on every page via topbar.css. Pages can still override in
   their own <style> blocks. Goals:
     - Consistent padding on small screens
     - Stack form controls so they don't overflow
     - Tap targets ≥44px (Apple HIG)
     - Tables remain horizontally scrollable but breathe
     - iOS doesn't zoom on input focus (font-size:16px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width:780px){
  /* Standard page wrap — tighter padding everywhere */
  .wrap{ padding: 12px !important; }

  /* Page header — vertical stack on phones */
  .page-hdr{ gap: 8px !important; margin-bottom: 12px !important; }
  .page-title{ font-size: 22px !important; line-height: 1.2; }
  .page-sub{ font-size: 12px !important; }

  /* Controls / filters bars — stack rows so each is tappable */
  .controls{ gap: 8px !important; padding: 10px 12px !important; }
  .controls .control-group,
  .controls .search-box{ width: 100%; min-width: 0; }
  .controls .control-group select,
  .controls .control-group input[type=number]{ flex: 1; min-width: 0; }

  /* iOS prevents zoom-on-focus only when input font-size ≥16px */
  input[type=text], input[type=search], input[type=email],
  input[type=number], input[type=tel], input[type=url],
  input[type=password], select, textarea{
    font-size: 16px;
  }

  /* Modals: fill most of mobile screen, no awkward gutters */
  .modal-bg{ padding: 8px !important; }
  .modal{ max-width: 100% !important; border-radius: 10px !important; }
  .modal-hdr{ padding: 12px 14px !important; }
  .modal-body{ padding: 14px !important; }
  .modal-ftr{ padding: 12px 14px !important; flex-wrap: wrap; }
  .modal-ftr .btn{ flex: 1; min-width: 0; justify-content: center; }

  /* Alerts inbox modal (.skucast-modal-*) — full-screen sheet on phones.
     Desktop inline styles set width:100%;max-width:520px on the card; on a
     phone that left an awkward floating panel with a 60px top gutter. Make it
     edge-to-edge so it reads as a proper mobile screen. */
  .skucast-modal-bd{ padding: 0 !important; align-items: stretch; }
  .skucast-modal-card{
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    height: 100vh;
    height: 100dvh;
    border-radius: 0 !important;
  }
  #skucast-inbox-body{ max-height: none !important; flex: 1 1 auto; }

  /* Tables: keep horizontal scroll wrappers + tighter cell padding.
     Pages can override per-table; this is the safe baseline. */
  table th, table td{ padding: 8px 6px; }

  /* Buttons: give them breathing room when row-wrapped */
  .btn{ min-height: 40px; }

  /* Hide page-level Refresh buttons — topbar has one already */
  .page-hdr button[onclick*="reload" i],
  .page-hdr button[onclick*="loadAll" i],
  .page-hdr .btn-ghost[title*="refresh" i],
  .page-hdr .refresh-btn,
  .page-actions .refresh-btn{ display: none; }
}

/* ═══════════════════════════════════════════════════════════════
   Underline tabs — replaces button-style tabs across pages
   Pages can opt in by using class="tabs-underline"
   ═══════════════════════════════════════════════════════════════ */
.tabs-underline{
  display:flex;
  gap:2px;
  border-bottom:1px solid #e5e7eb;
  flex-wrap:wrap;
  margin-bottom:0;
}
.tabs-underline .tab{
  padding:8px 14px;
  font-size:12px;
  font-weight:600;
  color:#666;
  background:transparent;
  border:0;
  border-bottom:2px solid transparent;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:6px;
  margin-bottom:-1px;
  text-transform:none;
  letter-spacing:0;
}
.tabs-underline .tab:hover{ color:#222; }
.tabs-underline .tab.on,
.tabs-underline .tab.active{
  color:#cc0000;
  border-bottom-color:#cc0000;
}
.tabs-underline .tab .cnt{
  background:#eee;
  color:#555;
  padding:1px 7px;
  border-radius:10px;
  font-size:10px;
  font-weight:700;
}
.tabs-underline .tab.on .cnt,
.tabs-underline .tab.active .cnt{
  background:#fbeaea;
  color:#cc0000;
}
