/* ── Global layout fixes ─────────────────────────────────────────── */
.main-content,
.main {
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  position: relative;
  z-index: 1;
}

.content-area,
.content {
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* POS fills viewport without double scroll */
.content-area.content-pos {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Mobile tap highlights */
a, button, .nav-item, .cat-btn, .prod-card {
  -webkit-tap-highlight-color: transparent;
}

/* Trial / notice banners */
.trial-banner {
  flex-shrink: 0;
  margin: 0 24px 12px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 12px;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.trial-banner-info {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text2);
}

.trial-banner-warn {
  background: var(--amber-dim);
  border: 1px solid rgba(255, 170, 0, 0.22);
  color: var(--text);
}

.trial-banner strong { color: var(--amber); font-weight: 700; }
.trial-banner-info strong { color: var(--green); }

/* Topbar polish */
.topbar {
  flex-shrink: 0;
  gap: 10px;
}

.topbar-left {
  min-width: 0;
  flex: 1;
}

.topbar-title,
.page-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.live-clock {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
  padding: 4px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 99px;
  white-space: nowrap;
}

.active-indicator {
  padding: 4px 10px;
  background: var(--green-dim);
  border: 1px solid rgba(0, 208, 132, 0.18);
  border-radius: 99px;
}

/* Nav active state — consistent filled style */
.nav-item.active {
  background: var(--green-dim);
  border-color: rgba(0, 208, 132, 0.25);
  box-shadow: inset 3px 0 0 var(--green);
}

/* Forms & cards — touch-friendly on mobile */
.form-input,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
select,
textarea {
  min-height: 40px;
  font-size: 16px; /* prevents iOS zoom on focus */
}

@media (min-width: 961px) {
  .form-input,
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: inherit;
  }
}

.btn {
  min-height: 40px;
  touch-action: manipulation;
}

/* Tables scroll on small screens */
.table-wrap,
.tbl-wrap {
  -webkit-overflow-scrolling: touch;
}

/* Flash messages */
.flash-container {
  flex-shrink: 0;
  padding: 8px 24px 0;
}

/* ── Notification panel (stock alerts) ───────────────────────────── */
.notif-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 480px);
  background: var(--bg1);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  z-index: 500;
  overflow: hidden;
  flex-direction: column;
}

.notif-panel.open { display: flex; }

.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.notif-panel-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.notif-panel-close {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.notif-panel-close:hover { background: var(--bg3); color: var(--text); }

.notif-panel-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
  min-height: 80px;
}

.notif-panel-foot {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.notif-loading,
.notif-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text3);
  line-height: 1.5;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg2);
  margin-bottom: 6px;
}

.notif-item:last-child { margin-bottom: 0; }

.notif-item.notif-critical {
  border-color: rgba(255, 77, 106, 0.35);
  background: var(--red-dim);
}

.notif-item.notif-low {
  border-color: rgba(255, 170, 0, 0.3);
  background: var(--amber-dim);
}

.notif-item-emoji {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border-radius: 10px;
  font-size: 18px;
  flex-shrink: 0;
}

.notif-item-info { flex: 1; min-width: 0; }

.notif-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 2px;
}

.notif-item-meta,
.notif-item-hint {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
}

.notif-item-tag {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 7px;
  border-radius: 99px;
  flex-shrink: 0;
  align-self: flex-start;
}

.notif-critical .notif-item-tag {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 77, 106, 0.3);
}

.notif-low .notif-item-tag {
  background: rgba(255, 170, 0, 0.15);
  color: var(--amber);
  border: 1px solid rgba(255, 170, 0, 0.25);
}

/* ── Tablet (768px – 1024px) ─────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  .content-area,
  .content {
    padding: 18px;
  }

  .stats-grid,
  .stats-row,
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid.cols-2,
  .form-grid.cols-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .form-grid .span-2 {
    grid-column: span 2;
  }

  .form-grid .span-3 {
    grid-column: span 2;
  }

  .admin-form-shell {
    max-width: 100%;
  }

  .table-wrap,
  .tbl-wrap {
    margin: 0 -4px;
  }
}

/* ── Tablet & mobile ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .topbar-actions .btn:not(.icon-btn) {
    font-size: 11px;
    padding: 5px 10px;
  }
}

@media (max-width: 960px) {
  .trial-banner {
    margin: 0 16px 10px;
  }

  .flash-container {
    padding: 8px 16px 0;
  }

  .active-indicator,
  .live-clock {
    display: none;
  }

  .notif-panel {
    position: fixed;
    top: 56px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100dvh - 72px);
  }

  .card,
  .card-v2,
  .admin-form-card {
    padding: 16px;
  }

  .stat-card,
  .stat-card-v2 {
    padding: 14px 16px;
  }
}

@media (max-width: 600px) {
  .topbar-title,
  .page-title {
    font-size: 15px;
  }

  .topbar-sub {
    display: none;
  }

  .trial-banner {
    font-size: 11px;
    padding: 7px 12px;
    margin: 0 12px 8px;
  }

  .flash-container {
    padding: 6px 12px 0;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }

  .content-area:not(.content-pos),
  .content:not(.content-pos) {
    padding: 12px;
  }
}
