/* ============================================================================
   Pourmetrics Design System
   A clean, modern SaaS design inspired by Stripe/Linear/Notion.
   ============================================================================ */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */

:root {
  /* Brand */
  --pm-gold:       #F5B335;
  --pm-gold-light: #FEF3C7;
  --pm-gold-dark:  #D4960A;
  --pm-slate:      #1E2933;
  --pm-slate-mid:  #334155;
  --pm-slate-light:#475569;

  /* Surfaces */
  --pm-bg:         #F8FAFC;
  --pm-card:       #FFFFFF;
  --pm-sidebar:    #1E2933;
  --pm-sidebar-hover: #2A3744;
  --pm-sidebar-active: rgba(245,179,53,0.12);

  /* Borders */
  --pm-border:     #E2E8F0;
  --pm-border-light:#F1F5F9;

  /* Text */
  --pm-text:       #0F172A;
  --pm-text-secondary: #64748B;
  --pm-text-muted: #94A3B8;
  --pm-text-on-dark: #E2E8F0;
  --pm-text-on-dark-muted: #94A3B8;

  /* Status */
  --pm-success:    #16A34A;
  --pm-success-bg: #DCFCE7;
  --pm-success-border: #BBF7D0;
  --pm-warning:    #F59E0B;
  --pm-warning-bg: #FEF3C7;
  --pm-warning-border: #FDE68A;
  --pm-danger:     #DC2626;
  --pm-danger-bg:  #FEE2E2;
  --pm-danger-border: #FECACA;
  --pm-info:       #2563EB;
  --pm-info-bg:    #DBEAFE;
  --pm-info-border:#BFDBFE;

  /* Shadows */
  --pm-shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --pm-shadow:     0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --pm-shadow-md:  0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --pm-shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

  /* Radius */
  --pm-radius-sm:  6px;
  --pm-radius:     8px;
  --pm-radius-md:  12px;
  --pm-radius-lg:  16px;

  /* Sidebar */
  --pm-sidebar-width: 240px;

  /* Typography */
  --pm-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --pm-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Legacy compatibility tokens (mapped to new system) */
  --text:   var(--pm-text);
  --muted:  var(--pm-text-secondary);
  --border: var(--pm-border);
  --bg:     var(--pm-bg);
  --card:   var(--pm-card);
  --card-bg:var(--pm-card);
  --good:   var(--pm-success);
  --warn:   var(--pm-warning);
  --bad:    var(--pm-danger);
  --link:   var(--pm-info);
  --neutral:var(--pm-text-secondary);
  --accent: var(--pm-slate);
  --primary:var(--pm-info);
  --hover-bg:#F8FAFC;
}


/* --------------------------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--pm-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--pm-text);
  background: var(--pm-bg);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--pm-info);
  text-decoration: none;
  font-weight: 600;
}
a:hover { text-decoration: underline; }


/* --------------------------------------------------------------------------
   3. Layout: Sidebar + Main
   -------------------------------------------------------------------------- */

.pm-layout {
  display: flex;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Sidebar */
.pm-sidebar {
  width: var(--pm-sidebar-width);
  background: var(--pm-sidebar);
  color: var(--pm-text-on-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.pm-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 10px 12px;
  margin: 8px 8px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-decoration: none;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
}

.pm-brand-full {
  width: 100%;
  max-width: 220px;
  height: auto;
  display: block;
}

.pm-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: none;
}

.pm-sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pm-sidebar-section {
  padding: 16px 8px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pm-text-on-dark-muted);
}

.pm-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--pm-radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--pm-text-on-dark);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.pm-sidebar-link:hover {
  background: var(--pm-sidebar-hover);
  text-decoration: none;
  color: #fff;
}

.pm-sidebar-link.active {
  background: var(--pm-sidebar-active);
  color: var(--pm-gold);
  font-weight: 600;
}

.pm-sidebar-link svg,
.pm-sidebar-link .pm-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.pm-sidebar-link.active svg,
.pm-sidebar-link.active .pm-nav-icon {
  opacity: 1;
}

