/* =====================================================================
   AEICC — Ashiana Enterprise Intelligence & Command Center
   Design tokens & base styles.

   Brand carried over from the Legend Group enterprise portal:
     --crimson (primary brand)   #8B1A1A
     --rust (secondary accent)   #C4622D
     --charcoal (ink/text)       #2C2C2C
   Extended for AEICC's three-source command-center identity:
     --hr (HR module accent)     steel blue
     --meter (Meter accent)      amber/energy
     --oms (OMS accent)          deep rust (matches brand secondary)
   ===================================================================== */

:root {
  /* Brand */
  --crimson: #8B1A1A;
  --crimson-dark: #6B1414;
  --rust: #C4622D;
  --charcoal: #2C2C2C;

  /* Module accents — each source system gets a stable identity color
     used consistently across KPI cards, charts, and sidebar groups */
  --mod-hr: #2E5C8A;
  --mod-hr-bg: #EAF1F8;
  --mod-meter: #B8860B;
  --mod-meter-bg: #FBF3DF;
  --mod-oms: #8B1A1A;
  --mod-oms-bg: #F8EAEA;

  /* Surfaces */
  --bg-app: #F6F5F3;
  --bg-card: #FFFFFF;
  --bg-sidebar: #20201F;
  --border-subtle: #E4E1DC;
  --border-card: #EAE7E1;

  /* Text */
  --text-primary: #20201F;
  --text-secondary: #6B6862;
  --text-on-dark: #F2F0EC;
  --text-muted-on-dark: #9A968D;

  /* Status */
  --status-good: #2E7D4F;
  --status-warn: #C4622D;
  --status-critical: #A22323;

  /* Type */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  /* Layout */
  --sidebar-width: 264px;
  --sidebar-collapsed-width: 72px;
  --header-height: 64px;
  --radius-card: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(32, 32, 31, 0.04), 0 1px 8px rgba(32, 32, 31, 0.04);
}

[data-theme="dark"] {
  --bg-app: #161615;
  --bg-card: #1E1E1C;
  --border-subtle: #2D2D2A;
  --border-card: #2D2D2A;
  --text-primary: #F2F0EC;
  --text-secondary: #9A968D;
  --mod-hr-bg: #1B2733;
  --mod-meter-bg: #2B240F;
  --mod-oms-bg: #2B1818;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

/* ---------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) 1fr;
}

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.sidebar {
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
}

.sidebar-brand .mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--crimson), var(--rust));
  flex-shrink: 0;
  position: relative;
}

.sidebar-brand .mark::after {
  /* Three-source convergence mark: three thin lines meeting at one point */
  content: '';
  position: absolute;
  inset: 7px;
  background:
    linear-gradient(115deg, transparent 46%, rgba(255,255,255,0.85) 46%, rgba(255,255,255,0.85) 54%, transparent 54%),
    linear-gradient(245deg, transparent 46%, rgba(255,255,255,0.55) 46%, rgba(255,255,255,0.55) 54%, transparent 54%),
    linear-gradient(0deg, transparent 46%, rgba(255,255,255,0.35) 46%, rgba(255,255,255,0.35) 54%, transparent 54%);
}

.sidebar-brand .name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
}
.sidebar-brand .name small {
  display: block;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted-on-dark);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-collapsed .sidebar-brand .name { display: none; }

.nav-group { margin-bottom: 4px; }

.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted-on-dark);
  padding: 14px 12px 6px;
}

.sidebar-collapsed .nav-group-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-on-dark);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: rgba(196,98,45,0.18); color: #F0B98C; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.nav-item .dot.hr { background: var(--mod-hr); }
.nav-item .dot.meter { background: var(--mod-meter); }
.nav-item .dot.oms { background: var(--mod-oms); }

.sidebar-collapsed .nav-item span.label { display: none; }

/* ---------------------------------------------------------------------
   Header
   --------------------------------------------------------------------- */
.app-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  font-size: 18px;
}

.header-actions { display: flex; align-items: center; gap: 14px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--crimson);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}

/* ---------------------------------------------------------------------
   Content area
   --------------------------------------------------------------------- */
.content { padding: 24px; max-width: 1440px; }

/* ---------------------------------------------------------------------
   KPI cards
   --------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.kpi-card.mod-hr::before { background: var(--mod-hr); }
.kpi-card.mod-meter::before { background: var(--mod-meter); }
.kpi-card.mod-oms::before { background: var(--mod-oms); }

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
}

.kpi-value.no-data {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.kpi-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ---------------------------------------------------------------------
   Panels / chart containers
   --------------------------------------------------------------------- */
.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
@media (max-width: 1024px) { .panel-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-header h3 { font-size: 15px; }
.panel-header .sub { font-size: 12px; color: var(--text-secondary); }

/* ---------------------------------------------------------------------
   Filter bar
   --------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
}

.filter-bar select, .filter-bar input[type="date"] {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  color: var(--text-primary);
}

.saved-filter-select {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  max-width: 160px;
}

.btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--crimson); color: #fff; }
.btn-primary:hover { background: var(--crimson-dark); }
.btn-ghost { background: transparent; border-color: var(--border-subtle); color: var(--text-primary); }

/* ---------------------------------------------------------------------
   Empty state
   --------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

/* ---------------------------------------------------------------------
   Data tables
   --------------------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.data-table tbody tr:hover { background: var(--bg-app); }
.data-table .num { text-align: right; font-family: var(--font-mono); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
}
.badge.on-roll { background: var(--mod-hr-bg); color: var(--mod-hr); }
.badge.off-roll { background: var(--bg-app); color: var(--text-secondary); }
.badge.good { background: #E6F4EC; color: var(--status-good); }
.badge.warn { background: #FBF1E8; color: var(--status-warn); }
.badge.critical { background: #FBEAEA; color: var(--status-critical); }

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}
.pagination a, .pagination span.current {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
.pagination span.current { background: var(--crimson); color: #fff; border-color: var(--crimson); }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------------
   MIS report print stylesheet — used for "Print / Save as PDF" export.
   Hides app chrome (sidebar, header, filter bar, export buttons) and
   lets the report content fill the page.
   --------------------------------------------------------------------- */
.report-section { margin-bottom: 28px; }
.report-section h2 {
  font-size: 16px;
  border-bottom: 2px solid var(--crimson);
  padding-bottom: 8px;
  margin-bottom: 14px;
}
.report-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.report-export-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

@media print {
  .sidebar, .app-header, .report-export-row, .no-print { display: none !important; }
  .app-shell { grid-template-columns: 1fr !important; }
  .content { padding: 0 !important; max-width: 100% !important; }
  body { background: #fff !important; }
  .panel, .kpi-card { box-shadow: none !important; border: 1px solid #ccc !important; }
  .report-section { page-break-inside: avoid; }
}
