/* ── Brand Tokens ── */
:root {
  --color-brand:       #005a96;
  --color-brand-dark:  #004070;
  --color-brand-light: #e8f2fa;
  --color-text:        #1a1a1a;
  --color-muted:       #6b7280;
  --color-border:      #d1d5db; 
  --color-error:       #d04a3b;
  --color-error-bg:    #fdf2f2;
  --header-height:     60px;
  --radius:            6px;
  --shadow-sm:         0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md:         0 4px 12px rgba(0, 0, 0, 0.12);
  --page-max-width:    1200px;
  --page-gutter:       1.5rem;
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--color-text);
  background: #f9fafb;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Shared page column ── */
.page-wrapper {
  max-width: var(--page-max-width);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--page-gutter);
  padding-right: var(--page-gutter);
}

/* ── Header ── */
.site-header {
  height: var(--header-height);
  background: var(--color-brand);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.header-left {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  height: 100%;
}


.site-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
  white-space: nowrap;
  padding-bottom: 0.55rem;
  cursor: default;
  user-select: none;
}

.logo-img {
  height: var(--header-height);
  width: auto;
  display: block;
  object-fit: cover;
}

/* ── Header Nav ── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 1.5rem;
}

.nav-link {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.2);
  color: #f97316;
  font-weight: 600;
}

/* ── Profile Dropdown ── */
.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.profile-dropdown {
  position: relative;
}

.profile-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
}

.avatar-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  transition: background 0.15s;
}

.avatar-photo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.65);
  display: block;
}

.profile-btn:hover .avatar-placeholder,
.profile-btn:focus .avatar-placeholder {
  background: rgba(255, 255, 255, 0.3);
}

.profile-btn:focus {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
  border-radius: 50%;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 170px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 200;
}

.dropdown-menu.open {
  display: block;
}

.dropdown-username {
  display: block;
  padding: 0.6rem 1rem 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-email {
  display: block;
  padding: 0 1rem 0.6rem;
  font-size: 0.78rem;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-text);
  transition: background 0.12s;
}

.logout-btn:hover {
  background: var(--color-brand-light);
  color: var(--color-brand);
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  padding-top: 0;
  padding-bottom: 2rem;
}

.main-content > .page-wrapper {
  padding-top: 0;
  padding-bottom: 0;
}

/* ── Auth Form ── */
.auth-container {
  max-width: 400px;
  margin: 4rem auto;
  background: #fff;
  padding: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.auth-container h1 {
  margin-bottom: 1.5rem;
  color: var(--color-brand);
  font-size: 1.6rem;
}

.auth-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  margin-top: 1.1rem;
  color: var(--color-text);
}

.auth-form label:first-of-type {
  margin-top: 0;
}

.auth-form input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(0, 90, 150, 0.15);
}

/* ── Auth divider ── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ── Microsoft button ── */
.btn-microsoft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 1rem;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.btn-microsoft:hover {
  background: #f3f3f3;
  border-color: #aaa;
}

.ms-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn-primary {
  display: inline-block;
  width: 100%;
  padding: 0.7rem 1rem;
  margin-top: 1.5rem;
  background: var(--color-brand);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s;
  line-height: 1.5;
}

.btn-primary:hover {
  background: var(--color-brand-dark);
}

.btn-center {
  width: auto;
  padding: 0.7rem 1.75rem;
}

/* ── Alerts ── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid var(--color-error);
}

/* ── Page containers ── */
.page-container {
  padding-top: 2rem;
}

.page-container--tabs {
  padding-top: 0;
}

.page-container--tabs .admin-tabs {
  margin-top: 0;
}

.page-container h1 {
  font-size: 2rem;
  color: var(--color-brand);
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--color-muted);
  font-size: 1rem;
}

/* ── Dashboard / Welcome ── */
.dashboard-container {
  padding-top: 2rem;
}

.dashboard-container h1 {
  font-size: 2rem;
  color: var(--color-brand);
  margin-bottom: 0.5rem;
}

.username-highlight {
  color: var(--color-brand-dark);
}

.welcome-subtitle {
  color: var(--color-muted);
  font-size: 1rem;
}

/* ── Error Page ── */
.error-container {
  text-align: center;
  padding: 5rem 1rem;
}

