/* =========================================================
   Smart MOQ & Production Planner — Main Stylesheet
   Modern SaaS Dashboard UI
   ========================================================= */

/* ── CSS Variables ── */
:root {
  --bg-main: #f0f4f8;
  --bg-panel: #ffffff;
  --bg-panel-alt: #f8fafc;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --blue: #3b82f6;
  --blue-light: #eff6ff;
  --blue-dark: #1d4ed8;
  --green: #22c55e;
  --green-light: #f0fdf4;
  --green-dark: #15803d;
  --orange: #f97316;
  --orange-light: #fff7ed;
  --red: #ef4444;
  --red-light: #fef2f2;
  --purple: #8b5cf6;
  --purple-light: #f5f3ff;
  --teal: #14b8a6;
  --teal-light: #f0fdfa;
  --indigo: #6366f1;
  --indigo-light: #eef2ff;
  --yellow: #eab308;
  --yellow-light: #fefce8;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 32px rgba(0,0,0,.10);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --transition: all .22s ease;
  --header-h: 76px;
  --font: 'Inter', system-ui, sans-serif;
}

/* Dark Mode Variables */
.dark-mode {
  --bg-main: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-alt: #162032;
  --border: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --blue-light: #1e3a5f;
  --green-light: #14291e;
  --orange-light: #2d1f0e;
  --red-light: #2d1515;
  --purple-light: #1e1535;
  --teal-light: #0d2520;
  --indigo-light: #1a1d40;
  --yellow-light: #2a2208;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 32px rgba(0,0,0,.5);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background .3s, color .3s;
  line-height: 1.6;
}

/* ── Header ── */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  height: var(--header-h);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.logo-placeholder {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--indigo) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59,130,246,.35);
}
.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
}
.brand-text h1 .accent { color: var(--blue); }
.brand-text .subtitle {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 400;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.live-clock {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  color: var(--text-secondary);
  background: var(--bg-panel-alt);
  padding: .45rem .85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.live-clock i { color: var(--blue); }
#clock-display { font-weight: 600; font-variant-numeric: tabular-nums; }
#date-display { color: var(--text-muted); font-size: .7rem; }
.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-panel-alt);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--blue-light); color: var(--blue); border-color: var(--blue); }
.btn-icon.btn-reset:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }

/* ── Main Layout ── */
#app-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* ── Panels ── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: fadeSlideIn .4s ease both;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.panel-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-alt);
}
.panel-header i { color: var(--blue); font-size: 1.1rem; }
.panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.panel-badge {
  font-size: .7rem;
  font-weight: 600;
  padding: .25rem .65rem;
  border-radius: 20px;
  background: var(--blue-light);
  color: var(--blue);
  letter-spacing: .03em;
}
.panel-badge.green { background: var(--green-light); color: var(--green-dark); }
.panel-badge.blue  { background: var(--blue-light);  color: var(--blue-dark); }
.panel-badge.red   { background: var(--red-light);   color: var(--red); }
.panel-badge.yellow{ background: var(--yellow-light); color: #854d0e; }

/* ── Panel Header Amp ── */
.panel-header h2 .header-amp { color: var(--blue); }

/* =========================================================
   PRODUCT MANAGER STYLES
   ========================================================= */

/* Count badge next to label */
.product-count-badge {
  margin-left: .5rem;
  font-size: .68rem;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: 10px;
  background: var(--blue-light);
  color: var(--blue);
  vertical-align: middle;
  letter-spacing: .02em;
}

/* Select row: dropdown + manage button side by side */
.product-select-row {
  display: flex;
  gap: .6rem;
  align-items: stretch;
}
.product-select-row select {
  flex: 1;
  min-width: 0;
}

/* Manage toggle button */
.btn-manage-products {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 0 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-panel-alt);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-manage-products:hover,
.btn-manage-products.active {
  background: var(--blue-light);
  color: var(--blue);
  border-color: var(--blue);
}
.btn-manage-products i { font-size: .8rem; }

/* ── Product Manager Panel ── */
.product-manager {
  margin-top: .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-panel);
  animation: fadeSlideIn .25s ease;
  box-shadow: var(--shadow-md);
}

