/* ============ IOMS Theme — gradient #0f5b73 → #1581a3, cards #093442 ============ */
:root {
  --bg-start: #0f5b73;
  --bg-end: #1581a3;
  --card: #093442;
  --card-hover: #0c4558;
  --accent: #22d3ee;
  --accent-soft: #67e8f9;
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.72);
  --border: rgba(255, 255, 255, 0.15);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent-soft); text-decoration: none; }
a:hover { color: var(--accent); }

/* -------- Landing / login -------- */
.landing {
  display: grid; grid-template-columns: 2fr 1fr;
  min-height: 100vh;
}
.landing-left, .landing-right { padding: 3rem; display: flex; flex-direction: column; justify-content: center; }
.landing-left { background: rgba(9, 52, 66, 0.75); }
.landing-right { background: rgba(9, 52, 66, 0.4); }
@media (max-width: 900px) {
  .landing { grid-template-columns: 1fr; }
}

.login-box {
  background: var(--card); padding: 2.5rem; border-radius: 16px;
  max-width: 440px; width: 100%; margin: 0 auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.login-box h2 { margin-bottom: 0.5rem; }
.login-box p.sub { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

.welcome h1 { font-size: 2.4rem; margin-bottom: 1rem; line-height: 1.2; }
.welcome p { color: var(--text-muted); font-size: 1.1rem; line-height: 1.6; }

/* -------- Top navigation -------- */
.navbar {
  background: rgba(9, 52, 66, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 2rem;
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand { font-weight: 700; font-size: 1.2rem; letter-spacing: 0.5px; }
.nav-links { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; }
.nav-links a {
  padding: 0.5rem 0.9rem; border-radius: 8px;
  color: var(--text-muted); transition: all 0.15s;
  font-size: 0.92rem;
}
.nav-links a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-links a.active { background: var(--accent); color: var(--card); font-weight: 600; }
.nav-user { color: var(--text-muted); font-size: 0.88rem; display: flex; align-items: center; gap: 0.75rem; }

/* -------- Layout -------- */
.container { max-width: 1400px; margin: 0 auto; padding: 2rem; }
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h1 { font-size: 1.7rem; }
.page-header .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* -------- Cards -------- */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
.card h3 { margin-bottom: 1rem; font-size: 1.05rem; font-weight: 600; color: var(--accent-soft); }

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

/* -------- KPI cards -------- */
.kpi {
  background: var(--card);
  padding: 1.3rem 1.5rem;
  border-radius: 14px;
  border-left: 4px solid var(--accent);
  transition: transform 0.15s;
}
.kpi:hover { transform: translateY(-2px); }
.kpi .label { color: var(--text-muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.4rem; }
.kpi .value { font-size: 2rem; font-weight: 700; }
.kpi .sub { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.3rem; }
.kpi.success { border-color: var(--success); }
.kpi.warning { border-color: var(--warning); }
.kpi.danger { border-color: var(--danger); }

/* -------- Forms -------- */
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1rem; }
.form-row.single { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) {
  .form-row, .form-row.three { grid-template-columns: 1fr; }
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select option { background: var(--card); color: var(--text); }

/* -------- Buttons -------- */
.btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 0.4rem;
  text-decoration: none;
}
.btn:hover { background: var(--card-hover); transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: var(--card); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-soft); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn.small { padding: 0.4rem 0.8rem; font-size: 0.82rem; }

/* -------- Tables -------- */
.table-wrap { overflow-x: auto; border-radius: 12px; background: var(--card); }
table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
}
table thead { background: rgba(0, 0, 0, 0.3); }
table th, table td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
table th { font-weight: 600; color: var(--accent-soft); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; }
table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
table tbody tr:last-child td { border-bottom: none; }

/* -------- Badges -------- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.1);
}
.badge.success { background: rgba(52, 211, 153, 0.25); color: var(--success); }
.badge.warning { background: rgba(251, 191, 36, 0.25); color: var(--warning); }
.badge.danger { background: rgba(248, 113, 113, 0.25); color: var(--danger); }
.badge.info { background: rgba(96, 165, 250, 0.25); color: var(--info); }
.badge.muted { background: rgba(255,255,255,0.08); color: var(--text-muted); }

/* -------- Flash messages -------- */
.flashes { position: fixed; top: 5rem; right: 1rem; z-index: 1000; max-width: 400px; }
.flash {
  padding: 0.9rem 1.2rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  background: var(--card);
  border-left: 4px solid var(--info);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: slide-in 0.3s ease-out;
}
.flash.success { border-color: var(--success); }
.flash.danger { border-color: var(--danger); }
.flash.warning { border-color: var(--warning); }
@keyframes slide-in { from { transform: translateX(120%); } to { transform: translateX(0); } }

/* -------- Filter bar -------- */
.filter-bar {
  background: var(--card);
  padding: 1rem 1.25rem;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.filter-bar .form-group { gap: 0.25rem; }
.filter-bar label { font-size: 0.75rem; }

/* -------- AI Assistant widget -------- */
.ai-fab {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--accent); color: var(--card);
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none;
  box-shadow: 0 10px 30px rgba(34, 211, 238, 0.4);
  font-size: 1.4rem; font-weight: 700;
  z-index: 999;
  transition: transform 0.2s;
}
.ai-fab:hover { transform: scale(1.08); }

.ai-panel {
  position: fixed; bottom: 5rem; right: 1.5rem;
  width: 400px; max-width: calc(100vw - 3rem); height: 500px;
  max-height: calc(100vh - 7rem); min-width: 320px; min-height: 300px;
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  z-index: 998;
  overflow: hidden;
  resize: both;   /* native drag-to-resize from bottom-right corner */
}
.ai-panel.open { display: flex; }

/* Size-preset classes */
.ai-panel.size-sm { width: 380px; height: 450px; }
.ai-panel.size-md { width: 520px; height: 600px; }
.ai-panel.size-lg { width: 720px; height: 720px; }
.ai-panel.size-xl {
  width: calc(100vw - 3rem); height: calc(100vh - 7rem);
  right: 1.5rem; bottom: 5rem;
}
.ai-header { padding: 1rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.2); gap: 0.5rem; }
.ai-header h4 { font-size: 1rem; font-weight: 600; flex: 1; }
.ai-size-controls { display: flex; gap: 0.2rem; margin-right: 0.3rem; }
.ai-size-controls button {
  background: rgba(255,255,255,0.08); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  width: 28px; height: 28px; border-radius: 6px;
  font-size: 0.75rem; font-weight: 600;
  transition: all 0.15s;
}
.ai-size-controls button:hover { background: var(--accent); color: var(--card); }
.ai-size-controls button.active { background: var(--accent); color: var(--card); }
.ai-close { background: none; border: none; color: white; cursor: pointer; font-size: 1.4rem; padding: 0 0.5rem; }
.ai-body { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.ai-msg { padding: 0.65rem 0.9rem; border-radius: 10px; font-size: 0.88rem; white-space: pre-wrap; line-height: 1.5; }
.ai-msg.user { background: rgba(34, 211, 238, 0.15); align-self: flex-end; max-width: 85%; }
.ai-msg.bot { background: rgba(255,255,255,0.06); align-self: flex-start; max-width: 95%; }
.ai-footer { padding: 0.75rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; }
.ai-footer input { flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--border); color: white; padding: 0.55rem 0.8rem; border-radius: 8px; font-size: 0.9rem; }
.ai-footer input:focus { outline: none; border-color: var(--accent); }
.ai-actions { display: flex; gap: 0.4rem; padding: 0 1rem 0.5rem; }
.ai-actions .btn { font-size: 0.75rem; padding: 0.3rem 0.7rem; }

/* -------- Progress bar -------- */
.progress { background: rgba(0,0,0,0.3); border-radius: 20px; overflow: hidden; height: 8px; }
.progress-bar { background: var(--accent); height: 100%; transition: width 0.3s; }

/* -------- Utility -------- */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; gap: 0.5rem; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none; }
.chart-container { position: relative; height: 280px; }

/* -------- Company filter chips -------- */
.company-chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.88rem;
  user-select: none;
}
.company-chip:hover { background: rgba(255,255,255,0.12); }
.company-chip input[type="checkbox"] {
  margin: 0;
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.company-chip.active {
  background: rgba(34, 211, 238, 0.18);
  border-color: var(--accent);
  color: var(--text);
}
.company-chip.active span { font-weight: 600; }
