:root {
  --bg: #f6f7f2;
  --panel: #ffffff;
  --text: #19201d;
  --muted: #68716c;
  --line: #dfe4dc;
  --green: #1f7a4d;
  --green-dark: #155a39;
  --amber: #d78b12;
  --blue: #2f68b3;
  --red: #c9473d;
  --teal: #18817c;
  --shadow: 0 14px 35px rgba(33, 45, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.logged-out .app-shell {
  display: none;
}

body.logged-in .login-screen {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f6f7f2 0%, #e7eee6 100%);
}

.login-card {
  width: min(430px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
  display: grid;
  gap: 16px;
}

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

.login-card h1 {
  font-size: 28px;
}

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

.login-options {
  display: grid;
  gap: 8px;
}

.login-options label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.login-options input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.login-hint {
  color: var(--muted);
  font-size: 13px;
  margin: -4px 0 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #101814;
  color: white;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

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

.brand span,
.team-box span,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .brand span,
.sidebar .team-box span {
  color: #aebbb4;
}

.main-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  color: #d9e4dd;
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #223329;
  color: white;
}

.team-box {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.team-person {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #d9e4dd;
  margin: 8px 0;
}

.team-person span:nth-child(2) {
  flex: 1;
}

.team-person small,
.team-summary {
  color: #aebbb4;
  font-size: 12px;
}

.member-credentials {
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.mode-select {
  color: #d9e4dd;
  margin-bottom: 8px;
}

.mode-select select {
  width: 100%;
  margin-top: 7px;
  background: #223329;
  border-color: #3b5546;
  color: white;
}

.top-mode {
  min-width: 190px;
  color: #39443e;
}

.top-mode select {
  background: white;
  border-color: var(--line);
  color: var(--text);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 10px;
}

.content {
  min-width: 0;
  padding: 26px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: white;
  color: var(--text);
  min-width: 0;
}

textarea {
  resize: vertical;
}

#globalSearch {
  width: min(360px, 42vw);
}

.button,
.icon-button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.button.primary {
  background: var(--green);
  color: white;
}

.button.primary:hover {
  background: var(--green-dark);
}

.button.secondary {
  background: #e9eee8;
  color: #27342d;
}

.button.danger {
  background: #f4dedb;
  color: #9c2d25;
  margin-right: auto;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  background: #eef2ec;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 14px;
}

.pipeline-column {
  background: #edf1eb;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 600px;
  padding: 12px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.pipeline-column.drag-over {
  background: #e4f1e9;
  border-color: var(--green);
}

.column-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.column-head h3 {
  font-size: 15px;
  margin: 0;
}

.count-badge,
.score-badge,
.phase-pill,
.status-pill {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  background: white;
}

.deal-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(25, 32, 29, 0.06);
  margin-bottom: 10px;
  cursor: pointer;
}

.deal-card[draggable="true"] {
  cursor: grab;
}

.deal-card.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.deal-card:hover {
  border-color: #a8b8ae;
}

.deal-card h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.card-meta {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.card-row,
.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.value {
  font-weight: 800;
  color: var(--text);
}

.score-badge {
  background: #fff1cb;
  color: #815200;
}

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

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

th,
td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-size: 14px;
}

th {
  background: #edf1eb;
  position: sticky;
  top: 0;
  z-index: 1;
}

th.sortable {
  cursor: pointer;
}

tr:hover td {
  background: #fbfcfa;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 10px;
}

.day-cell {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-height: 178px;
}

.day-name {
  font-weight: 800;
  margin-bottom: 8px;
}

.calendar-event {
  border-left: 4px solid var(--green);
  background: #f7faf6;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  cursor: pointer;
}

.due {
  outline: 2px solid var(--amber);
  background: #fff8e8;
}

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

.activity-item {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 5px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.admin-dashboard {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 0.8fr);
  gap: 14px;
  margin-bottom: 18px;
}

.chart-panel,
.overdue-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.chart-row {
  display: grid;
  grid-template-columns: 160px minmax(120px, 1fr) 86px;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  font-size: 13px;
}

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

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--green);
}

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

.overdue-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  padding: 10px;
  background: #fffafa;
  cursor: pointer;
}

.notification-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.notification-strip div {
  background: white;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  padding: 12px;
}

.notification-strip strong {
  display: block;
  font-size: 24px;
}

.notification-strip span {
  color: var(--muted);
  font-size: 13px;
}

.admin-pool,
.team-management {
  margin-bottom: 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.admin-pool h2,
.team-management h2 {
  margin: 2px 0 12px;
}

.pool-list,
.member-grid {
  display: grid;
  gap: 10px;
}

.pool-item,
.member-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, auto) minmax(190px, auto);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.pool-item {
  cursor: pointer;
}

.member-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.phase-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.phase-item {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.member-card {
  grid-template-columns: 1fr;
}

.member-head {
  display: flex;
  gap: 8px;
  align-items: center;
}

.team-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) 180px 160px auto;
  gap: 10px;
  margin-bottom: 14px;
}

