/* Link Money Executive Dashboard Suite — Deep Space Theme */

:root {
  /* Deep Space palette */
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2333;
  --surface3: #242d3d;
  --border: #2a3444;
  --border-light: #3a4758;
  --text: #e6edf3;
  --text2: #8b949e;
  --text3: #6e7681;

  /* Link Money primary — orange */
  --primary: #f17e04;
  --primary-light: #ffa13d;
  --primary-dim: rgba(241,126,4,0.12);

  /* Accent colors — vibrant on dark */
  --green: #56d364;
  --green-dim: rgba(86,211,100,0.12);
  --red: #f85149;
  --red-dim: rgba(248,81,73,0.10);
  --yellow: #e3b341;
  --yellow-dim: rgba(227,179,65,0.10);
  --blue: #58a6ff;
  --blue-dim: rgba(88,166,255,0.10);
  --purple: #bc8cff;
  --purple-dim: rgba(188,140,255,0.10);
  --orange: #f0883e;
  --orange-dim: rgba(240,136,62,0.10);
  --cyan: #39d2c0;
  --cyan-dim: rgba(57,210,192,0.10);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 3px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.35);
}

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

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

.container { max-width: 1480px; margin: 0 auto; padding: 24px; }

/* Typography */
h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.3px; }
.subtitle { color: var(--text2); font-size: 12px; margin-bottom: 20px; }
.section-title { font-size: 14px; font-weight: 700; margin: 28px 0 14px 0; letter-spacing: -0.2px; }

/* Navigation */
.nav-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 0; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.nav-bar a {
  color: var(--text2); text-decoration: none; font-size: 12px;
  padding: 7px 14px; border-radius: 6px; transition: all 0.15s;
  font-weight: 500;
}
.nav-bar a:hover { color: var(--text); background: var(--surface2); }
.nav-bar a.active { color: var(--primary); background: var(--primary-dim); font-weight: 600; }
.nav-title { font-weight: 700; font-size: 14px; color: var(--text); margin-right: auto; }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.grid-5 { grid-template-columns: 1fr 1fr 1fr 1fr 1fr; }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-light); }
.card-title {
  font-size: 11px; text-transform: uppercase; color: var(--text2);
  letter-spacing: 0.8px; margin-bottom: 10px; font-weight: 600;
}

/* KPI Cards */
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  transition: border-color 0.2s, transform 0.2s;
}
.kpi-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.kpi-card .kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.kpi-card .kpi-label {
  font-size: 11px; text-transform: uppercase; color: var(--text2);
  letter-spacing: 0.8px; margin-bottom: 6px; font-weight: 600;
}
.kpi-card .kpi-sub { font-size: 12px; margin-top: 6px; color: var(--text2); }

