:root {
  --bg: #0f1720;
  --panel: #17212c;
  --panel-2: #1e2a37;
  --border: #2a3949;
  --text: #e6edf3;
  --muted: #8b9bab;
  --accent: #4fb3ff;
  --accent-2: #6ee7b7;
  --warn: #f5a97f;
  --danger: #f38ba8;
  --radius: 10px;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-box h1 { font-size: 16px; margin: 0 0 6px; }
.login-box input { width: 100%; }
.login-box button { margin-top: 4px; }

#app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
#app-shell > main {
  min-width: 0; /* without this, a grid item's content can force the track (and the whole
                   page) wider than the viewport instead of wrapping/scrolling internally */
}

nav.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

nav.sidebar h1 {
  font-size: 15px;
  color: var(--text);
  margin: 0 0 18px 4px;
  line-height: 1.3;
}
nav.sidebar h1 span { color: var(--accent); display:block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

nav.sidebar a {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
nav.sidebar a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
nav.sidebar a.active { background: var(--panel-2); color: var(--accent); }

main {
  padding: 28px 36px;
  max-width: 1200px;
  width: 100%;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: inherit;
  text-decoration: none;
  transition: border-color .12s, background .12s;
}
.stat-card:hover {
  border-color: var(--accent);
  background: var(--panel-2);
  text-decoration: none;
}
.stat-card .n { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-card .l { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

h2 { font-size: 19px; margin: 28px 0 12px; }
h3 { font-size: 15px; color: var(--muted); margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .04em; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  overflow-x: auto; /* wide tables scroll within their own panel, never the page */
}

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
input, select, textarea, button {
  font-family: inherit;
  font-size: 13.5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }
textarea { width: 100%; resize: vertical; }
button {
  cursor: pointer;
  background: var(--accent);
  color: #0b1620;
  font-weight: 600;
  border: none;
}
button:hover { filter: brightness(1.08); }
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--panel-2); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.badge.high { color: var(--accent-2); border-color: var(--accent-2); }
.badge.medium { color: var(--warn); border-color: var(--warn); }
.badge.current { color: var(--accent-2); }
.badge.ceased { color: var(--muted); }
.badge.reviewed { color: var(--accent); border-color: var(--accent); }
.badge.rejected { color: var(--danger); border-color: var(--danger); }
.badge.target { color: #f4c95d; border-color: #f4c95d; background: rgba(244, 201, 93, 0.08); font-weight: 700; }

.sf-up { color: var(--accent-2); font-weight: 600; }
.sf-down { color: var(--danger); font-weight: 600; }

.company-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; }
.company-header h2 { margin: 0; }
.meta-row { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 8px; }
.meta-row b { color: var(--text); }

.note-item, .news-item { border-bottom: 1px solid var(--border); padding: 10px 0; }
.note-item:last-child, .news-item:last-child { border-bottom: none; }
.note-item .date, .news-item .date { color: var(--muted); font-size: 12px; }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

.ask-box { display: flex; gap: 10px; }
.ask-box textarea { flex: 1; min-height: 60px; }
.answer { white-space: pre-wrap; line-height: 1.55; font-size: 14px; }
.answer h1, .answer h2, .answer h3 { font-size: 15px; margin: 14px 0 6px; }

.loading { color: var(--muted); font-style: italic; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.small { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }
