/* ULTIMO — Professional Business Dashboard CSS */

:root {
  --sidebar-width: 228px;
  --topbar-height: 56px;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-bg: #f1f5f9;
  --color-bg-card: #ffffff;
  --color-text: #111827;
  --color-sidebar-bg: #0f172a;
  --color-sidebar-hover: #1e293b;
  --color-sidebar-active: #2563eb;
  --color-sidebar-text: #94a3b8;
  --color-sidebar-text-active: #f1f5f9;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

/* ═══════════════════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════════════════ */
.app-layout {
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
  z-index: 50;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.sidebar-brand {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.brand-link {
  display: block;
  text-decoration: none;
  width: 100%;
  background: #ffffff;
  border-radius: 10px;
  padding: 7px 10px;
  box-sizing: border-box;
}
.brand-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 44px;
  object-fit: contain;
}

/* NAV */
.sidebar-nav {
  flex: 1;
  padding: 16px 0 8px;
  overflow-y: auto;
}
.nav-group {
  margin-bottom: 4px;
}
.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #475569;
  padding: 12px 18px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 450;
  border-radius: 0;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.nav-item:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-sidebar-text-active);
}
.nav-item.active {
  background: rgba(37,99,235,0.18);
  color: #93c5fd;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.75;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

/* SIDEBAR FOOTER */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #334155;
  color: #e2e8f0;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 10.5px;
  color: #64748b;
  text-transform: capitalize;
}
.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: #64748b;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.sidebar-logout:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }

/* ═══════════════════════════════════════════════════
   APP MAIN
═══════════════════════════════════════════════════ */
.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-height);
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
  gap: 16px;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
}
.topbar-workspace {
  font-size: 12.5px;
  color: var(--color-muted);
  font-weight: 400;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* MAIN CONTENT */
.main-content {
  flex: 1;
  padding: 28px;
  max-width: 1440px;
  width: 100%;
}

/* ═══════════════════════════════════════════════════
   AUTH PAGE
═══════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 20px;
}
.auth-container { width: 100%; display: flex; justify-content: center; align-items: center; }
.auth-card {
  background: var(--color-bg-card);
  border-radius: 14px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.auth-logo { text-align: center; margin-bottom: 28px; padding: 16px 24px 0; }
.auth-brand-img { max-width: 100%; width: 240px; height: auto; margin: 0 auto; display: block; }
.auth-logo p { color: var(--color-muted); font-size: 13px; margin-top: 4px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 13px; color: var(--color-muted); }
.auth-footer a { color: var(--color-primary); }
.auth-hint { text-align: center; margin-top: 12px; color: var(--color-muted); font-size: 12px; }

/* ═══════════════════════════════════════════════════
   DASHBOARD COMPONENTS
═══════════════════════════════════════════════════ */
.welcome-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}
.welcome-text {
  font-size: 15px;
  color: #374151;
}
.welcome-text strong { color: var(--color-text); }
.pending-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
}

/* KPI STRIP */
.kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}
.kpi-tile {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  flex: 1;
  min-width: 100px;
}
.kpi-tile--warn { border-color: #fbbf24; background: #fffbeb; }
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.1;
}
.kpi-tile--warn .kpi-value { color: var(--color-warning); }
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* SECTION LABELS */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--color-muted);
  margin-bottom: 12px;
}
.section-sublabel {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-muted);
  margin-bottom: 8px;
}

/* MODULE TILES */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.module-tile {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 16px 14px;
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
  position: relative;
}
.module-tile:hover {
  box-shadow: var(--shadow);
  border-color: #c7d2fe;
  transform: translateY(-1px);
}
.module-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.module-icon svg { width: 18px; height: 18px; }