/* Collapsible nav groups */
.pm-nav-group {
  border: none;
  padding: 0;
  margin: 0;
}

.pm-nav-group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.pm-nav-group > summary::-webkit-details-marker {
  display: none;
}

.pm-nav-group > summary::after {
  content: '';
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat center;
  flex-shrink: 0;
  transition: transform 0.15s;
  opacity: 0.6;
}

.pm-nav-group[open] > summary::after {
  transform: rotate(0deg);
}

.pm-nav-group:not([open]) > summary::after {
  transform: rotate(-90deg);
}

.pm-nav-group > summary:hover::after {
  opacity: 1;
}

.pm-sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.pm-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--pm-radius);
}

.pm-sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--pm-gold);
  color: var(--pm-slate);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.pm-sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.pm-sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pm-sidebar-user-role {
  font-size: 11px;
  color: var(--pm-text-on-dark-muted);
  text-transform: capitalize;
}

.pm-sidebar-logout {
  display: block;
  padding: 6px 12px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--pm-text-on-dark-muted);
  text-decoration: none;
  border-radius: var(--pm-radius-sm);
  transition: color 0.15s;
}

.pm-sidebar-logout:hover {
  color: #fff;
  text-decoration: none;
}

/* Main area */
.pm-main {
  flex: 1;
  margin-left: var(--pm-sidebar-width);
  min-height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Top bar */
.pm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 56px;
  background: var(--pm-card);
  border-bottom: 1px solid var(--pm-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.pm-topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pm-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--pm-text-muted);
}

.pm-breadcrumb a {
  color: var(--pm-text-secondary);
  font-weight: 500;
}

.pm-breadcrumb-sep {
  color: var(--pm-text-muted);
  font-size: 11px;
}

.pm-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pm-topbar-brand {
  display: none;
  align-items: center;
}

.pm-topbar-brand img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.pm-topbar-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--pm-gold-light);
  color: var(--pm-gold-dark);
}

/* Content */
.pm-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1400px;
  min-width: 0;
  overflow-x: auto;
}


/* --------------------------------------------------------------------------
   4. Component: Cards
   -------------------------------------------------------------------------- */

.pm-card {
  background: var(--pm-card);
  border: 1px solid var(--pm-border);
  border-radius: var(--pm-radius-lg);
  padding: 20px;
  box-shadow: var(--pm-shadow-sm);
  min-width: 0;
  overflow-x: auto;
}

.pm-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.pm-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--pm-text);
}

.pm-card-subtitle {
  font-size: 13px;
  color: var(--pm-text-secondary);
  margin-top: 2px;
}


/* --------------------------------------------------------------------------
   5. Component: Metric / KPI Cards
   -------------------------------------------------------------------------- */

.pm-metrics {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.pm-metric {
  background: var(--pm-card);
  border: 1px solid var(--pm-border);
  border-radius: var(--pm-radius-md);
  padding: 16px 18px;
  box-shadow: var(--pm-shadow-sm);
}

.pm-metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--pm-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pm-metric-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--pm-text);
}

.pm-metric-change {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.pm-metric-change.up   { color: var(--pm-danger); }
.pm-metric-change.down { color: var(--pm-success); }
.pm-metric-change.flat { color: var(--pm-text-muted); }


/* --------------------------------------------------------------------------
   6. Component: Tables
   -------------------------------------------------------------------------- */

.pm-table-wrap {
  overflow-x: auto;
  border-radius: var(--pm-radius-md);
}

.pm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pm-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pm-text-secondary);
  border-bottom: 1px solid var(--pm-border);
  background: var(--pm-bg);
  white-space: nowrap;
}

.pm-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--pm-border-light);
  vertical-align: middle;
}

.pm-table tbody tr:last-child td {
  border-bottom: none;
}

.pm-table tbody tr:hover {
  background: rgba(0,0,0,0.015);
}

.pm-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pm-table .mono {
  font-family: var(--pm-font-mono);
  font-size: 12px;
  color: var(--pm-text-secondary);
}


/* --------------------------------------------------------------------------
   7. Component: Badges / Status
   -------------------------------------------------------------------------- */

.pm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

.pm-badge-success  { background: var(--pm-success-bg); color: var(--pm-success); }
.pm-badge-warning  { background: var(--pm-warning-bg); color: #B45309; }
.pm-badge-danger   { background: var(--pm-danger-bg);  color: var(--pm-danger); }
.pm-badge-info     { background: var(--pm-info-bg);    color: var(--pm-info); }
.pm-badge-neutral  { background: #F1F5F9; color: var(--pm-text-secondary); }

.pm-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pm-dot-success { background: var(--pm-success); }
.pm-dot-warning { background: var(--pm-warning); }
.pm-dot-danger  { background: var(--pm-danger); }
.pm-dot-info    { background: var(--pm-info); }
.pm-dot-muted   { background: var(--pm-text-muted); }


/* --------------------------------------------------------------------------
   8. Component: Buttons
   -------------------------------------------------------------------------- */

.pm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--pm-radius);
  border: 1px solid var(--pm-border);
  background: var(--pm-card);
  color: var(--pm-text);
  font-family: var(--pm-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.pm-btn:hover {
  background: var(--pm-bg);
  text-decoration: none;
}

.pm-btn-primary {
  background: var(--pm-slate);
  border-color: var(--pm-slate);
  color: #fff;
}

.pm-btn-primary:hover {
  background: var(--pm-slate-mid);
}

.pm-btn-gold {
  background: var(--pm-gold);
  border-color: var(--pm-gold);
  color: var(--pm-slate);
}

.pm-btn-gold:hover {
  background: var(--pm-gold-dark);
  border-color: var(--pm-gold-dark);
}

.pm-btn-danger {
  background: var(--pm-danger-bg);
  border-color: var(--pm-danger-border);
  color: var(--pm-danger);
}

.pm-btn-danger:hover {
  background: #FECACA;
}

.pm-btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--pm-radius-sm);
}


/* --------------------------------------------------------------------------
   9. Component: Forms
   -------------------------------------------------------------------------- */

.pm-input,
.pm-select {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--pm-radius);
  border: 1px solid var(--pm-border);
  background: var(--pm-card);
  font-family: var(--pm-font);
  font-size: 13px;
  color: var(--pm-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pm-input:focus,
.pm-select:focus {
  outline: none;
  border-color: var(--pm-info);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.pm-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--pm-text);
  margin-bottom: 4px;
}

.pm-hint {
  font-size: 12px;
  color: var(--pm-text-muted);
  margin-top: 4px;
}


/* --------------------------------------------------------------------------
   10. Component: Empty State
   -------------------------------------------------------------------------- */

.pm-empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--pm-text-secondary);
}

.pm-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.pm-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--pm-text);
  margin-bottom: 4px;
}

.pm-empty-desc {
  font-size: 13px;
  color: var(--pm-text-secondary);
  max-width: 360px;
  margin: 0 auto;
}


/* --------------------------------------------------------------------------
   11. Component: Page Header
   -------------------------------------------------------------------------- */

.pm-page-header {
  margin-bottom: 24px;
}

.pm-page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--pm-text);
}

.pm-page-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--pm-text-secondary);
}

.pm-page-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}


/* --------------------------------------------------------------------------
   12. Flash Messages
   -------------------------------------------------------------------------- */

.pm-flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--pm-radius-md);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}

.pm-flash-success {
  background: var(--pm-success-bg);
  color: var(--pm-success);
  border: 1px solid var(--pm-success-border);
}

.pm-flash-error {
  background: var(--pm-danger-bg);
  color: var(--pm-danger);
  border: 1px solid var(--pm-danger-border);
}

.pm-flash-info {
  background: var(--pm-info-bg);
  color: var(--pm-info);
  border: 1px solid var(--pm-info-border);
}

.pm-flash-warning {
  background: var(--pm-warning-bg);
  color: #B45309;
  border: 1px solid var(--pm-warning-border);
}


/* --------------------------------------------------------------------------
   13. Utility Classes
   -------------------------------------------------------------------------- */