/* PM Header */
.pm-header {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .7rem 1rem;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.pm-header i { color: var(--blue); }
.pm-hint {
  margin-left: auto;
  font-size: .7rem;
  font-weight: 400;
  color: var(--text-muted);
  font-style: italic;
}

/* PM List */
.pm-list {
  list-style: none;
  padding: .4rem .6rem;
  margin: 0;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.pm-list::-webkit-scrollbar { width: 5px; }
.pm-list::-webkit-scrollbar-track { background: transparent; }
.pm-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* PM List Item */
.pm-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .65rem;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: var(--transition);
  background: transparent;
}
.pm-item:hover {
  background: var(--bg-panel-alt);
  border-color: var(--border);
}
.pm-item-drag {
  color: var(--text-muted);
  cursor: grab;
  font-size: .78rem;
  flex-shrink: 0;
  padding: .1rem .2rem;
}
.pm-item-drag:active { cursor: grabbing; }

/* Inline editable name */
.pm-item-name {
  flex: 1;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-primary);
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 6px;
  padding: .3rem .5rem;
  font-family: var(--font);
  outline: none;
  cursor: text;
  transition: var(--transition);
  min-width: 0;
}
.pm-item-name:hover {
  border-color: var(--border);
  background: var(--bg-main);
}
.pm-item-name:focus {
  border-color: var(--border-focus);
  background: var(--bg-panel);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
  cursor: text;
}
.pm-item-name.unsaved {
  border-color: var(--orange);
  background: var(--orange-light);
}

/* Save inline button (shows when editing) */
.pm-item-save {
  display: none;
  align-items: center;
  gap: .3rem;
  padding: .28rem .65rem;
  border-radius: 6px;
  border: 1.5px solid var(--green);
  background: var(--green-light);
  color: var(--green-dark);
  font-family: var(--font);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.pm-item-save:hover { background: var(--green); color: #fff; }
.pm-item-save.visible { display: inline-flex; }

/* Delete button */
.pm-item-delete {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.pm-item-delete:hover {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red);
}

/* PM Add Row */
.pm-add-row {
  display: flex;
  gap: .6rem;
  align-items: center;
  padding: .6rem .65rem;
  border-top: 1px solid var(--border);
  background: var(--bg-panel-alt);
}
.pm-add-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg-panel);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0 .75rem;
  transition: var(--transition);
}
.pm-add-input-wrap:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.pm-add-input-wrap i {
  color: var(--text-muted);
  font-size: .78rem;
  flex-shrink: 0;
}
#pm-new-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: .84rem;
  color: var(--text-primary);
  padding: .55rem 0;
  outline: none;
}
#pm-new-input::placeholder { color: var(--text-muted); }

.btn-pm-add {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .55rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--blue);
  color: #fff;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59,130,246,.3);
}
.btn-pm-add:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,.4);
}

/* PM Footer */
.pm-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem .9rem;
  background: var(--bg-panel-alt);
  border-top: 1px solid var(--border);
  gap: .75rem;
  flex-wrap: wrap;
}
.pm-save-note {
  font-size: .7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .35rem;
}
.pm-save-note i { color: var(--green-dark); }
.btn-pm-reset {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .75rem;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-pm-reset:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--orange-light);
}

/* Empty list message */
.pm-empty {
  text-align: center;
  padding: 1.25rem;
  color: var(--text-muted);
  font-size: .82rem;
  font-style: italic;
}

/* ── Form Grid ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  padding: 1.75rem;
}
.form-group { display: flex; flex-direction: column; gap: .5rem; }
.form-group.span-2 { grid-column: 1 / -1; }
.form-group label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.form-group label i { color: var(--blue); font-size: .78rem; }
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrapper .input-unit {
  position: absolute;
  right: .85rem;
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
}
input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .875rem;
  color: var(--text-primary);
  background: var(--bg-main);
  transition: var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
input[type="number"]:focus,
select:focus {
  border-color: var(--border-focus);
  background: var(--bg-panel);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.input-wrapper input[type="number"] { padding-right: 3.5rem; }

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* Priority Selector */
.priority-selector {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}
.priority-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--bg-main);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: .83rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.priority-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.priority-btn.active { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.priority-btn.urgent.active { border-color: var(--red); color: var(--red); background: var(--red-light); }
.priority-btn[data-priority="High"].active { border-color: var(--orange); color: var(--orange); background: var(--orange-light); }

/* Form Actions */
.form-actions {
  padding: 0 1.75rem 1.75rem;
  display: flex;
  justify-content: flex-end;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-export {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .72rem 1.5rem;
  border-radius: 10px;
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59,130,246,.4);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59,130,246,.5);
}
.btn-secondary {
  background: var(--bg-panel-alt);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--blue-light); color: var(--blue); border-color: var(--blue); }
.btn-export {
  background: var(--bg-panel-alt);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  font-size: .85rem;
}
.btn-export:hover { transform: translateY(-1px); border-color: var(--blue); color: var(--blue); }
.btn-export.green:hover { border-color: var(--green); color: var(--green-dark); }