.module-icon--blue    { background: #dbeafe; color: #1e40af; }
.module-icon--indigo  { background: #e0e7ff; color: #3730a3; }
.module-icon--green   { background: #dcfce7; color: #15803d; }
.module-icon--emerald { background: #d1fae5; color: #065f46; }
.module-icon--teal    { background: #ccfbf1; color: #0f766e; }
.module-icon--violet  { background: #ede9fe; color: #5b21b6; }
.module-icon--purple  { background: #f3e8ff; color: #7e22ce; }
.module-icon--amber   { background: #fef3c7; color: #92400e; }
.module-icon--sky     { background: #e0f2fe; color: #0369a1; }
.module-icon--orange  { background: #ffedd5; color: #c2410c; }
.module-icon--rose    { background: #ffe4e6; color: #9f1239; }
.module-icon--slate   { background: #f1f5f9; color: #374151; }

.module-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}
.module-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
}
.module-arrow {
  font-size: 13px;
  color: var(--color-muted);
  position: absolute;
  bottom: 14px;
  right: 14px;
  transition: color 0.12s, right 0.12s;
}
.module-tile:hover .module-arrow { color: var(--color-primary); right: 11px; }
.badge-count {
  display: inline-block;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
}

/* STRATEGIC OVERVIEW */
.overview-band {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.overview-stat {
  flex: 1;
  min-width: 100px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.overview-stat--green { background: #f0fdf4; border-color: #86efac; }
.overview-stat--amber { background: #fffbeb; border-color: #fcd34d; }
.overview-stat--blue  { background: #eff6ff; border-color: #93c5fd; }
.overview-stat--red   { background: #fef2f2; border-color: #fca5a5; }
.overview-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}
.overview-lbl {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 3px;
}

/* TREND BAR */
.trend-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.trend-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-muted);
  margin-right: 4px;
}
.trend-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.trend-pill--up   { background: #d1fae5; color: #065f46; }
.trend-pill--down { background: #fee2e2; color: #991b1b; }
.trend-pill--flat { background: #e5e7eb; color: #374151; }
.trend-pill--none { background: #f3f4f6; color: var(--color-muted); }

/* ATTENTION LIST */
.attention-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.attention-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 14px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.attention-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--color-primary);
  text-decoration: none;
  min-width: 120px;
}
.attention-name:hover { text-decoration: underline; }
.attention-goto {
  margin-left: auto;
  font-size: 12px;
  color: var(--color-primary);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
}
.attention-goto:hover { text-decoration: underline; }
.meta-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.meta-pill--blue  { background: #dbeafe; color: #1e40af; }
.meta-pill--amber { background: #fef3c7; color: #92400e; }

/* ═══════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════ */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  background: #fafafa;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}
.card .table { margin: 0; }
.card .news-list { padding: 12px 16px; }
.card .empty-state { padding: 32px 20px; }

.content-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 960px) { .content-row { grid-template-columns: 1fr; } }

/* LEGACY COMPAT — dashboard-section used on other pages */
.dashboard-section, .admin-section {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h3 { font-size: 14px; font-weight: 600; }
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }

/* ═══════════════════════════════════════════════════
   PAGE HEADER (detail/list pages)
═══════════════════════════════════════════════════ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}
.page-header h2 { font-size: 20px; font-weight: 700; }
.subtitle { color: var(--color-muted); font-size: 13px; margin-top: 2px; }

/* ═══════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
  color: var(--color-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }
.detail-table th { width: 160px; }

/* ═══════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--color-text);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.15s;
  background: white;
  color: var(--color-text);
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-row { display: flex; gap: 16px; }
.form-row .form-group { margin-bottom: 0; }
.form-row .flex-1 { flex: 1; }
.auth-form .form-group { margin-bottom: 18px; }
.role-select {
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════ */
.btn {
  display: inline-block;
  padding: 7px 15px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: white;
  color: var(--color-text);
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1.4;
}
.btn:hover { background: #f1f5f9; }
.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn-success { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-delete { background: #dc2626; color: white; border: 1px solid #b91c1c; border-radius: var(--radius); padding: 5px 12px; font-size: 0.8rem; cursor: pointer; }
.btn-delete:hover { background: #b91c1c; color: white; }
.btn-delete.btn-sm { padding: 3px 8px; font-size: 0.75rem; }
.btn-secondary { background: #6b7280; color: white; border-color: #6b7280; }
.btn-secondary:hover { background: #4b5563; border-color: #4b5563; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; text-align: center; padding: 11px; }
.btn-active { background: var(--color-primary); color: white; border-color: var(--color-primary); }

/* ═══════════════════════════════════════════════════
   BADGES
═══════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-draft, .badge-pending { background: #fef3c7; color: #92400e; }
.badge-reviewed { background: #dbeafe; color: #1e40af; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef9c3; color: #854d0e; }
.btn-xs { padding: 2px 8px; font-size: 0.72rem; border-radius: 4px; }
.badge-imported { background: #d1fae5; color: #065f46; }
.badge-valid { background: #dcfce7; color: #166534; }
.badge-invalid, .badge-failed { background: #fee2e2; color: #991b1b; }
.badge-validating { background: #dbeafe; color: #1e40af; }
.badge-news-pending { background: #fef3c7; color: #92400e; }
.badge-news-approved { background: #dcfce7; color: #166534; }
.badge-news-rejected { background: #fee2e2; color: #991b1b; }
.role-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  background: rgba(255,255,255,0.15);
  color: #f1f5f9;
  text-transform: uppercase;
}
.role-badge.role-admin { background: #7c3aed; }
.role-badge.role-analyst { background: #2563eb; }
.role-badge.role-reviewer { background: #0891b2; }
.role-badge.role-viewer { background: #374151; }

/* ═══════════════════════════════════════════════════
   ALERTS
═══════════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
  border-left: 4px solid;
}
.alert-success { background: #f0fdf4; border-color: var(--color-success); color: #14532d; }
.alert-error,
.alert-danger  { background: #fef2f2; border-color: var(--color-danger);  color: #7f1d1d; }
.alert-warning,
.alert-info    { background: #fffbeb; border-color: var(--color-warning); color: #78350f; }
.alert ul { margin: 8px 0 0 20px; }
.alert li { margin-bottom: 4px; }

/* ═══════════════════════════════════════════════════
   UPLOAD
═══════════════════════════════════════════════════ */
.upload-area {
  background: var(--color-bg-card);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.upload-form h3 { margin-bottom: 16px; font-size: 15px; }
.upload-hint {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--color-muted);
}
.upload-hint ul { margin: 8px 0 0 16px; }
.upload-hint li { margin-bottom: 4px; }

/* ═══════════════════════════════════════════════════
   NEWS
═══════════════════════════════════════════════════ */
.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fafafa;
}
.news-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 5px; flex-wrap: wrap; }
.news-title { font-size: 13px; font-weight: 500; }
.news-title a { color: var(--color-text); text-decoration: none; }
.news-title a:hover { color: var(--color-primary); text-decoration: underline; }
.news-grid { display: flex; flex-direction: column; gap: 16px; }
.news-full-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.news-full-header { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.news-full-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.news-full-title a { color: var(--color-text); text-decoration: none; }
.news-full-title a:hover { color: var(--color-primary); text-decoration: underline; }
.news-summary { font-size: 13px; color: var(--color-muted); margin-bottom: 10px; line-height: 1.5; }
.news-actions { display: flex; gap: 8px; }
.keyword-tag {
  background: #eff6ff;
  color: #1e40af;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}
.source-name { font-weight: 500; }

/* ═══════════════════════════════════════════════════
   FILTER BAR
═══════════════════════════════════════════════════ */
.filter-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-muted);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════
   MISC UTILITIES
═══════════════════════════════════════════════════ */
.text-muted    { color: var(--color-muted); }
.text-success  { color: var(--color-success); font-weight: 600; }
.text-danger   { color: var(--color-danger); font-weight: 600; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 24px; }
a { color: var(--color-primary); }
code {
  background: #f1f5f9;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
}

/* ═══════════════════════════════════════════════════
   DETAIL / FORM CARDS
═══════════════════════════════════════════════════ */
.detail-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.form-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 600px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.form-card-wide {
  max-width: none;
}

/* ═══════════════════════════════════════════════════
   ERROR LIST
═══════════════════════════════════════════════════ */
.error-list { display: flex; flex-direction: column; gap: 4px; }
.error-item {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  color: #7f1d1d;
  font-family: monospace;
}

/* ═══════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════ */
.footer {
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  text-align: center;
  padding: 16px 28px;
}
.footer-img {
  max-width: 100%;
  width: 560px;
  height: auto;
  display: block;
  margin: 0 auto;
}
.footer-auth {
  margin-top: 24px;
  background: transparent;
  border-top: none;
}

/* ═══════════════════════════════════════════════════
   REASONING / SITE DETAIL
═══════════════════════════════════════════════════ */
.reasoning-panel, .simulation-panel {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 24px;
  box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════════════
   CSS VARIABLE ALIASES
   Templates use short names; map them to our full names
═══════════════════════════════════════════════════ */
:root {
  --text-muted:   var(--color-muted);
  --border:       var(--color-border);
  --bg-secondary: var(--color-bg);
  --primary:      var(--color-primary);
}

/* ═══════════════════════════════════════════════════
   MISSING UTILITY CLASSES (used in templates)
═══════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-number {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.1;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.form-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
}
.form-control {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: white;
  color: var(--color-text);
  font-family: inherit;
  max-width: 100%;
}
.form-control-sm {
  padding: 4px 8px;
  font-size: 12px;
}
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.page-body {
  max-width: 100%;
}
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* fix form-card overflow so tables/charts can scroll inside */
.form-card {
  overflow: visible;
}

/* ═══════════════════════════════════════════════════
   HAMBURGER BUTTON (hidden on desktop)
═══════════════════════════════════════════════════ */
.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  color: var(--color-text);
  flex-shrink: 0;
  padding: 0;
  margin-right: 4px;
}
.topbar-hamburger:hover { background: #f1f5f9; }
.topbar-hamburger svg { display: block; }

/* ═══════════════════════════════════════════════════
   SIDEBAR BACKDROP (mobile overlay)
═══════════════════════════════════════════════════ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
  opacity: 0;
  transition: opacity 0.25s;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 960px)
═══════════════════════════════════════════════════ */
@media (max-width: 960px) {
  .content-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
═══════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* — Hamburger visible */
  .topbar-hamburger { display: flex; }

  /* — Sidebar: becomes a left-drawer overlay */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 50;
  }

  /* — Open state (body.sidebar-open) */
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
  }

  /* — Main takes full width */
  .app-main { margin-left: 0; }

  /* — Topbar: stack title row then buttons row */
  .topbar {
    padding: 6px 14px;
    gap: 4px;
    flex-wrap: wrap;
    height: auto;
    min-height: var(--topbar-height);
    align-items: flex-start;
  }
  .topbar-left {
    flex: 1 1 100%;
    align-items: center;
    min-width: 0;
    padding: 4px 0;
  }
  .topbar-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }
  .topbar-right {
    flex: 0 0 100%;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    gap: 6px;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
  }
  .topbar-right::-webkit-scrollbar { display: none; }
  .topbar-right .btn {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 11.5px;
    padding: 5px 10px;
  }
  .topbar-workspace { display: none; }

  /* — Main content */
  .main-content { padding: 14px; }

  /* — Page header wraps cleanly */
  .page-header {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header h2 { font-size: 18px; }

  /* — Form rows stack vertically */
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .form-row .form-group { margin-bottom: 14px; }

  /* — Form cards go full-width */
  .form-card {
    max-width: 100%;
    padding: 16px;
  }

  /* — Tables: horizontal scroll inside card/section */
  .card {
    overflow-x: auto;
    overflow-y: visible;
  }
  .dashboard-section,
  .admin-section,
  .detail-card {
    overflow-x: auto;
    padding: 14px;
  }

  /* — KPI strip */
  .kpi-strip {
    gap: 8px;
    flex-wrap: wrap;
  }
  .kpi-tile {
    min-width: 0;
    flex: 1 1 calc(50% - 8px);
    padding: 12px 10px;
  }
  .kpi-value { font-size: 22px; }

  /* — Module grid: 3 columns on tablet-mobile */
  .module-grid { grid-template-columns: repeat(3, 1fr); }

  /* — Overview band */
  .overview-band { gap: 8px; }
  .overview-stat {
    min-width: 0;
    flex: 1 1 calc(50% - 4px);
    padding: 10px 12px;
  }
  .overview-num { font-size: 22px; }

  /* — Filter bar stacks */
  .filter-bar {
    flex-direction: column;
    gap: 8px;
  }
  .filter-bar select,
  .filter-bar input[type="text"],
  .filter-bar input[type="search"] {
    width: 100%;
  }

  /* — Attention rows wrap */
  .attention-row { flex-wrap: wrap; }
  .attention-goto { margin-left: 0; }

  /* — Footer */
  .footer { padding: 12px 14px; }
  .footer-img { width: 220px; }

  /* — Section header wraps */
  .section-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* — Upload area */
  .upload-area { padding: 16px; }

  /* — Card header wraps */
  .card-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
  }

  /* ─ Inline 2-column grids: force single column ─ */
  /* Targets report templates that use hard-coded grid-template-columns:1fr 1fr */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ─ Form cards: allow overflow for charts/tables inside ─ */
  .form-card {
    overflow-x: auto !important;
    overflow-y: visible !important;
    padding: 16px !important;
    max-width: 100% !important;
  }

  /* ─ Stats grid on site detail ─ */
  .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* ─ Inline flex gaps that cause overflow: allow wrap ─ */
  [style*="display:flex"][style*="gap:1.5rem"],
  [style*="display:flex"][style*="gap:2rem"] {
    flex-wrap: wrap !important;
  }

  /* ─ Chart canvas height adjustments on mobile ─ */
  [style*="height:220px"] { height: 180px !important; }
  [style*="height:200px"] { height: 160px !important; }
  [style*="height:160px"] { height: 140px !important; }
  [style*="height:300px"] { height: 200px !important; }
  [style*="height:350px"] { height: 220px !important; }
  [style*="height:400px"] { height: 240px !important; }

  /* ─ Inline page-body max-width ─ */
  .page-body { max-width: 100% !important; }

  /* ─ Report section: always full width ─ */
  .report-section { width: 100% !important; }
  .report-section .form-card { width: 100% !important; }

  /* ─ Inline grids with minmax that still overflow ─ */
  [style*="grid-template-columns:repeat(auto-fill"] { min-width: 0 !important; }
  [style*="grid-template-columns:repeat(auto-fit"]  { min-width: 0 !important; }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — SMALL PHONE (≤ 480px)
   Note: inherits all 768px rules above
═══════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-title { font-size: 14px; }
  .kpi-tile { flex: 1 1 calc(50% - 6px); }
  .main-content { padding: 10px; }
  .topbar { padding: 0 10px; }
  .btn { font-size: 12px; padding: 6px 11px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ═══════════════════════════════════════════════════
   HELP / GUIDE DRAWER
═══════════════════════════════════════════════════ */
.help-drawer {
  position: fixed;
  top: 0; right: -440px;
  width: 400px;
  max-width: 96vw;
  height: 100%;
  background: var(--color-bg-card);
  border-left: 1px solid var(--color-border);
  box-shadow: -6px 0 30px rgba(0,0,0,.14);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transition: right .26s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.help-drawer.help-open { right: 0; }
.help-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 499;
}
.help-backdrop.help-open { display: block; }
.help-drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: linear-gradient(135deg,#1e40af,#0891b2);
  color: #fff;
}
.help-drawer-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.18);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.help-drawer-htitle { font-size: 14px; font-weight: 700; flex: 1; }
.help-drawer-hsubtitle { font-size: 11px; opacity: .8; }
.help-close-btn {
  background: rgba(255,255,255,.18);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.help-close-btn:hover { background: rgba(255,255,255,.3); }
.help-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
}
.help-sec { margin-bottom: 18px; }
.help-sec-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--color-primary);
  margin-bottom: 7px;
  padding-bottom: 5px;
  border-bottom: 2px solid #dbeafe;
}
.help-sec p { font-size: 13px; color: var(--color-text); line-height: 1.6; margin: 0 0 6px; }
.help-sec ul, .help-sec ol {
  font-size: 13px; color: var(--color-text);
  line-height: 1.55; padding-left: 18px; margin: 0;
}
.help-sec li { margin-bottom: 5px; }
.help-sec a { color: var(--color-primary); text-decoration: none; }
.help-sec a:hover { text-decoration: underline; }
.help-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  color: #1e40af; border-radius: 99px;
  padding: 2px 9px; font-size: 11.5px; font-weight: 500;
  margin: 2px; text-decoration: none;
}
.help-chip:hover { background: #dbeafe; }
.help-tip {
  background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 6px; padding: 9px 12px;
  font-size: 12px; color: #166534; margin-top: 8px; line-height: 1.5;
}
.btn-help {
  display: inline-flex; align-items: center; gap: 5px;
  background: #1e40af; color: #fff;
  border: none; border-radius: 6px;
  padding: 5px 11px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background .15s;
}
.btn-help:hover { background: #1d4ed8; }
.btn-help svg { flex-shrink: 0; }
@media (max-width: 768px) {
  .help-drawer { width: 100%; max-width: 100%; }
  .help-btn-text { display: none; }
  .btn-help { padding: 5px 8px; }
}
