:root {
  --pd-green: #1f8f57;
  --pd-green-dark: #166b40;
  --pd-green-soft: #e6f4eb;
  --bg: #f4f7f5;
  --text: #1a1f1d;
  --muted: #6b7d75;
  --card: #ffffff;
  --border: #d8e1dc;
  --danger: #d43f3f;
  --shadow: 0 14px 28px rgba(22, 39, 30, 0.08);
}

* {
  box-sizing: border-box;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top left, #dff3e7, #f7faf8 70%);
}

.login-card {
  width: min(420px, 92vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.4s ease;
}

.login-card h1 {
  margin: 0 0 8px;
  color: var(--pd-green-dark);
}

.login-card p {
  margin: 0 0 18px;
  color: #4f5d57;
}

label {
  display: block;
  margin: 10px 0 6px;
  font-size: 14px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  background: #fff;
}

button {
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

#loginForm button {
  margin-top: 14px;
  width: 100%;
  background: var(--pd-green);
  color: #fff;
  padding: 11px;
  border-radius: 8px;
  font-weight: 600;
}

#loginForm button:hover {
  background: var(--pd-green-dark);
}

.error {
  color: #bd1e1e;
  min-height: 18px;
  margin-top: 8px;
}

.app {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  font-weight: 800;
  color: var(--pd-green-dark);
}

.brand-subtitle {
  margin: -12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.logout-btn,
.secondary-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  color: #2f3a35;
}

.nav-item.active,
.nav-item:hover {
  background: var(--pd-green-soft);
  color: var(--pd-green-dark);
  font-weight: 600;
  transform: translateX(2px);
}

.logout-btn {
  margin-top: auto;
  border: 1px solid var(--border);
}

.secondary-btn {
  border: 1px solid var(--border);
  background: #fff;
}

.secondary-btn:hover,
.logout-btn:hover {
  background: #f0f5f2;
}

.main-content {
  flex: 1;
  padding: 24px;
  overflow-x: hidden;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.top-header h2 {
  margin: 0;
}

.top-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.global-banner {
  margin-top: 12px;
  padding: 12px;
  background: #fee;
  border: 1px solid #f1c2c2;
  border-radius: 8px;
  color: #8a1f1f;
}

.page {
  display: none;
  animation: fadeUp 0.25s ease;
}

.page.active {
  display: block;
}

.metrics-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 5px 14px rgba(28, 42, 35, 0.06);
}

.metric-card h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.metric-value {
  margin: 8px 0 4px;
  font-size: 24px;
  font-weight: 700;
  color: var(--pd-green-dark);
}

.metric-trend {
  font-size: 12px;
  color: #5a6c64;
}

.metric-trend.up {
  color: #0f8a48;
}

.metric-trend.down {
  color: var(--danger);
}

.dashboard-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 5px 14px rgba(28, 42, 35, 0.05);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 8px;
}

.panel-title {
  font-weight: 700;
}

.panel-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  padding: 0 12px 12px;
}

.pipeline-column {
  background: #f7fbf9;
  border: 1px solid #e5efea;
  border-radius: 10px;
  min-height: 120px;
  padding: 8px;
}

.column-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #446357;
  margin-bottom: 8px;
}

.deal-chip {
  background: #fff;
  border: 1px solid #e4ede8;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}

.deal-chip:hover {
  border-color: #b8d7c8;
  transform: translateY(-1px);
}

.deal-chip-title {
  font-size: 13px;
  font-weight: 600;
}

.deal-chip-meta {
  font-size: 12px;
  color: var(--muted);
}

.chart-grid {
  padding: 0 12px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.chart-card {
  border: 1px solid #e8efeb;
  border-radius: 10px;
  padding: 10px;
  background: #fcfdfc;
}

.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 80px;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
  font-size: 12px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e8efeb;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2ea867, #1f8f57);
  border-radius: 999px;
}

.timeline {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 120px;
  margin-top: 6px;
}

.timeline-col {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.timeline-bar {
  width: 100%;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, #5ac788, #1f8f57);
}

.timeline-label {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.donut {
  --percent: 0;
  width: 120px;
  height: 120px;
  margin: 10px auto;
  border-radius: 999px;
  background: conic-gradient(#1f8f57 calc(var(--percent) * 1%), #e8efeb 0);
  position: relative;
}

.donut::after {
  content: attr(data-label);
  position: absolute;
  inset: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #27473a;
  font-weight: 700;
}

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0 14px 14px;
  display: grid;
  gap: 8px;
}

.feed-item {
  border: 1px solid #e8efeb;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
}

.feed-item:hover {
  border-color: #c5ddd1;
}

.feed-title {
  font-size: 13px;
  font-weight: 600;
}

.feed-meta {
  font-size: 12px;
  color: var(--muted);
}

.table-shell {
  margin-top: 14px;
}

.table-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.table-toolbar input,
.table-toolbar select {
  width: auto;
  min-width: 180px;
}

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #edf1ee;
  text-align: left;
  font-size: 14px;
}

th {
  background: #f0f7f3;
  color: #355045;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr.data-row {
  transition: background 0.2s ease;
  cursor: pointer;
}

tr.data-row:hover {
  background: #f4faf7;
}

.loading,
.empty {
  padding: 14px;
  color: #5b6e66;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(18, 28, 22, 0.42);
  animation: fadeIn 0.2s ease;
}

.modal-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(560px, 100%);
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 34px rgba(17, 26, 20, 0.18);
  padding: 20px;
  overflow-y: auto;
  animation: slideIn 0.24s ease;
}

.close-modal {
  position: absolute;
  right: 12px;
  top: 10px;
  border: 1px solid var(--border);
  background: #fff;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-size: 20px;
  line-height: 1;
}

.detail-title {
  margin: 0 0 10px;
  padding-right: 30px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}

.detail-item {
  padding: 8px;
  border: 1px solid #e8efeb;
  border-radius: 8px;
}

.detail-key {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.detail-value {
  margin-top: 3px;
  font-size: 13px;
  word-break: break-word;
}

.notes-section {
  margin-top: 14px;
}

.note-item {
  border-left: 3px solid #9acdb0;
  background: #f7fbf9;
  padding: 8px 10px;
  margin: 6px 0;
  border-radius: 6px;
}

.note-date {
  font-size: 11px;
  color: var(--muted);
}

@keyframes slideIn {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeUp {
  from { transform: translateY(5px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 1080px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .sidebar {
    width: 80px;
    padding: 12px 8px;
  }

  .brand,
  .brand-subtitle,
  .logout-btn,
  .nav-item {
    font-size: 0;
  }

  .nav-item::before {
    font-size: 12px;
  }

  .nav-item[data-page='dashboard']::before { content: 'DB'; }
  .nav-item[data-page='deals']::before { content: 'DE'; }
  .nav-item[data-page='contacts']::before { content: 'CT'; }
  .nav-item[data-page='organizations']::before { content: 'OR'; }
  .nav-item[data-page='activities']::before { content: 'AC'; }
  .nav-item[data-page='pipelines']::before { content: 'PL'; }

  .main-content {
    padding: 14px;
  }

  .table-toolbar input,
  .table-toolbar select {
    min-width: 100%;
  }
}

@media (max-width: 620px) {
  .top-header {
    flex-direction: column;
  }

  .modal-panel {
    width: 100%;
  }
}