.compact-form {
  grid-template-columns: minmax(240px, 1fr) auto;
}

.compact-list {
  max-height: 260px;
  overflow: auto;
}

.metric {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.modal {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.wide-modal {
  width: min(1100px, calc(100vw - 32px));
}

.preview-modal {
  width: min(1100px, calc(100vw - 32px));
}

.modal::backdrop {
  background: rgba(10, 15, 12, 0.48);
}

.modal form {
  padding: 22px;
}

.preview-shell {
  padding: 22px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin: 0;
}

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

label {
  display: grid;
  gap: 7px;
  color: #39443e;
  font-weight: 700;
  font-size: 13px;
}

.wide {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.attachment-panel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
}

.attachment-panel h3 {
  margin: 2px 0 12px;
  font-size: 18px;
}

.quick-calendar-grid {
  display: grid;
  grid-template-columns: 170px 160px minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.attachment-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-bottom: 12px;
}

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

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

.protocol-item {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.protocol-item .mini-row {
  align-items: flex-start;
}

.tech-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.tech-image-slot {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 9px;
}

.tech-image-preview {
  aspect-ratio: 4 / 3;
  border: 1px dashed #b8c4bb;
  border-radius: 8px;
  background: #f8faf7;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.tech-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tech-image-slot .attachment-actions {
  gap: 6px;
}

.tech-image-slot .button {
  padding: 8px 10px;
  font-size: 13px;
}

.attachment-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.attachment-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.preview-content {
  min-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8faf7;
  display: grid;
  grid-template-rows: auto 1fr;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: white;
}

.preview-toolbar span {
  color: var(--muted);
  font-weight: 700;
}

.preview-content img,
.preview-content iframe,
.preview-content object,
.pdf-preview {
  width: 100%;
  height: 68vh;
  border: 0;
}

.preview-content img {
  object-fit: contain;
  padding: 12px;
}

.preview-fallback {
  padding: 24px;
  text-align: center;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #b8c4bb;
  border-radius: 8px;
  color: var(--muted);
  background: #f8faf7;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .main-nav {
    display: flex;
  }

  .team-box {
    display: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  #globalSearch {
    width: min(100%, 520px);
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .pool-item,
  .team-form,
  .compact-form,
  .phase-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 15px;
  }

  .content {
    padding: 14px;
  }

  .login-screen {
    padding: 12px;
    align-items: start;
  }

  .login-card {
    margin-top: 18px;
    padding: 18px;
  }

  .login-card h1,
  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  .sidebar {
    padding: 12px;
    gap: 12px;
    align-items: flex-start;
  }

  .brand {
    min-width: 150px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .main-nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    flex: 0 0 auto;
    padding: 10px 12px;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
  }

  .form-grid,
  .dashboard-grid,
  .admin-dashboard,
  .quick-calendar-grid,
  .notification-strip,
  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }

  .topbar-actions > * {
    width: 100%;
  }

  #globalSearch {
    width: 100%;
  }

  .pipeline-board {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    padding-bottom: 12px;
  }

  .pipeline-column {
    min-width: min(86vw, 340px);
    max-height: none;
    scroll-snap-align: start;
    min-height: 380px;
  }

  .deal-card {
    padding: 11px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar > * {
    width: 100%;
  }

  .table-wrap {
    border-radius: 8px;
    max-width: calc(100vw - 28px);
  }

  th,
  td {
    padding: 10px;
    font-size: 13px;
  }

  .day-cell {
    min-height: auto;
  }

  .calendar-event {
    font-size: 13px;
  }

  .chart-row {
    grid-template-columns: 1fr;
    gap: 6px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
  }

  .member-grid {
    grid-template-columns: 1fr;
  }

  .modal,
  .wide-modal,
  .preview-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal form,
  .preview-shell {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
  }

  .modal-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: white;
    padding-bottom: 10px;
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
    background: white;
    padding-top: 10px;
    flex-direction: column;
  }

  .modal-actions .button,
  .modal-actions button {
    width: 100%;
  }

  .button.danger {
    margin-right: 0;
  }

  .attachment-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .attachment-actions .button {
    width: 100%;
  }

  .attachment-item {
    grid-template-columns: 1fr;
  }

  .tech-image-grid {
    grid-template-columns: 1fr;
  }

  .tech-image-preview {
    aspect-ratio: 16 / 10;
  }

  .preview-content {
    min-height: 72vh;
  }

  .preview-content img,
  .preview-content iframe,
  .preview-content object,
  .pdf-preview {
    height: 70vh;
  }
}

@media (max-width: 420px) {
  .content {
    padding: 10px;
  }

  .topbar-actions .button,
  input,
  select,
  textarea {
    font-size: 14px;
  }

  .pipeline-column {
    min-width: 88vw;
  }

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