/* Ekara Investor Suite — Product-grade design system */
:root {
  --primary: #059669;
  --primary-hover: #047857;
  --primary-muted: #d1fae5;
  --primary-subtle: #ecfdf5;
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --error: #ef4444;
  --error-bg: #fee2e2;
  --bg-app: #f9fafb;
  --bg-surface: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --text-placeholder: #9ca3af;
  --gray-500: #6b7280;
  --sidebar-width: 260px;
  --header-height: 64px;
  --content-max: 1280px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 2px 8px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 24px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.04);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 22px;
  --text-3xl: 26px;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --tracking-tight: -0.01em;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  padding: var(--space-6) 0;
  display: flex;
  flex-direction: column;
  box-shadow: 1px 0 0 0 var(--border-light);
}
.sidebar .logo {
  padding: 0 var(--space-6) var(--space-6);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: var(--primary);
}
.sidebar .logo a { color: inherit; text-decoration: none; display: inline-block; }
.sidebar .logo img.logo-img { display: block; max-height: 56px; width: auto; object-fit: contain; }
.sidebar .nav { flex: 1; }
.sidebar .nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  margin: 0 var(--space-2);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: color 0.15s, background 0.15s;
}
.sidebar .nav a:hover { color: var(--text-primary); background: var(--border-light); }
.sidebar .nav a.active { color: var(--primary); background: var(--primary-subtle); font-weight: 600; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-app); }
.header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  flex-shrink: 0;
  box-shadow: 0 1px 0 0 var(--border-light);
}
.header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.header-right { display: flex; align-items: center; gap: var(--space-4); }
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #047857 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.avatar:hover { opacity: 0.92; transform: scale(1.02); }

.notification-bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.notification-bell:hover { background: var(--border-light); color: var(--text-primary); }
.notification-bell:focus { outline: none; }
.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Notification dropdown popover */
.notification-dropdown { position: relative; }
.notification-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.notification-dropdown.open .notification-popover { display: flex; }
.notification-popover-header {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-base);
}
.notification-popover-body {
  overflow-y: auto;
  max-height: 280px;
}
.notification-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}
.notification-item:hover { background: var(--border-light); }
.notification-item-title { font-weight: 500; }
.notification-item-time { font-size: 11px; color: var(--text-tertiary); }
.notification-popover-footer {
  display: block;
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  border-top: 1px solid var(--border-light);
  background: var(--bg-base);
  transition: background 0.15s;
}
.notification-popover-footer:hover { background: var(--border-light); }
.notification-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}
.notification-bell { border: none; background: transparent; cursor: pointer; }
.notification-bell[href] { text-decoration: none; }
.notification-dropdown .notification-bell { border: none; background: transparent; }
.notification-dropdown .notification-bell:hover { background: var(--border-light); }

.rec-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
}
.rec-card.rec-high { border-left-color: var(--error); }
.rec-card .rec-meta { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.rec-card .rec-meta .rec-priority { color: var(--error); }
.rec-card .rec-meta .rec-category { color: var(--text-muted); }
.rec-card .rec-meta .rec-date { color: var(--text-muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.rec-card .rec-title { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-2); color: var(--text-primary); }
.rec-card .rec-actions { margin: 0; padding-left: 20px; font-size: var(--text-sm); color: var(--text-primary); line-height: 1.6; }
.rec-expert-badge { display: inline-block; font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-4); }
.rec-company-block { margin-bottom: var(--space-4); border: 1px solid var(--border-light); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-surface); }
.rec-company-block summary { padding: var(--space-4) var(--space-5); font-weight: 600; font-size: var(--text-base); color: var(--text-primary); cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.rec-company-block summary::-webkit-details-marker { display: none; }
.rec-company-block summary::after { content: ''; width: 20px; height: 20px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat center; transition: transform 0.2s; }
.rec-company-block[open] summary::after { transform: rotate(180deg); }
.rec-company-body { padding: 0 var(--space-5) var(--space-5); }
.rec-company-body .rec-card { margin-bottom: var(--space-4); }
.rec-company-body .rec-card:last-child { margin-bottom: 0; }

.content { flex: 1; padding: var(--space-6); overflow-x: auto; }
.content-inner { max-width: var(--content-max); margin: 0 auto; }

.page-hero { margin-bottom: var(--space-6); }
.page-hero .page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  line-height: 1.3;
}
.page-hero .page-desc { font-size: var(--text-base); color: var(--text-muted); line-height: 1.5; }

.toolbar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); flex-wrap: wrap; }
.toolbar .search-wrap { flex: 1; min-width: 200px; max-width: 320px; }
.toolbar .search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--bg-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 12px center;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.toolbar .search-wrap input::placeholder { color: var(--text-placeholder); }
.toolbar .search-wrap input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(5,150,105,0.1); }
.toolbar .filter-pills { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.toolbar .filter-pill {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.toolbar .filter-pill:hover { background: var(--border-light); color: var(--text-primary); }

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

/* Summary cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
@media (max-width: 768px) {
  .summary-cards { grid-template-columns: 1fr; }
}
.summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.summary-card:hover { box-shadow: var(--shadow); border-color: var(--border); }
.summary-card .label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}
.summary-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* Company cards */
.company-cards { display: grid; gap: var(--space-4); }
.company-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-6);
  align-items: center;
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.company-card:hover { box-shadow: var(--shadow); border-color: var(--border); }
@media (max-width: 768px) {
  .company-card { grid-template-columns: 1fr; }
}
.company-card.warning { border-left-color: var(--warning); }
.company-card.healthy { border-left-color: var(--success); }
.company-name {
  font-weight: 600;
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}
.company-meta { font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-3); }
.company-metrics { display: flex; gap: var(--space-6); flex-wrap: wrap; }
.company-metric .m-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.company-metric .m-value { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.company-metric .m-trend { font-size: var(--text-xs); font-weight: 500; }
.company-metric .m-trend.up { color: var(--success); }
.company-metric .m-trend.down { color: var(--error); }
.company-actions { display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-end; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 36px;
}
.btn-primary { background: var(--primary); color: #fff; border-radius: var(--radius-md); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.btn-outline:hover { background: var(--border-light); border-color: var(--text-muted); }

/* Badges */
.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-healthy { background: var(--success-bg); color: #047857; }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-attention { background: var(--error-bg); color: #b91c1c; }

/* Data card & table */
.data-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.data-card h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table th,
.data-table td {
  padding: 12px var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}
.data-table th {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-app);
}
.data-table td { color: var(--text-primary); }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:nth-child(even) { background: #fafafa; }
.data-table tbody tr:hover { background: var(--border-light); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Projection cards */
.projection-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}
@media (max-width: 768px) {
  .projection-cards { grid-template-columns: 1fr; }
}
.projection-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border-top: 4px solid var(--primary);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.projection-card:hover { box-shadow: var(--shadow); border-color: var(--border); }
.projection-card .year {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}
.projection-card .amount {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.projection-card .note { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-2); }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card:hover { box-shadow: var(--shadow); border-color: var(--border); }
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--text-primary);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: var(--space-6);
}
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal h3 { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-4); color: var(--text-primary); }
.modal-close {
  float: right;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-muted);
  line-height: 1;
  padding: var(--space-1);
  margin: calc(-1 * var(--space-1));
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: var(--text-primary); background: var(--border-light); }

.form-group { margin-bottom: var(--space-4); }
.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.form-group input,
.form-group select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}
