/* ==========================================================================
   Industrial AI Intelligence Center — estilos base
   Estética SaaS B2B industrial: minimalista, orientada a datos, premium.
   ========================================================================== */

:root {
  --bg: #0b1220;
  --sidebar-bg: #0f1a2e;
  --sidebar-bg-2: #0b1526;
  --app-bg: #f4f6f9;
  --card-bg: #ffffff;
  --border: #e4e8f0;
  --text-primary: #101828;
  --text-secondary: #667085;
  --text-muted: #98a2b3;
  --accent: #2563eb;
  --accent-light: #eff4ff;
  --accent-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0891b2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 4px 12px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.10);
  --sidebar-w: 264px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--app-bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }

/* ------------------------------ App shell -------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ------------------------------ Sidebar ---------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand .brand-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; flex-shrink: 0;
}
.sidebar-brand .brand-text { line-height: 1.15; }
.sidebar-brand .brand-text strong { display: block; color: #fff; font-size: 14.5px; font-weight: 700; letter-spacing: .2px; }
.sidebar-brand .brand-text span { font-size: 11px; color: #7c8aa5; }

.sidebar-company {
  padding: 12px 20px;
  font-size: 12px;
  color: #7c8aa5;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-company strong { color: #e2e8f0; font-weight: 600; }

.sidebar-nav { padding: 10px 12px; flex: 1; }
.sidebar-nav .nav-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #5b6c8c;
  padding: 14px 12px 6px;
  font-weight: 600;
}
.sidebar-nav a.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: #b6c2d9;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
  position: relative;
}
.sidebar-nav a.nav-item i { width: 18px; text-align: center; font-size: 14px; color: #7c8aa5; }
.sidebar-nav a.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.nav-item.active { background: rgba(37,99,235,.18); color: #fff; }
.sidebar-nav a.nav-item.active i { color: #60a5fa; }
.sidebar-nav a.nav-item.active::before {
  content: '';
  position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px;
  background: #3b82f6; border-radius: 3px;
}
.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: 11px;
  color: #5b6c8c;
}
.sidebar-footer .ai-status {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  color: #93e2b0; font-weight: 600; font-size: 12px;
}
.sidebar-footer .ai-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }

/* ------------------------------ Main area -------------------------------- */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .topbar-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.topbar .topbar-title small { display: block; font-size: 11.5px; font-weight: 400; color: var(--text-secondary); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: #f4f6f9; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; font-size: 13px; color: var(--text-muted); width: 260px;
}
.topbar-search i { color: var(--text-muted); }
.topbar-icon-btn {
  position: relative;
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 14px;
}
.topbar-icon-btn .dot {
  position: absolute; top: -3px; right: -3px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--danger);
  border: 2px solid #fff;
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg,#2563eb,#4f46e5);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.topbar-user .user-meta { line-height: 1.2; }
.topbar-user .user-meta strong { font-size: 12.5px; display: block; }
.topbar-user .user-meta span { font-size: 11px; color: var(--text-secondary); }

.page-content { padding: 28px; max-width: 1500px; }

/* ------------------------------ Common blocks ---------------------------- */
.page-header { margin-bottom: 22px; }
.page-header h1 { font-size: 24px; font-weight: 800; letter-spacing: -.3px; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 5px; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 14.5px; font-weight: 700; }
.card-header .sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3{grid-template-columns:repeat(2,1fr);} }
@media (max-width: 760px) { .grid-4,.grid-3,.grid-2 { grid-template-columns: 1fr; } }

/* KPI cards */
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.kpi-card .kpi-top { display: flex; align-items: flex-start; justify-content: space-between; }
.kpi-card .kpi-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.kpi-card .kpi-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; margin-top: 12px; }
.kpi-card .kpi-value { font-size: 25px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; }
.kpi-card .kpi-delta { font-size: 12px; font-weight: 600; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--text-secondary); }

