:root {
  --navy: #1a2638;
  --navy-light: #5e6774;
  --navy-darker: #0d131d;
  --light-grey: #f2f2f2;
  --white: #ffffff;
  --teal: #36c799;
  --teal-dark: #25b285;
  --red: #ff4f57;
  --border: #e5e7eb;
  --warning: #fff8e6;
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 12px 30px rgba(26, 38, 56, 0.12);
}

.tf-logo {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}

.tf-logo-header {
  margin: 0;
}

.tf-logo-image {
  display: block;
  width: 221px;
  max-width: 100%;
  height: auto;
}

.tf-logo-image-header {
  width: 258px;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 600;
  color: var(--navy);
}

p {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--navy-light);
  line-height: 1.5;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  margin-bottom: 16px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(54, 199, 153, 0.18);
}

button {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  background: var(--teal);
  color: var(--white);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--teal-dark);
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#loginButton {
  width: 100%;
}

.error {
  margin-top: 14px;
  color: var(--red);
  font-size: 13px;
}

.portal-header {
  background: var(--navy);
  color: var(--white);
  padding: 24px 32px;
}

.portal-header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
}

.portal-header h1 {
  color: var(--white);
  font-size: 24px;
}

.portal-header p {
  color: rgba(255, 255, 255, 0.75);
  margin: 4px 0 0;
}

.portal-content {
  padding: 32px;
}

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

.portal-title {
  margin: 0 0 4px;
  font-size: 22px;
}

.last-updated {
  margin: 0;
  font-size: 13px;
  color: var(--navy-light);
}

.portal-message,
.project-picker {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}

#refreshButton {
  width: auto;
  min-width: 110px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.tab,
.project-button {
  width: auto;
  padding: 10px 18px;
  background: var(--white);
  color: var(--navy);
  border: 1px solid var(--border);
}

.tab.active,
.project-button.active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}

.project-picker-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
}

.project-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.section-card {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 8px 20px rgba(26, 38, 56, 0.08);
}

.section-card h2 {
  margin: 0 0 16px;
  font-size: 20px;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #000000;
  border-radius: 12px;
}

.referral-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.referral-table th {
  background: var(--navy);
  color: var(--white);
  padding: 14px 12px;
  text-align: left;
  vertical-align: bottom;
  white-space: normal;
  min-width: 150px;
  height: 72px;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 2;
  border: 1px solid #000000;
}

.referral-table td {
  padding: 12px;
  height: 44px;
  min-width: 150px;
  background: var(--white);
  color: var(--navy);
  border: 1px solid #000000;
}

.empty-table {
  text-align: center;
  color: var(--navy-light);
  padding: 28px;
}

.readonly-cell {
  display: block;
  min-height: 20px;
}

.readonly-reason {
  display: block;
  margin-top: 4px;
  color: var(--navy-light);
  font-size: 11px;
}

.editable-cell {
  width: 100%;
  min-width: 140px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  color: var(--navy);
  background: var(--white);
}

.editable-textarea {
  min-height: 38px;
  resize: vertical;
}

.editable-cell.cell-changed {
  border-color: var(--teal);
  background: #f4fffb;
}

.editable-cell.cell-saving {
  opacity: 0.7;
  background: var(--light-grey);
}

.editable-cell.cell-saved {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(54, 199, 153, 0.18);
}

.editable-cell.cell-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 79, 87, 0.14);
}

.conflict-note {
  background: var(--warning);
  border-color: #f5d276;
}

@media (max-width: 720px) {
  .portal-header,
  .portal-content {
    padding: 20px;
  }

  .portal-toolbar,
  .portal-header-inner {
    align-items: stretch;
    flex-direction: column;
  }
}