/* ── Risk Banner ── */
.risk-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 1.75rem .25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem;
  background: var(--green-light);
  border: 1.5px solid rgba(34,197,94,.25);
  color: var(--green-dark);
  transition: var(--transition);
}
.risk-banner.yellow { background: var(--yellow-light); border-color: rgba(234,179,8,.3); color: #854d0e; }
.risk-banner.red    { background: var(--red-light);    border-color: rgba(239,68,68,.3);  color: #991b1b; }
.risk-banner i { font-size: 1.5rem; flex-shrink: 0; }
.risk-banner strong { display: block; font-size: .95rem; font-weight: 700; margin-bottom: .15rem; }

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 1.25rem 1.75rem;
}
.kpi-card {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
  opacity: 0;
  transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-card:hover::before { opacity: 1; }
.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  flex-shrink: 0;
}
.kpi-icon.blue   { background: var(--blue-light);   color: var(--blue); }
.kpi-icon.green  { background: var(--green-light);  color: var(--green-dark); }
.kpi-icon.orange { background: var(--orange-light); color: var(--orange); }
.kpi-icon.purple { background: var(--purple-light); color: var(--purple); }
.kpi-icon.teal   { background: var(--teal-light);   color: var(--teal); }
.kpi-icon.indigo { background: var(--indigo-light); color: var(--indigo); }
.kpi-body { flex: 1; min-width: 0; }
.kpi-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  display: block;
}
.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  display: block;
  line-height: 1.2;
  margin: .15rem 0 .1rem;
  transition: var(--transition);
}
.kpi-value.sm { font-size: 1.1rem; font-weight: 700; }
.kpi-sub { font-size: .7rem; color: var(--text-muted); }
.kpi-progress-wrap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}
.kpi-progress-bar {
  height: 100%;
  border-radius: 0 0 var(--radius) var(--radius);
  background: linear-gradient(90deg, var(--blue), var(--indigo));
  transition: width 1s ease;
  width: 0%;
}

/* ── Chart Section ── */
.chart-section {
  margin: .5rem 1.75rem 1.25rem;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.chart-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.chart-header i { color: var(--blue); }
.chart-header h3 { font-size: .9rem; font-weight: 700; flex: 1; }
.chart-legend {
  display: flex;
  align-items: center;
  gap: .85rem;
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: 500;
}
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: .2rem;
}
.legend-dot.blue  { background: var(--blue); }
.legend-dot.green { background: var(--green); }
.legend-dot.red   { background: var(--red); }
.chart-container { position: relative; }