/* Badges / pills */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
  border: 1px solid transparent;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge.b-normal { color:#16a34a; background:#ecfdf5; border-color:#bbf7d0; }
.badge.b-atencion { color:#b45309; background:#fffbeb; border-color:#fde68a; }
.badge.b-anomalia { color:#c2410c; background:#fff7ed; border-color:#fed7aa; }
.badge.b-critico { color:#b91c1c; background:#fef2f2; border-color:#fecaca; }
.badge.b-info { color:#0369a1; background:#f0f9ff; border-color:#bae6fd; }
.badge.b-neutral { color:#475467; background:#f2f4f7; border-color:#e4e8f0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: #fff; color: var(--text-primary);
  transition: all .15s;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ai { background: linear-gradient(135deg,#4338ca,#2563eb); border: none; color: #fff; }
.btn-ai:hover { filter: brightness(1.08); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger-outline { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-outline-accent { color: var(--accent); border-color: #bfdbfe; background: var(--accent-light); }

/* AI insight box */
.ai-box {
  border-radius: var(--radius);
  background: linear-gradient(135deg, #0f1a2e 0%, #1e2a4a 100%);
  color: #e2e8f0;
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
}
.ai-box::before {
  content: '';
  position: absolute; top: -60px; right: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(99,102,241,.35), transparent 70%);
}
.ai-box .ai-box-tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #93c5fd; margin-bottom: 12px;
}
.ai-box .ai-box-tag i { color: #818cf8; }
.ai-box p { font-size: 14.5px; line-height: 1.65; color: #dbe4f3; position: relative; z-index: 1; }
.ai-box .ai-box-actions { margin-top: 16px; display: flex; gap: 10px; position: relative; z-index: 1; }
.ai-box .btn-light { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.18); }
.ai-box .btn-light:hover { background: rgba(255,255,255,.18); }

.ai-inline-box {
  background: var(--accent-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.ai-inline-box .tag { display:flex; align-items:center; gap:7px; font-size:11.5px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:#1d4ed8; margin-bottom:8px;}
.ai-inline-box p { font-size: 13.5px; line-height: 1.6; color: #1e3a5f; }

/* Attention section */
.attention-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 5px solid;
  padding: 18px 20px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.attention-card.sev-critica { border-left-color: var(--danger); }
.attention-card.sev-alta { border-left-color: #f97316; }
.attention-card.sev-media { border-left-color: var(--warning); }
.attention-card .att-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.attention-card h4 { font-size: 15.5px; font-weight: 700; }
.attention-card .att-meta { font-size: 12px; color: var(--text-secondary); }
.attention-card p.att-text { font-size: 13.5px; color: #344054; line-height: 1.6; margin: 8px 0 14px; }
.attention-card .att-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 10px 14px; background: #f8fafc;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-secondary); font-weight: 700; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
.data-table tr:hover td { background: #fafbfd; }
.data-table tr:last-child td { border-bottom: none; }
.link-row { cursor: pointer; }

/* Line grid cards */
.line-tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 15px;
  background: #fff;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.line-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.line-tile .lt-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.line-tile .lt-code { font-weight: 800; font-size: 15px; }
.line-tile .lt-oee { font-size: 22px; font-weight: 800; margin: 6px 0 2px; }
.line-tile .lt-label { font-size: 11px; color: var(--text-secondary); }
.line-tile .lt-bar { height: 5px; border-radius: 4px; background: #eef1f6; margin-top: 10px; overflow: hidden; }
.line-tile .lt-bar span { display: block; height: 100%; border-radius: 4px; }

/* Chat / copilot */
.chat-shell { display: flex; flex-direction: column; height: 640px; }
.chat-messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 4px 16px; }
.chat-shell > div:last-child { flex: 0 0 auto; }
.chat-msg { display: flex; gap: 12px; margin-bottom: 18px; max-width: 780px; }
.chat-msg.user { margin-left: auto; flex-direction: row-reverse; }
.chat-avatar { width: 34px; height: 34px; border-radius: 9px; flex-shrink:0; display:flex; align-items:center; justify-content:center; font-size:14px; color:#fff; }
.chat-avatar.ai { background: linear-gradient(135deg,#4338ca,#2563eb); }
.chat-avatar.user { background: #475467; }
.chat-bubble { background:#fff; border:1px solid var(--border); border-radius: 12px; padding: 14px 16px; font-size: 13.8px; line-height: 1.65; box-shadow: var(--shadow-sm); }
.chat-msg.user .chat-bubble { background: var(--accent); color: #fff; border-color: var(--accent); }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.chat-chip {
  border: 1px solid #d0d9e8; background: #fff; color: var(--text-primary);
  padding: 8px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
}
.chat-chip:hover { background: var(--accent-light); border-color: #bfdbfe; }
.chat-input-bar {
  display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border);
  background: #fff; border-radius: var(--radius); margin-top: 8px;
}
.chat-input-bar input { flex: 1; border: none; outline: none; font-size: 14px; padding: 0 6px; }
.chat-sources { margin-top: 10px; display:flex; gap:8px; flex-wrap: wrap; }
.source-chip { display:inline-flex; align-items:center; gap:6px; background:#f2f4f7; border:1px solid var(--border); border-radius: 20px; padding: 5px 11px; font-size:11.5px; font-weight:600; color:#344054; }

/* Timeline */
.timeline-item { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid #f0f2f6; }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex-shrink:0; }
.timeline-content .tl-time { font-size: 11.5px; color: var(--text-secondary); }
.timeline-content .tl-title { font-size: 13.5px; font-weight: 600; margin-top: 2px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 11px 18px; font-size: 13.5px; font-weight: 600; color: var(--text-secondary);
  border-bottom: 2px solid transparent; background: none; border-radius: 0;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover { color: var(--text-primary); }

/* Report cards */
.report-type-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  padding: 22px; box-shadow: var(--shadow-sm); cursor: pointer; transition: box-shadow .15s, transform .15s;
}
.report-type-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.report-type-card .rt-icon { width: 44px; height: 44px; border-radius: 10px; display:flex; align-items:center; justify-content:center; font-size: 18px; margin-bottom: 14px; }

/* Doc drop zone */
.dropzone {
  border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 40px 20px;
  text-align: center; color: var(--text-secondary); background: #fbfcfe;
}
.dropzone i { font-size: 30px; color: #94a3b8; margin-bottom: 10px; }

/* Integration card */
.integration-card { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; padding: 18px 20px; box-shadow: var(--shadow-sm); }
.integration-card .ic-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.integration-card .ic-icon { width: 40px; height: 40px; border-radius: 10px; background:#eff4ff; color:var(--accent); display:flex; align-items:center; justify-content:center; font-size:16px; }
.integration-card .ic-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 5px 0; color: var(--text-secondary); }
.integration-card .ic-row strong { color: var(--text-primary); font-weight: 600; }

/* utility */
.flex { display: flex; }
.flex-between { display:flex; align-items:center; justify-content:space-between; }
.gap-8 { gap: 8px; } .gap-10{gap:10px;} .gap-14{gap:14px;}
.mt-8{margin-top:8px;} .mt-14{margin-top:14px;} .mt-20{margin-top:20px;} .mt-24{margin-top:24px;}
.mb-14{margin-bottom:14px;} .mb-20{margin-bottom:20px;}
.text-sec { color: var(--text-secondary); }
.text-sm { font-size: 12.5px; }
.tag-focus { background:#fef3c7; color:#92400e; font-size:10.5px; font-weight:700; padding:2px 8px; border-radius:20px; margin-left:6px; }
.chart-box { position: relative; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: #101828; color: #fff; font-size: 11.5px; font-weight: 500;
  padding: 7px 11px; border-radius: 7px; white-space: nowrap; z-index: 100;
  box-shadow: var(--shadow-lg);
}
[data-tooltip]:hover::before {
  content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #101828; margin-bottom: -2px; z-index: 100;
}

/* filters bar */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-select {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: 8px 12px; font-size: 12.5px; color: var(--text-primary); font-weight: 500;
}

#lines-grid { grid-template-columns: repeat(6, 1fr) !important; }
@media (max-width: 1300px) { #lines-grid { grid-template-columns: repeat(4, 1fr) !important; } }
@media (max-width: 760px) { #lines-grid { grid-template-columns: repeat(2, 1fr) !important; } }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .topbar-search { display:none; }
}
