:root {
  --navy:      #2A3D66;
  --navy-dark: #1e2e50;
  --navy-mid:  #3d5280;
  --steel:     #AEC6CF;
  --steel-lt:  #d4e5ea;
  --steel-dim: #8aadb8;
  --bg:        #f5f6f8;
  --bg2:       #eef0f4;
  --white:     #ffffff;
  --text:      #2A3D66;
  --text2:     #5a6a85;
  --text3:     #9aa5b8;
  --border:    rgba(42,61,102,0.09);
  --border2:   rgba(42,61,102,0.16);
  --pro:       #22c55e;
  --neu:       #9aa5b8;
  --opp:       #ef4444;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 14px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── App layout ──────────────────────────────────────────────────────────── */

.app-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 52px 1fr;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */

.topbar {
  grid-column: 1 / -1;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.logo-wrap { display: flex; align-items: center; gap: 12px; }

.logo-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--navy);
  letter-spacing: -0.3px;
}
.logo-name > span { color: var(--steel-dim); font-weight: 300; }
.logo-product { color: var(--text3) !important; font-size: 13px; font-weight: 300 !important; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.role-badge {
  font-size: 11px; padding: 3px 10px; border-radius: 20px;
  font-weight: 500; border: 1px solid;
}
.role-badge.admin  { background: rgba(42,61,102,0.08); color: var(--navy); border-color: var(--border2); }
.role-badge.client { background: rgba(174,198,207,0.2); color: var(--steel-dim); border-color: rgba(174,198,207,0.4); }

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

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy); display: flex;
  align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500; color: white;
}

.logout-btn {
  font-size: 12px; color: var(--text3); text-decoration: none;
  padding: 4px 8px; border-radius: 6px; transition: all .15s;
}
.logout-btn:hover { color: var(--navy); background: var(--bg); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
}

.nav-section {
  font-size: 9px; font-weight: 500; color: var(--text3);
  text-transform: uppercase; letter-spacing: .1em;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  font-size: 13px; color: var(--text2);
  text-decoration: none; border: 1px solid transparent;
  transition: all .15s;
}
.nav-item:hover { background: var(--bg); color: var(--navy); }
.nav-item.active {
  background: rgba(42,61,102,0.07); color: var(--navy);
  font-weight: 500; border-color: var(--border);
}
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }

.sidebar-footer {
  margin-top: auto; padding: 12px 10px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text3); line-height: 1.6;
}

/* ── Main content ────────────────────────────────────────────────────────── */

.main-content {
  padding: 28px 32px;
  overflow-y: auto;
}

/* ── Flash messages ──────────────────────────────────────────────────────── */

.flash-wrap { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; border: 1px solid;
}
.flash-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text3); margin-bottom: 20px;
}
.breadcrumb a { color: var(--text3); text-decoration: none; transition: color .15s; }
.breadcrumb a:hover { color: var(--navy); }
.breadcrumb-sep { color: var(--border2); }
.breadcrumb-current { color: var(--text2); }

/* ── Page header ─────────────────────────────────────────────────────────── */

.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 24px;
}
.page-title { font-size: 20px; font-weight: 500; color: var(--navy); letter-spacing: -0.3px; }
.page-sub { font-size: 13px; color: var(--text2); margin-top: 3px; font-weight: 300; }
.header-actions { display: flex; gap: 8px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; background: var(--navy); color: white;
  border: none; border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif; font-size: 13px;
  font-weight: 500; cursor: pointer; transition: background .15s;
  text-decoration: none;
}
.btn-primary:hover { background: var(--navy-dark); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; background: var(--white); color: var(--text2);
  border: 1px solid var(--border2); border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif; font-size: 13px;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.btn-secondary:hover { background: var(--bg); color: var(--navy); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; background: transparent; color: #991b1b;
  border: 1px solid rgba(239,68,68,0.25); border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif; font-size: 13px;
  cursor: pointer; transition: all .15s;
}
.btn-danger:hover { background: rgba(239,68,68,0.05); }

/* ── Cards & Panels ──────────────────────────────────────────────────────── */

.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 13px; font-weight: 500; color: var(--navy); }
.card-body { padding: 20px; }

/* ── Metrics grid ────────────────────────────────────────────────────────── */

.metrics {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 24px;
}
.metric-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.metric-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 500; color: var(--navy); letter-spacing: -0.5px; }
.metric-sub   { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 3px 8px; border-radius: 5px; font-weight: 500;
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; }