.error-code {
  font-size: 5rem;
  font-weight: 800;
  color: var(--color-brand);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.error-message {
  color: var(--color-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

/* ── Admin Tabs ── */
.detail-card--tabs {
  padding-left: 0;
  padding-right: 0;
  padding-top: 0;
}

.detail-card--tabs .tab-panel,
.detail-card--tabs .admin-tabs { padding-left: 1.5rem; padding-right: 1.5rem; }

.admin-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin: 0;
}

.tab-btn {
  padding: 0.6rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover  { color: var(--color-brand); }

.tab-btn.active {
  color: var(--color-brand);
  border-bottom-color: #e30b17;
  font-weight: 600;
}

.tab-panel        { display: none; padding: 1.5rem 0; }
.tab-panel.active { display: block; }

.tab-panel-title {
  font-size: 1.1rem;
  color: var(--color-brand);
  margin-bottom: 0.4rem;
}

/* ── Admin Card ── */
.admin-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  max-width: 720px;
}

.admin-card h2 {
  font-size: 1.2rem;
  color: var(--color-brand);
  margin-bottom: 0.4rem;
}

.panel-desc {
  font-size: 0.88rem;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.panel-desc code {
  background: #f3f4f6;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.84rem;
  color: var(--color-text);
}

/* ── File input ── */
.file-input-wrap {
  margin-bottom: 1.25rem;
}

.file-input-wrap input[type="file"] {
  display: block;
  font-size: 0.9rem;
  padding: 0.4rem 0;
}

/* ── Export radio + date ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1.5rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.date-input {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--color-text);
  transition: border-color 0.15s;
}

.date-input:focus {
  outline: none;
  border-color: var(--color-brand);
}

.date-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Email summary (compact single cell) ── */
.email-summary {
  display: inline-block;
  background: var(--color-brand-light);
  border: 1px solid #b8d5eb;
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
  color: var(--color-text);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.email-summary--warn {
  background: #fffbeb;
  border-color: #fcd34d;
}

.email-summary--stale {
  background: #fef2f2;
  border-color: #fca5a5;
  color: var(--color-error);
}

.email-summary-cooldown {
  color: #92400e;
}

/* ── Email preview ── */
.email-preview-box {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.preview-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  background: #f9fafb;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

/* ── Ghost button ── */
.btn-ghost {
  display: inline-block;
  padding: 0.45rem 1rem;
  background: none;
  color: var(--color-brand);
  border: 1px solid var(--color-brand);
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 1rem;
}

.btn-ghost:hover {
  background: var(--color-brand-light);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-muted);
  cursor: pointer;
  padding: 0 0.2rem;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.email-preview-frame {
  width: 100%;
  height: 520px;
  border: none;
  display: block;
}

/* ── Result messages ── */
.result-box {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.result-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.result-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid var(--color-error);
}

.result-info {
  background: var(--color-brand-light);
  color: var(--color-brand);
  border: 1px solid #b8d5eb;
}

/* ── Dashboard filter bar ── */
.dash-filters {
  display: flex;
  align-items: flex-end;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 1rem 0 1.25rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-select {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--color-text);
  background: #fff;
  cursor: pointer;
  min-width: 160px;
  transition: border-color 0.15s;
}

.filter-select:focus {
  outline: none;
  border-color: var(--color-brand);
}

.filter-date {
  min-width: 150px;
}

.filter-meta {
  font-size: 0.85rem;
  color: var(--color-muted);
  padding-bottom: 0.45rem;
  margin-left: auto;
}

/* ── Charts grid ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  padding-bottom: 2rem;
}

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

.chart-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chart-question {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-brand);
  line-height: 1.4;
}

.chart-meta {
  font-size: 0.78rem;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.dash-empty--spaced { padding: 2rem 0; }

.dash-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--color-muted);
  font-size: 1rem;
}

/* ── Details page ── */
.filter-select--wide { min-width: 280px; }
.filter-select--sm   { min-width: 130px; font-size: 0.82rem; padding: 0.35rem 0.6rem; }

.chart-card-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.chart-type-ctrl {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Gray band — full-width bleed container */
.detail-band {
  margin: 0 -1.5rem;
  background: #e8edf2;
  padding: 1.25rem 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* White card inside the band */
.detail-card {
  background: #fff;
  border: 1px solid #c5cdd6;
  border-radius: 3px;
  padding: 1.1rem 1.5rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}


/* Filter form inside a card — compact, no standalone bottom border */
.dash-filters--card {
  border-bottom: none;
  margin-bottom: 0;
  padding: 0;
}

.response-page-hdr {
  margin-bottom: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--color-brand);
}

.response-total {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
}

.response-list {
  display: flex;
  flex-direction: column;
}

.response-row {
  display: flex;
  gap: 0.65rem;
  padding: 0.6rem 1rem 0.65rem;
}

.response-row + .response-row {
  border-top: 1px solid var(--color-border);
}

.response-bullet {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  background: var(--color-brand);
  margin-top: 0.45rem;
}

.response-body {
  flex: 1;
  min-width: 0;
}

.response-name-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.crew-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-brand);
}

.response-date {
  font-size: 0.78rem;
  color: var(--color-text);
  margin-top: 0.05rem;
}

.response-answer {
  font-size: 0.875rem;
  color: var(--color-text);
  margin-top: 0.1rem;
  padding-left: 1.25rem;
}

.response-comment {
  font-size: 0.85rem;
  color: var(--color-text);
  margin-top: 0.15rem;
  line-height: 1.5;
}

.comment-label {
  font-weight: 700;
  color: var(--color-text);
}

.expand-btn {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s, color 0.15s, transform 0.2s;
}

.expand-btn:hover  { border-color: var(--color-brand); color: var(--color-brand); }
.expand-btn--open  { transform: rotate(90deg); color: var(--color-brand); border-color: var(--color-brand); }

.response-history {
  margin-top: 0.5rem;
  border-left: 2px solid var(--color-brand);
  padding-left: 0.75rem;
}

.response-history-item {
  padding: 0.4rem 0;
}

.response-history-item + .response-history-item {
  border-top: 1px dashed var(--color-border);
}

/* ── Login page — full-bleed background ── */
body.login-page {
  background: #0a1628 url('/login-bg.jpg') center 40% / cover fixed;
}

body.login-page .site-header {
  background: rgba(0, 45, 110, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

body.login-page .main-content {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem var(--page-gutter);
  background: linear-gradient(rgba(0, 8, 30, 0.38), rgba(0, 8, 30, 0.38));
}

body.login-page .site-footer {
  background: transparent;
  border-top-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.4);
}

body.login-page .auth-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.04);
  margin: 0;
}

.login-tagline {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-brand);
  margin-bottom: 0.35rem;
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.85rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}