/* ── Recommended Actions ── */
.actions-section {
  padding: 0 1.75rem 1.75rem;
}
.actions-section h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}
.actions-section h3 i { color: var(--blue); }
.actions-list {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.action-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  border-radius: 10px;
  font-size: .83rem;
  border: 1px solid transparent;
  animation: fadeSlideIn .35s ease both;
}
.action-item.info    { background: var(--blue-light);   border-color: rgba(59,130,246,.2);  color: var(--blue-dark); }
.action-item.success { background: var(--green-light);  border-color: rgba(34,197,94,.2);   color: var(--green-dark); }
.action-item.warning { background: var(--yellow-light); border-color: rgba(234,179,8,.25);  color: #854d0e; }
.action-item.danger  { background: var(--red-light);    border-color: rgba(239,68,68,.25);  color: #991b1b; }
.action-item i { margin-top: .1rem; flex-shrink: 0; font-size: .95rem; }

/* ── Email Panel ── */
.email-wrapper {
  margin: 1.5rem 1.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.email-subject-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.1rem;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
  font-size: .83rem;
}
.email-label { font-weight: 700; color: var(--text-muted); }
.email-subject-text { font-weight: 600; color: var(--text-primary); }
.email-body {
  padding: 1.25rem;
  min-height: 220px;
  font-size: .87rem;
  line-height: 1.8;
  color: var(--text-primary);
  background: var(--bg-panel);
  white-space: pre-wrap;
  outline: none;
  font-family: var(--font);
}
.email-body:focus { background: var(--bg-panel-alt); }
.email-actions {
  padding: 0 1.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.copy-confirm {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: var(--green-dark);
  font-weight: 600;
  background: var(--green-light);
  padding: .4rem .8rem;
  border-radius: 8px;
  animation: fadeSlideIn .3s ease;
}

/* ── Export Panel ── */
.export-note {
  padding: 1rem 1.75rem .5rem;
  font-size: .85rem;
  color: var(--text-secondary);
}
.export-actions {
  display: flex;
  gap: .75rem;
  padding: .75rem 1.75rem 1.75rem;
  flex-wrap: wrap;
}

/* ── Footer ── */
#app-footer {
  text-align: center;
  padding: 1.5rem 2rem;
  font-size: .75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

/* =========================================================
   INTERNAL SUMMARY REPORT STYLES
   ========================================================= */

/* ── Report Panel Header ── */
.panel-header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: auto;
}
.report-generated-at {
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Meta Bar ── */
.report-meta-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .85rem 1.75rem;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-secondary);
}
.report-meta-item {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.report-meta-item i { color: var(--blue); font-size: .78rem; }
.report-meta-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 .25rem;
}
.report-meta-right {
  margin-left: auto;
}
.rpt-status-badge {
  display: inline-block;
  padding: .3rem .85rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.rpt-status-badge.rpt-safe    { background: var(--green-light); color: var(--green-dark); border: 1px solid rgba(34,197,94,.25); }
.rpt-status-badge.rpt-monitor { background: var(--yellow-light); color: #854d0e; border: 1px solid rgba(234,179,8,.3); }
.rpt-status-badge.rpt-urgent  { background: var(--red-light); color: #991b1b; border: 1px solid rgba(239,68,68,.3); animation: pulseRing 1.8s infinite; }

/* ── Report Body ── */
.report-body {
  padding: .5rem 1.75rem 0;
}

/* ── Report Sections ── */
.report-section {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px dashed var(--border);
}
.report-section:last-child { border-bottom: none; }
.report-section-title {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: 1rem;
}
.report-section-num {
  font-size: .65rem;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: .1em;
  background: var(--blue-light);
  padding: .2rem .5rem;
  border-radius: 5px;
  flex-shrink: 0;
}
.report-section-title h3 {
  font-size: .92rem;
  font-weight: 700;
  color: var(--text-primary);
  border-left: 3px solid var(--blue);
  padding-left: .65rem;
}

/* ── Executive Summary ── */
.report-summary-text {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  line-height: 1.85;
  font-size: .875rem;
  color: var(--text-primary);
}
.report-summary-text p { margin-bottom: .65rem; }
.report-summary-text p:last-child { margin-bottom: 0; }
.rpt-highlight {
  display: inline;
  font-weight: 700;
  padding: .05rem .35rem;
  border-radius: 4px;
}
.rpt-highlight.green { background: var(--green-light); color: var(--green-dark); }
.rpt-highlight.yellow{ background: var(--yellow-light); color: #854d0e; }
.rpt-highlight.red   { background: var(--red-light); color: #991b1b; }

/* ── Inventory Table ── */
.report-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
.report-table thead tr {
  background: var(--bg-panel-alt);
}
.report-table th {
  padding: .65rem 1rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.report-table td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.report-table .row-even td { background: var(--bg-panel-alt); }
.report-table tbody tr:last-child td { border-bottom: none; }
.report-table tbody tr:hover td { background: var(--blue-light); transition: var(--transition); }
.rpt-tag {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 12px;
  font-size: .7rem;
  font-weight: 700;
}
.rpt-tag.green  { background: var(--green-light); color: var(--green-dark); }
.rpt-tag.yellow { background: var(--yellow-light); color: #854d0e; }
.rpt-tag.red    { background: var(--red-light); color: #991b1b; }

/* ── Recommendation Cards ── */
.report-rec-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.rpt-rec-card {
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  border: 1px solid var(--border);
  text-align: center;
  transition: var(--transition);
}
.rpt-rec-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.rpt-rec-icon { font-size: 1.3rem; margin-bottom: .5rem; }
.rpt-rec-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .35rem;
}
.rpt-rec-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: .3rem;
}
.rpt-rec-value span { font-size: .8rem; font-weight: 500; color: var(--text-secondary); }
.rpt-rec-note { font-size: .7rem; color: var(--text-muted); line-height: 1.4; }

.rpt-rec-card.highlight-blue   { background: var(--blue-light);   border-color: rgba(59,130,246,.2); }
.rpt-rec-card.highlight-purple { background: var(--purple-light); border-color: rgba(139,92,246,.2); }
.rpt-rec-card.highlight-green  { background: var(--green-light);  border-color: rgba(34,197,94,.2); }
.rpt-rec-card.highlight-teal   { background: var(--teal-light);   border-color: rgba(20,184,166,.2); }
.rpt-rec-card.highlight-red    { background: var(--red-light);    border-color: rgba(239,68,68,.2); }

.rpt-rec-card.highlight-blue   .rpt-rec-icon { color: var(--blue); }
.rpt-rec-card.highlight-purple .rpt-rec-icon { color: var(--purple); }
.rpt-rec-card.highlight-green  .rpt-rec-icon { color: var(--green-dark); }
.rpt-rec-card.highlight-teal   .rpt-rec-icon { color: var(--teal); }
.rpt-rec-card.highlight-red    .rpt-rec-icon { color: var(--red); }

/* ── Risk Block ── */
.report-risk-block {
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
.rpt-risk-item {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  padding: .9rem 1.1rem;
  border-radius: 10px;
  font-size: .84rem;
  border: 1px solid transparent;
}
.rpt-risk-item i { font-size: 1.05rem; flex-shrink: 0; margin-top: .1rem; }
.rpt-risk-item strong { display: block; font-weight: 700; margin-bottom: .2rem; }
.rpt-risk-item p { margin: 0; color: inherit; line-height: 1.55; }
.rpt-risk-ok   { background: var(--green-light);  border-color: rgba(34,197,94,.2);  color: var(--green-dark); }
.rpt-risk-warn { background: var(--yellow-light); border-color: rgba(234,179,8,.25); color: #854d0e; }
.rpt-risk-crit { background: var(--red-light);    border-color: rgba(239,68,68,.25); color: #991b1b; }

/* ── Next Steps ── */
.report-steps-list {
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.report-steps-list li {
  font-size: .875rem;
  color: var(--text-primary);
  line-height: 1.6;
  padding-left: .25rem;
}
.report-steps-list li::marker { color: var(--blue); font-weight: 700; }

/* ── Report Footer Section ── */
.report-section-footer { border-bottom: none; }
.report-notes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.report-notes-col { display: flex; flex-direction: column; gap: .5rem; }
.report-notes-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.report-notes-label i { color: var(--blue); }
.report-notes-input {
  min-height: 90px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-family: var(--font);
  font-size: .84rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-main);
  outline: none;
  resize: vertical;
  transition: var(--transition);
}
.report-notes-input:empty::before {
  content: attr(placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.report-notes-input:focus { border-color: var(--border-focus); background: var(--bg-panel); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.report-preparedby-grid {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.report-field-input {
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .84rem;
  color: var(--text-primary);
  background: var(--bg-main);
  outline: none;
  transition: var(--transition);
}
.report-field-input:focus { border-color: var(--border-focus); background: var(--bg-panel); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }

/* ── Report Actions ── */
.report-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.75rem 1.75rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}

/* ── Responsive: Report ── */
@media (max-width: 900px) {
  .report-rec-grid { grid-template-columns: repeat(2, 1fr); }
  .report-notes-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .report-rec-grid { grid-template-columns: 1fr 1fr; }
  .report-meta-bar { gap: .35rem; font-size: .73rem; }
}

/* ── Packaging Warning ── */
.packaging-warning {
  background: var(--red-light) !important;
  color: #991b1b !important;
  border-color: rgba(239,68,68,.35) !important;
}
.packaging-ok {
  background: var(--green-light) !important;
  color: var(--green-dark) !important;
  border-color: rgba(34,197,94,.35) !important;
}

/* ── Print Styles ── */
@media print {
  #app-header, #export-panel, .form-actions, .email-actions, .export-actions,
  .btn-primary, .btn-secondary, .btn-export, .btn-icon, #dark-mode-toggle, #reset-all-btn,
  #app-footer { display: none !important; }
  body { background: #fff !important; }
  .panel { box-shadow: none !important; border: 1px solid #ddd !important; page-break-inside: avoid; }
  #app-main { padding: 1rem !important; }
  .kpi-grid { grid-template-columns: repeat(3,1fr) !important; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .brand-text .subtitle { display: none; }
}
@media (max-width: 640px) {
  #app-main { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.span-2 { grid-column: 1; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .header-inner { padding: 0 1rem; }
  .live-clock #date-display { display: none; }
  .brand-text h1 { font-size: .95rem; }
  .logo-placeholder { width: 36px; height: 36px; font-size: 1rem; }
}
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Number counter animation ── */
.counting { animation: countPulse .5s ease; }
@keyframes countPulse {
  0%   { transform: scale(.85); opacity: .5; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1);   opacity: 1; }
}

/* ── Tooltip ── */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: .7rem;
  padding: .3rem .6rem;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 999;
  pointer-events: none;
}

/* ── Shimmer loading placeholder ── */
.shimmer {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-panel-alt) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Pulse for urgent items ── */
.pulse {
  animation: pulseRing 1.8s infinite;
}
@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,.35); }
  70%  { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