.badge-pro { background: rgba(34,197,94,.1);  color: #166534; }
.badge-pro .badge-dot { background: #22c55e; }
.badge-neu { background: rgba(154,165,184,.12); color: var(--text2); }
.badge-neu .badge-dot { background: var(--text3); }
.badge-opp { background: rgba(239,68,68,.1);  color: #991b1b; }
.badge-opp .badge-dot { background: #ef4444; }
.badge-cat { background: rgba(42,61,102,0.07); color: var(--navy); }
.badge-q   { background: var(--bg); color: var(--text2); border: 1px solid var(--border); }

/* ── Category badges ─────────────────────────────────────────────────────── */
.cat-inst { background: rgba(42,61,102,0.08); color: var(--navy); }
.cat-pol  { background: rgba(139,92,246,.1);  color: #5b21b6; }
.cat-med  { background: rgba(174,198,207,.25); color: var(--steel-dim); }
.cat-wirt { background: rgba(245,158,11,.1);  color: #92400e; }
.cat-ziv  { background: rgba(154,165,184,.15); color: var(--text2); }

/* ── Form fields ─────────────────────────────────────────────────────────── */

.field { margin-bottom: 16px; }
.field-label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text2); margin-bottom: 6px;
}
.field-hint { font-size: 11px; color: var(--text3); margin-bottom: 6px; display: block; }

.field-input, .field-select, textarea.field-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border2); border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif; font-size: 13px;
  color: var(--navy); background: var(--white); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field-input:focus, .field-select:focus, textarea.field-input:focus {
  border-color: var(--steel);
  box-shadow: 0 0 0 3px rgba(174,198,207,0.2);
}
.field-input::placeholder { color: var(--text3); font-weight: 300; }
textarea.field-input { resize: vertical; min-height: 80px; line-height: 1.6; }

.field-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239aa5b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }

/* ── Table ───────────────────────────────────────────────────────────────── */

.table-wrap {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-xl); overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg); }
th {
  text-align: left; padding: 11px 16px;
  font-size: 10px; font-weight: 500; color: var(--text3);
  text-transform: uppercase; letter-spacing: .07em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td {
  padding: 13px 16px; font-size: 13px;
  color: var(--text2); border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; transition: background .12s; }
tr.clickable:hover td { background: rgba(42,61,102,0.02); }

/* ── Influence dots ──────────────────────────────────────────────────────── */

.inf-dots { display: flex; gap: 2px; }
.inf-dot { width: 6px; height: 6px; border-radius: 50%; }
.inf-on  { background: var(--navy); }
.inf-off { background: var(--border2); border: 1px solid var(--border); }

/* ── Login page ──────────────────────────────────────────────────────────── */

body.login-page {
  display: flex; flex-direction: column;
  min-height: 100vh; background: var(--bg);
}

.login-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 420px;
  padding: 40px; animation: cardIn .4s cubic-bezier(0.16,1,0.3,1) both;
}

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

.role-switcher {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px;
  padding: 5px; background: var(--bg); border-radius: 10px;
  margin-bottom: 20px; border: 1px solid var(--border);
}
.role-btn {
  padding: 8px 12px; border-radius: 7px; border: none;
  background: transparent; font-family: 'DM Sans', sans-serif;
  font-size: 13px; color: var(--text2); cursor: pointer; transition: all .2s;
}
.role-btn.active {
  background: var(--white); color: var(--navy); font-weight: 500;
  box-shadow: 0 1px 3px rgba(42,61,102,0.08), 0 0 0 1px var(--border);
}

.pos-selector { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.pos-option {
  padding: 10px 8px; border-radius: var(--radius); border: 1px solid var(--border2);
  cursor: pointer; text-align: center; transition: all .15s; background: var(--white);
}
.pos-option.selected-pro { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.4); }
.pos-option.selected-neu { background: rgba(154,165,184,.1); border-color: rgba(154,165,184,.4); }
.pos-option.selected-opp { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.4); }
.pos-dot { width: 8px; height: 8px; border-radius: 50%; margin: 0 auto 5px; }
.pos-label { font-size: 11px; font-weight: 500; color: var(--text2); }

/* ── Admin only badge ────────────────────────────────────────────────────── */

.admin-only-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  background: rgba(42,61,102,0.08); color: var(--navy);
  border: 1px solid var(--border2); font-weight: 500;
}

/* ── Mandate pill (sidebar) ──────────────────────────────────────────────── */

.mandate-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 7px; font-size: 12px;
  color: var(--text2); cursor: pointer; transition: all .15s;
}
.mandate-pill:hover { background: var(--bg); color: var(--navy); }
.mandate-pill.active { color: var(--navy); font-weight: 500; background: var(--bg); }
.mandate-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ── Slider ──────────────────────────────────────────────────────────────── */

.slider-wrap { display: flex; align-items: center; gap: 12px; }
.slider-wrap input[type=range] {
  flex: 1; -webkit-appearance: none; height: 4px;
  background: var(--bg); border-radius: 2px; border: 1px solid var(--border2); outline: none;
}
.slider-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--navy); cursor: pointer; border: 2px solid white;
  box-shadow: 0 1px 4px rgba(42,61,102,0.3);
}
.slider-val { font-size: 12px; font-weight: 500; color: var(--navy); min-width: 72px; text-align: right; }

/* ── Timeline ────────────────────────────────────────────────────────────── */

.timeline-item {
  display: flex; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--steel); margin-top: 4px; flex-shrink: 0; }
.tl-text { font-size: 12px; color: var(--text2); line-height: 1.5; flex: 1; }
.tl-date { font-size: 11px; color: var(--text3); white-space: nowrap; }

/* ── Form actions bar ────────────────────────────────────────────────────── */

.form-actions {
  display: flex; gap: 8px; align-items: center;
  padding: 16px 20px; border-top: 1px solid var(--border);
  background: var(--bg);
}
.save-hint { font-size: 11px; color: var(--text3); margin-left: auto; }

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--navy); color: white; padding: 10px 20px;
  border-radius: 20px; font-size: 13px; font-weight: 500;
  z-index: 100; transition: transform .3s cubic-bezier(0.16,1,0.3,1);
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 20px rgba(42,61,102,0.3);
}
.toast.visible { transform: translateX(-50%) translateY(0); }
