:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --ink: #172033;
  --muted: #657084;
  --line: #d9e0ea;
  --blue: #1769aa;
  --blue-2: #e8f2fb;
  --green: #0f8a5f;
  --green-2: #e7f5ef;
  --gold: #9a6b00;
  --gold-2: #fff4d7;
  --red: #b42318;
  --red-2: #fde7e4;
  --shadow: 0 8px 24px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  width: 248px;
  min-width: 248px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 16px;
  background: #152337;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f4c95d;
  color: #152337;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand p {
  margin: 3px 0 0;
  color: #aeb8c6;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: transparent;
  color: #d8e0eb;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #213650;
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.sidebar-footer label {
  color: #aeb8c6;
  font-size: 12px;
}

.sidebar-footer input {
  width: 100%;
  border: 1px solid #314761;
  border-radius: 6px;
  padding: 10px;
  background: #0f1b2a;
  color: #fff;
}

.shell {
  width: calc(100% - 248px);
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.top-actions,
.form-actions,
.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.language-picker {
  min-width: 150px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.language-picker select {
  min-height: 36px;
  font-size: 14px;
  font-weight: 650;
}

.primary,
.secondary {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 12px;
  border: 1px solid transparent;
  font-weight: 650;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary:hover {
  background: var(--panel-2);
}

.danger {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 12px;
  border: 1px solid var(--red);
  font-weight: 650;
  background: #fff;
  color: var(--red);
}

.danger:hover {
  background: var(--red);
  color: #fff;
}

button.small {
  min-height: 28px;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 4px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 86px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.metric strong {
  font-size: 28px;
}

.metric-hint {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-hint.met {
  color: var(--green);
}

.metric-hint.miss {
  color: var(--red);
}

.metric-hint.neutral {
  color: var(--muted);
}

.view {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.view.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-header h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.section-header p {
  margin: 0;
  color: var(--muted);
}

.entry-form {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #38465a;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  font-size: 14px;
}

input[type="datetime-local"],
input[type="date"] {
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  min-width: 180px;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  margin-left: 4px;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* Fix for date input styling on some browsers */
input[type="datetime-local"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit {
  padding: 0;
}

input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.14);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef3f8;
  color: #334258;
  font-size: 12px;
}

tbody tr:hover {
  background: #fbfcfe;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--blue-2);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.major,
.tag.overdue {
  background: var(--red-2);
  color: var(--red);
}

.tag.small {
  background: var(--gold-2);
  color: var(--gold);
}

.tag.unknown {
  background: var(--blue-2);
  color: var(--blue);
}

.tag.done {
  background: var(--green-2);
  color: var(--green);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  min-width: 32px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.followup-list {
  display: grid;
  gap: 10px;
}

.followup-card {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) auto;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.followup-card.overdue {
  border-color: #f3b4ae;
  background: #fff8f7;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.card-title strong {
  font-size: 16px;
}

.muted {
  color: var(--muted);
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(230px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.board-column {
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.board-column header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.board-column h4 {
  margin: 0;
  font-size: 14px;
}

.board-cards {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.board-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.board-card strong {
  display: block;
  margin-bottom: 6px;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.review-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.review-card.wide {
  grid-column: span 2;
}

.review-card.full {
  grid-column: 1 / -1;
}

.review-card h4 {
  margin: 0 0 10px;
}

.stat-list {
  display: grid;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #edf1f6;
  padding-bottom: 7px;
}

.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 180px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

/* ── Login overlay ── */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #152337 0%, #1a3050 100%);
}

.login-card {
  width: 400px;
  max-width: calc(100vw - 48px);
  background: var(--panel);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-brand {
  padding: 0 0 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.login-brand h1 {
  color: var(--ink);
}

.login-brand p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: #38465a;
  font-weight: 650;
}

.login-error {
  margin: 0;
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.login-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ── User info in topbar ── */

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-weight: 650;
  color: var(--ink);
}

.logout-btn {
  font-size: 12px;
  min-height: 28px;
  padding: 4px 10px;
}

/* ── Leader panel ── */

.nav-item-leader {
  border-top: 1px solid #314761;
  margin-top: 6px;
  padding-top: 12px;
}

.leader-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0;
}

.leader-tab {
  border: 0;
  border-radius: 6px 6px 0 0;
  padding: 8px 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}

.leader-tab.active {
  background: var(--blue-2);
  color: var(--blue);
}

.leader-tab:hover:not(.active) {
  color: var(--ink);
}

.leader-tab-content {
  display: none;
}

.leader-tab-content.active {
  display: block;
}

.leader-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.leader-panel-card {
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.leader-panel-card.wide {
  grid-column: span 2;
}

.leader-panel-card h4 {
  margin: 0 0 12px;
  font-size: 15px;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-title-row h4 {
  margin-bottom: 0;
}

.member-score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.member-score-card {
  border: 1px solid #edf1f6;
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.member-score-card.met {
  border-color: #b7dfcd;
  background: #f2fbf6;
}

.member-score-card.miss {
  border-color: #f3b4ae;
  background: #fff8f7;
}

.member-score-card.neutral {
  background: #fbfcfe;
}

.member-score-top,
.member-score-meta,
.visual-stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.member-score-top strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-score-top span {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
}

.member-score-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}

.progress-track,
.pipeline-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.progress-fill,
.pipeline-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.progress-fill.alt {
  background: var(--green);
}

.bar-chart {
  min-height: 170px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.bar-item {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 6px;
}

.bar-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.bar-track {
  width: 100%;
  max-width: 26px;
  height: 124px;
  display: flex;
  align-items: flex-end;
  border-radius: 999px;
  background: #e8edf4;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.bar-label {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.pipeline-list {
  display: grid;
  gap: 12px;
}

.pipeline-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) 2fr auto;
  gap: 10px;
  align-items: center;
}

.pipeline-label {
  min-width: 0;
  color: #334258;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visual-stat-list {
  gap: 12px;
}

.visual-stat-row {
  display: grid;
  gap: 6px;
}

.compact-table table {
  min-width: 720px;
}

/* ── Modal overlay ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(21, 35, 55, 0.65);
}

.modal-card {
  width: 420px;
  max-width: calc(100vw - 48px);
  background: var(--panel);
  border-radius: 12px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-card h3 {
  margin: 0 0 16px;
  font-size: 20px;
}

.modal-card .form-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

@media (max-width: 1100px) {
  body {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    min-height: auto;
  }

  .nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
  }

  .shell {
    width: 100%;
  }

  .form-grid,
  .metric-grid,
  .review-grid,
  .leader-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .leader-panel-card.wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .section-header,
  .followup-card {
    display: grid;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .metric-grid,
  .review-grid,
  .leader-dashboard,
  .member-score-grid {
    grid-template-columns: 1fr;
  }

  .review-card.wide {
    grid-column: auto;
  }
}