/* Metrics */
.metric { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.metric-sm { font-size: 14px; font-weight: 600; }
.change { font-size: 12px; margin-top: 4px; }
.up { color: var(--green); }
.down { color: var(--red); }
.neutral { color: var(--text2); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  text-align: left; padding: 10px 12px; color: var(--text2);
  font-weight: 600; border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr { transition: background 0.1s; }
tr:hover { background: var(--surface2); }
td.right, th.right { text-align: right; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-purple { background: var(--purple-dim); color: var(--purple); }
.badge-orange { background: var(--orange-dim); color: var(--orange); }

/* Bars */
.bar-container { width: 100%; height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; }
.bar { height: 100%; border-radius: 3px; }

/* Alert banners */
.alert-banner {
  padding: 12px 18px; border-radius: 10px; margin-bottom: 12px;
  font-size: 12px; display: flex; align-items: center; gap: 10px;
}
.alert-banner.alert-red { background: var(--red-dim); border: 1px solid rgba(248,81,73,0.2); color: var(--red); }
.alert-banner.alert-yellow { background: var(--yellow-dim); border: 1px solid rgba(227,179,65,0.2); color: var(--yellow); }
.alert-banner.alert-green { background: var(--green-dim); border: 1px solid rgba(86,211,100,0.2); color: var(--green); }

/* Health indicators */
.health-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.health-dot.healthy { background: var(--green); box-shadow: 0 0 8px rgba(86,211,100,0.4); }
.health-dot.watch { background: var(--yellow); box-shadow: 0 0 8px rgba(227,179,65,0.4); }
.health-dot.action { background: var(--red); box-shadow: 0 0 8px rgba(248,81,73,0.4); }

/* Health banner */
.health-banner { padding: 14px 20px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.banner-green { background: var(--green-dim); border: 1px solid rgba(86,211,100,0.15); }
.banner-yellow { background: var(--yellow-dim); border: 1px solid rgba(227,179,65,0.15); }
.banner-red { background: var(--red-dim); border: 1px solid rgba(248,81,73,0.15); }

/* Date picker */
.date-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.date-controls input[type="date"] {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px; border-radius: 8px; font-family: inherit; font-size: 12px;
  transition: border-color 0.2s;
}
.date-controls input[type="date"]:focus { outline: none; border-color: var(--primary); }
.date-controls label { font-size: 12px; color: var(--text2); font-weight: 500; }
.date-controls button {
  background: var(--primary); color: #fff; border: none;
  padding: 7px 16px; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  transition: opacity 0.2s;
}
.date-controls button:hover { opacity: 0.9; }
.date-controls .preset-btn {
  background: var(--surface2); color: var(--text2); border: 1px solid var(--border); font-weight: 500;
}
.date-controls .preset-btn:hover { color: var(--text); border-color: var(--border-light); }
.date-controls .preset-btn.active { color: var(--primary); border-color: var(--primary); background: var(--primary-dim); }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 8px; }
.toolbar .btn-export, .nav-bar .btn-export {
  background: var(--surface2); color: var(--text2); border: 1px solid var(--border);
  padding: 7px 16px; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 500; transition: all 0.15s;
}
.toolbar .btn-export:hover, .nav-bar .btn-export:hover { color: var(--text); border-color: var(--border-light); }

/* Chart containers */
.chart-container { position: relative; width: 100%; height: 260px; }
.chart-container canvas { display: block; }
.sparkline-container { display: inline-block; vertical-align: middle; }
.sparkline-container canvas { height: 30px; width: 80px; }

/* Inline loading spinner */
.loading { text-align: center; padding: 40px; color: var(--text2); }
.loading::after {
  content: ''; display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
  margin-left: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ */
/* Link Logo Loading Overlay                                          */
/* ------------------------------------------------------------------ */
.link-loading-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(13,17,23,0.88);
  backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}
.link-loading-overlay.active { opacity: 1; pointer-events: auto; }

.link-loader-logo {
  width: 40px; height: 40px;
  animation: logo-breathe 2s ease-in-out infinite;
  filter: drop-shadow(0 0 16px rgba(241,126,4,0.3));
}

.link-loader-text {
  margin-top: 16px; font-size: 13px; font-weight: 500;
  color: var(--text2); letter-spacing: 0.3px;
}
.link-loader-bar {
  margin-top: 12px; width: 112px; height: 3px;
  background: var(--border); border-radius: 2px; overflow: hidden;
}
.link-loader-bar-inner {
  height: 100%; width: 35%; border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  animation: loader-slide 1.3s ease-in-out infinite;
}

@keyframes logo-breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.7; }
}
@keyframes loader-slide {
  0% { transform: translateX(-120%); }
  50% { transform: translateX(350%); }
  100% { transform: translateX(-120%); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

::selection { background: rgba(241,126,4,0.2); color: var(--text); }

/* Responsive */
@media (max-width: 1100px) { .grid-4, .grid-5, .grid-6 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: 1fr; }
  .nav-bar { gap: 4px; } .container { padding: 16px; }
}

/* Drag-and-Drop Reorderable Sections */
.draggable-section { position: relative; padding-left: 28px; }
.drag-handle {
  position: absolute; top: 8px; left: 0; width: 22px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: grab; color: var(--text3, #484d64); font-size: 14px; line-height: 1; letter-spacing: 2px;
  border-radius: 4px; transition: color 0.15s, background 0.15s, opacity 0.15s;
  user-select: none; z-index: 100; opacity: 0;
}
.draggable-section:hover .drag-handle { opacity: 0.6; }
.drag-handle:hover { opacity: 1 !important; color: var(--text); background: var(--surface2); }
.drag-handle:active { cursor: grabbing; }
.sortable-ghost {
  opacity: 0.4; border: 2px dashed var(--primary, #f17e04); border-radius: 8px;
  background: var(--primary-dim, rgba(241,126,4,0.08));
}
.sortable-chosen { box-shadow: 0 8px 32px rgba(0,0,0,0.4); transform: scale(1.005); z-index: 100; }
.btn-reset-layout {
  background: transparent; color: var(--text3, #484d64); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
  font-family: inherit; font-size: 11px; font-weight: 500; transition: all 0.15s; margin-left: 8px;
}
.btn-reset-layout:hover { color: var(--text); border-color: var(--border-light); background: var(--surface2); }

/* Print */
@media print {
  body { background: #fff; color: #000; font-size: 11px; }
  .container { max-width: 100%; padding: 10px; }
  .nav-bar, .date-controls, .toolbar, .btn-export, .preset-btn, .link-loading-overlay, .drag-handle, .btn-reset-layout { display: none !important; }
  .card, .kpi-card { background: #fff; border: 1px solid #ccc; break-inside: avoid; box-shadow: none; }
  table th { border-bottom: 2px solid #333; background: #f5f5f5; }
  table td { border-bottom: 1px solid #ddd; }
  tr:hover { background: transparent; }
}