.pm-mono { font-family: var(--pm-font-mono); font-size: 12px; }
.pm-muted { color: var(--pm-text-secondary); }
.pm-text-success { color: var(--pm-success); }
.pm-text-warning { color: var(--pm-warning); }
.pm-text-danger  { color: var(--pm-danger); }
.pm-text-info    { color: var(--pm-info); }

.pm-grid { display: grid; gap: 16px; }
.pm-grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.pm-grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.pm-grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.pm-flex { display: flex; gap: 12px; flex-wrap: wrap; }
.pm-flex-center { align-items: center; }
.pm-flex-between { justify-content: space-between; }

.pm-mb-0  { margin-bottom: 0; }
.pm-mb-sm { margin-bottom: 8px; }
.pm-mb-md { margin-bottom: 16px; }
.pm-mb-lg { margin-bottom: 24px; }


/* --------------------------------------------------------------------------
   14. LIVE Status Rows (preserved for dashboard compatibility)
   -------------------------------------------------------------------------- */

tr.row-pouring {
  background: #e8f7ec;
  border-left: 4px solid #2ea44f;
}
tr.row-online  { background: #f6f9ff; }
tr.row-attention { background: #fff6e5; }
tr.row-offline { background: #fafafa; color: #777; }

@keyframes pourPulse {
  0%   { background-color: #e8f7ec; }
  50%  { background-color: #d9f3e2; }
  100% { background-color: #e8f7ec; }
}
tr.row-pouring { animation: pourPulse 2.5s ease-in-out infinite; }


/* --------------------------------------------------------------------------
   15. Mobile / Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .pm-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
  }

  .pm-sidebar.open {
    transform: translateX(0);
  }

  .pm-main {
    margin-left: 0;
  }

  .pm-content {
    padding: 20px 16px;
  }

  .pm-topbar {
    padding: 0 16px;
  }

  .pm-topbar-brand {
    display: flex;
  }

  .pm-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

}

.pm-hamburger {
  background: #1E2933;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  color: #fff;
  border-radius: 8px;
  display: none;
  align-items: center;
  gap: 6px;
  font-family: var(--pm-font);
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 768px) {
  .pm-hamburger {
    display: flex;
  }
}

.pm-hamburger svg {
  width: 20px;
  height: 20px;
}

/* Mobile overlay */
.pm-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

@media (max-width: 768px) {
  .pm-sidebar.open ~ .pm-sidebar-overlay {
    display: block;
  }
}


/* --------------------------------------------------------------------------
   16. Tablet Breakpoint (769px - 1024px)
   -------------------------------------------------------------------------- */

@media (min-width: 769px) and (max-width: 1024px) {
  .pm-sidebar {
    width: 200px;
  }
  .pm-main {
    margin-left: 200px;
  }
  .pm-content {
    padding: 20px 16px;
  }
  .pm-sidebar-link {
    font-size: 12px;
    padding: 7px 10px;
    gap: 8px;
  }
  .pm-sidebar-link svg {
    width: 16px;
    height: 16px;
  }
  .pm-sidebar-section {
    padding: 12px 8px 4px;
    font-size: 10px;
  }
  .pm-sidebar-brand {
    padding: 10px 8px;
  }
  .pm-brand-full {
    max-width: 170px;
  }
  .pm-topbar {
    padding: 0 16px;
  }

  /* Page header stacks on tablet */
  .pm-page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Metric cards: smaller on tablet */
  .pm-metric-value {
    font-size: 24px;
  }
  .pm-metrics {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
  }

  /* Inline flex card layouts: reduce min-width so cards fit or stack */
  .pos-page [style*="min-width:300px"],
  .pm-card[style*="min-width:300px"],
  div[style*="min-width:300px"],
  div[style*="min-width:280px"] {
    min-width: 220px !important;
  }

  /* Forms: ensure inputs don't overflow */
  .pm-input, .pm-select {
    max-width: 100%;
  }

  /* Cards: slightly tighter */
  .pm-card {
    padding: 16px;
  }
}

/* --------------------------------------------------------------------------
   17. Enhanced Mobile (max-width: 768px)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Sticky topbar with brand */
  .pm-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 52px;
  }

  /* Touch-friendly buttons */
  .pm-btn {
    min-height: 42px;
    padding: 0 16px;
    font-size: 14px;
  }
  .pm-btn-sm {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
  }

  /* Stacked KPI cards */
  .pm-kpi-card,
  .pm-metric {
    min-width: unset !important;
  }

  .pm-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .pm-metric-value {
    font-size: 22px;
  }

  /* Page header: full stack on mobile */
  .pm-page-header {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 16px;
  }
  .pm-page-title {
    font-size: 18px;
  }
  .pm-page-subtitle {
    font-size: 13px;
  }
  .pm-page-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .pm-page-actions .pm-btn {
    text-align: center;
    padding: 6px 4px;
    font-size: 12px;
    justify-content: center;
  }

  /* Card compact */
  .pm-card {
    padding: 14px;
    border-radius: var(--pm-radius-md);
  }
  .pm-card-header {
    margin-bottom: 10px;
  }
  .pm-card-title {
    font-size: 14px;
  }

  /* ── Inline flex layouts: force column stack on mobile ── */
  .pos-page > [style*="display:flex"],
  .pm-card > [style*="display:flex"][style*="gap"],
  div.pos-page > div[style*="display:flex"] {
    flex-direction: column !important;
  }

  /* Override all inline min-widths on flex children */
  .pos-page [style*="min-width"],
  .pm-card[style*="min-width"],
  div[style*="min-width:300px"],
  div[style*="min-width:280px"],
  div[style*="min-width:250px"] {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* Table improvements */
  .pm-table-wrap {
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px;
    padding: 0 14px;
  }
  .pm-table {
    font-size: 12px;
  }
  .pm-table thead th {
    padding: 8px 10px;
    font-size: 10px;
  }
  .pm-table tbody td {
    padding: 8px 10px;
  }

  /* Forms: full-width inputs, stacked layout */
  .pm-input, .pm-select {
    min-height: 42px;
    font-size: 16px; /* Prevent iOS zoom */
    max-width: 100%;
  }
  input[style*="width:"], select[style*="width:"] {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Form rows: stack on mobile */
  form[style*="display:flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  form[style*="display:flex"] > div {
    width: 100%;
  }
  form[style*="display:flex"] > button,
  form[style*="display:flex"] > input[type="submit"] {
    width: 100%;
  }

  /* Badge compact */
  .pm-badge {
    font-size: 11px;
    padding: 2px 8px;
  }

  /* Flash messages */
  .pm-flash {
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--pm-radius);
  }

  /* Sidebar on mobile - full overlay */
  .pm-sidebar {
    width: 280px;
  }

  /* Grid helpers */
  .pm-grid-2, .pm-grid-3, .pm-grid-4 {
    grid-template-columns: 1fr;
  }

  /* Detail layouts: inline key-value pairs stack */
  div[style*="padding:12px"] p {
    word-break: break-word;
  }
}

/* --------------------------------------------------------------------------
   18. Small Mobile (max-width: 480px)
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .pm-content {
    padding: 14px 12px;
  }

  .pm-topbar {
    padding: 0 12px;
    height: 48px;
  }

  .pm-metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .pm-metric {
    padding: 12px;
  }

  .pm-metric-value {
    font-size: 20px;
  }

  .pm-metric-label {
    font-size: 10px;
  }

  .pm-page-title {
    font-size: 16px;
  }

  /* All inline flex layouts: force column */
  [style*="display:flex"][style*="gap"] {
    flex-direction: column !important;
  }

  /* All inline min-widths: collapse */
  [style*="min-width"] {
    min-width: 0 !important;
  }

  /* Page action buttons: 2-col grid on small phones */
  .pm-page-actions {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 4px;
  }
  .pm-page-actions .pm-btn,
  .pm-page-actions .pm-btn-sm {
    font-size: 11px;
    padding: 5px 2px;
  }
}

/* --------------------------------------------------------------------------
   18b. Responsive Layout Utilities (reusable across all pages)
   -------------------------------------------------------------------------- */

/* Two-column detail layout — stacks on mobile */
.pm-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Inline filter/action bar */
.pm-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}

/* Form field row — side by side on desktop, stacked on mobile */
.pm-form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.pm-form-row > * {
  flex: 1;
  min-width: 160px;
}

/* Compact inline group (badges, metadata) */
.pm-inline-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Full-width on mobile helper */
.pm-full-mobile {
  width: auto;
}

@media (max-width: 768px) {
  .pm-detail-grid {
    grid-template-columns: 1fr;
  }

  .pm-filter-row {
    flex-direction: column;
    gap: 8px;
  }
  .pm-filter-row > div {
    width: 100%;
  }
  .pm-filter-row input,
  .pm-filter-row select {
    width: 100% !important;
    min-width: 0 !important;
  }
  .pm-filter-row button,
  .pm-filter-row .pm-btn {
    width: 100%;
  }

  .pm-form-row {
    flex-direction: column;
  }
  .pm-form-row > * {
    min-width: 0;
    width: 100%;
  }

  .pm-full-mobile {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Hero stats 2x2 grid on mobile (for marketing reuse) */
  .pm-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  /* Prevent horizontal overflow on any page */
  .pm-content {
    overflow-x: hidden;
  }

  /* Breadcrumb truncation */
  .pm-breadcrumb {
    max-width: calc(100vw - 120px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .pm-form-row > * {
    min-width: 0;
  }

  /* Even tighter card padding */
  .pm-detail-grid {
    gap: 10px;
  }

  .pm-filter-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Venue row (quote forms) */
.venue-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  align-items: end;
}
.venue-row > :first-child { flex: 2; min-width: 120px; }
.venue-row > :nth-child(2) { flex: 1; min-width: 60px; }

@media (max-width: 480px) {
  .venue-row {
    flex-wrap: wrap;
  }
  .venue-row > :first-child,
  .venue-row > :nth-child(2) {
    min-width: 0;
    flex-basis: calc(50% - 4px);
  }
}

/* Print styles */
@media print {
  .pm-sidebar, .pm-topbar, .pm-hamburger, .pm-sidebar-overlay { display: none !important; }
  .pm-main { margin-left: 0 !important; }
  .pm-content { padding: 0 !important; }
  .pm-card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  .pm-btn, .pm-actions-row { display: none !important; }
  .pm-table { font-size: 11px; }
}

/* --------------------------------------------------------------------------
   19. Responsive Utility Helpers
   -------------------------------------------------------------------------- */

/* Hide on mobile */
@media (max-width: 768px) {
  .pm-hide-mobile { display: none !important; }
}

/* Hide on desktop */
@media (min-width: 769px) {
  .pm-hide-desktop { display: none !important; }
}

/* Hide on tablet and below */
@media (max-width: 1024px) {
  .pm-hide-tablet { display: none !important; }
}

/* Responsive table: stacked on mobile */
.pm-table-responsive thead {
  display: none;
}

@media (max-width: 768px) {
  .pm-table-responsive tbody tr {
    display: block;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--pm-border);
    border-radius: var(--pm-radius);
    background: var(--pm-card);
  }
  .pm-table-responsive tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: none;
    font-size: 13px;
  }
  .pm-table-responsive tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--pm-text-secondary);
    flex-shrink: 0;
    margin-right: 8px;
  }
}

/* Touch-friendly action rows */
@media (max-width: 768px) {
  .pm-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .pm-actions-row .pm-btn,
  .pm-actions-row .pm-btn-sm {
    flex: 1;
    min-width: 80px;
    justify-content: center;
  }
}

/* KPI strip responsive */
.pm-kpi-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pm-kpi-card {
  background: var(--pm-card);
  border: 1px solid var(--pm-border);
  border-radius: var(--pm-radius-md);
  padding: 14px 18px;
  min-width: 120px;
  box-shadow: var(--pm-shadow-sm);
}

.pm-kpi-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--pm-text);
}

.pm-kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--pm-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

@media (max-width: 768px) {
  .pm-kpi-strip {
    gap: 8px;
  }
  .pm-kpi-card {
    flex: 1;
    min-width: 80px;
    padding: 10px 12px;
  }
  .pm-kpi-value {
    font-size: 20px;
  }
  .pm-kpi-label {
    font-size: 10px;
  }
}

/* Progress bar component */
.pm-progress {
  height: 8px;
  background: var(--pm-border);
  border-radius: 4px;
  overflow: hidden;
}

.pm-progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.pm-progress-success { background: var(--pm-success); }
.pm-progress-warning { background: var(--pm-warning); }
.pm-progress-danger  { background: var(--pm-danger); }
.pm-progress-info    { background: var(--pm-info); }


/* ── M23: Command Centre Polish ──────────────────────────────── */

/* Improved page header with action bar */
.pm-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

/* Better empty states */
.pm-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #94a3b8;
}
.pm-empty-state-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.pm-empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
}
.pm-empty-state-text {
  font-size: 13px;
  color: #94a3b8;
}

/* Consistent card hover */
.pm-card-interactive {
  transition: box-shadow 0.15s, border-color 0.15s;
  cursor: pointer;
}
.pm-card-interactive:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #cbd5e1;
}

/* Score/metric display */
.pm-score {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}
.pm-score-sm {
  font-size: 24px;
  font-weight: 700;
}
.pm-score-label {
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Status dot improvements */
.pm-status-online { color: #22c55e; }
.pm-status-warning { color: #f59e0b; }
.pm-status-offline { color: #ef4444; }
.pm-status-neutral { color: #94a3b8; }

/* Improved sticky topbar shadow */
.pm-topbar {
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Notification bell */
.pm-topbar-bell {
  position: relative;
  display: flex;
  align-items: center;
  color: var(--pm-text-secondary);
  text-decoration: none;
  padding: 6px;
  border-radius: var(--pm-radius-sm);
  transition: background 0.15s, color 0.15s;
}
.pm-topbar-bell:hover {
  background: var(--pm-bg);
  color: var(--pm-text);
  text-decoration: none;
}
.pm-topbar-bell-count {
  position: absolute;
  top: -2px;
  right: -4px;
  background: var(--pm-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Subtle divider utility */
.pm-divider {
  border: none;
  border-top: 1px solid #f1f5f9;
  margin: 16px 0;
}

/* Better filter/action bars */
.pm-filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
  padding: 12px;
}

/* Improved table row hover */
.pm-table tbody tr {
  transition: background 0.1s;
}
.pm-table tbody tr:hover {
  background: #f8fafc;
}

/* --------------------------------------------------------------------------
   Page Guide — collapsible contextual help
   -------------------------------------------------------------------------- */
.pm-guide {
  background: var(--pm-info-bg);
  border: 1px solid var(--pm-info-border);
  border-radius: var(--pm-radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.pm-guide-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--pm-info);
  text-align: left;
}
.pm-guide-toggle:hover {
  background: rgba(37, 99, 235, 0.06);
}
.pm-guide-toggle svg {
  flex-shrink: 0;
  transition: transform 0.2s;
}
.pm-guide.open .pm-guide-toggle svg {
  transform: rotate(90deg);
}
.pm-guide-body {
  display: none;
  padding: 0 14px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--pm-text-secondary);
}
.pm-guide.open .pm-guide-body {
  display: block;
}
.pm-guide-body p {
  margin: 0 0 8px;
}
.pm-guide-body ul {
  margin: 0;
  padding-left: 18px;
}
.pm-guide-body li {
  margin-bottom: 4px;
}
.pm-guide-body strong {
  color: var(--pm-text);
}

/* Empty state with guidance */
.pm-empty-guided {
  text-align: center;
  padding: 32px 20px;
  color: var(--pm-text-muted);
}
.pm-empty-guided-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.5;
}
.pm-empty-guided-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--pm-text-secondary);
  margin-bottom: 4px;
}
.pm-empty-guided-text {
  font-size: 13px;
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.5;
}
.pm-empty-guided-action {
  margin-top: 12px;
}
