:root {
  --primary-blue: #1a3a5f;
  --accent-gold: #d4af37;
  --bg-light: #f4f7f9;
  --text-dark: #2c3e50;
  --success-green: #27ae60;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-dark);
  margin: 0;
  padding-bottom: 76px;
}

.dashboard-header {
  background: linear-gradient(135deg, var(--primary-blue), #2c5282);
  color: #fff;
  padding: 22px 20px;
  border-radius: 0 0 25px 25px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  font-size: 1.2rem;
  font-weight: 700;
}

.text-btn {
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: transparent;
  color: #fff;
  border-radius: 16px;
  padding: 4px 10px;
  cursor: pointer;
}

.pilot-line {
  margin-top: 10px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

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

.with-divider {
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  display: block;
}

.stat-label {
  font-size: 0.75rem;
  opacity: 0.82;
}

.target-card {
  background: #fff;
  margin: -20px 20px 16px 20px;
  padding: 18px;
  border-radius: 15px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.target-top,
.target-bottom {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
}

.target-title {
  font-weight: 700;
}

.target-remain {
  color: var(--success-green);
}

.progress-container {
  height: 12px;
  background: #e0e0e0;
  border-radius: 6px;
  margin: 14px 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent-gold);
  width: 0%;
  transition: width 0.25s ease;
}

.module-section {
  padding: 0 20px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.card {
  background: #fff;
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 15px;
}

h3 {
  font-size: 1rem;
  margin-top: 0;
  border-left: 4px solid var(--primary-blue);
  padding-left: 10px;
}

.form-group {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.entry-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.entry-field {
  display: grid;
  gap: 6px;
}

.entry-field label {
  color: #334155;
  font-size: 0.85rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font: inherit;
}

textarea {
  resize: vertical;
  margin-bottom: 10px;
}

.btn-add {
  background: var(--primary-blue);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

.btn-light {
  background: #f3f4f6;
  color: #374151;
  border: none;
  padding: 8px 16px;
  border-radius: 18px;
  cursor: pointer;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 460px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}
.table-wrap::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  border-bottom: 1px solid #eee;
  text-align: left;
  padding: 9px 6px;
  white-space: nowrap;
}

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

.mini-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}

.mini-btn.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.chart-grid {
  display: grid;
  gap: 14px;
}

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

.insight-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.pf90-card {
  margin-bottom: 12px;
}

.pf90-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.pf90-badge {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.78rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
}

.pf90-badge.ok {
  border-color: #86efac;
  color: #166534;
  background: #f0fdf4;
}

.pf90-badge.warn {
  border-color: #fdba74;
  color: #9a3412;
  background: #fff7ed;
}

.pf90-badge.danger {
  border-color: #fca5a5;
  color: #991b1b;
  background: #fef2f2;
}

.pf90-grid {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

.fatigue-card {
  position: relative;
  overflow: hidden;
}

.fatigue-pilot {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 1.4rem;
  opacity: 0.85;
}

.insight-label {
  margin: 0;
  font-size: 0.82rem;
  color: #64748b;
}

.insight-value {
  margin: 4px 0 0;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.insight-list {
  margin-top: 6px;
  display: grid;
  gap: 4px;
  color: #0f172a;
  font-size: 0.92rem;
}

.goal-gap-panel {
  margin-top: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
  display: grid;
  gap: 5px;
  font-size: 0.9rem;
}

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

.medal-item {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 6px;
  font-size: 0.92rem;
}

.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chart-label {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #475569;
}

.chart-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.year-select {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.88rem;
  color: #0f172a;
}

.chart-canvas-fixed {
  height: 360px;
  max-height: 360px;
  overflow: hidden;
}

.chart-canvas-fixed #yearly-hours-chart {
  height: 100% !important;
  min-height: 0;
}

canvas {
  width: 100%;
  min-height: 240px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px;
}

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

.note-search-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
}

.log-search-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
}

.log-filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.log-filter-actions .btn-light {
  width: 100%;
}

.note-search-btn {
  padding: 8px 10px;
}

.note-search-count {
  font-size: 0.85rem;
  color: #64748b;
  min-width: 44px;
  text-align: right;
}

@media (max-width: 640px) {
  .note-search-row {
    grid-template-columns: 1fr 1fr;
  }
  .note-search-row #note-search-keyword {
    grid-column: 1 / -1;
  }
  .log-search-row {
    grid-template-columns: 1fr 1fr;
  }
  .log-search-row #log-search-keyword {
    grid-column: 1 / -1;
  }
  .log-filter-actions {
    grid-template-columns: 1fr;
  }
  .note-search-count {
    text-align: left;
  }
}

.note-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
}

.note-content-wrap {
  max-height: 220px;
  overflow: auto;
  padding-right: 6px;
  border: 1px dashed #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.note-content-wrap.is-full {
  max-height: none;
  overflow: visible;
  padding-right: 10px;
}

.note-content-wrap::-webkit-scrollbar {
  width: 8px;
}
.note-content-wrap::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
.note-content-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.note-title-btn {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.note-title {
  margin: 0;
  font-weight: 700;
}

.note-expand-indicator {
  color: #64748b;
  font-size: 0.8rem;
  white-space: nowrap;
}

.note-meta {
  margin: 6px 0;
  color: #6b7280;
  font-size: 0.8rem;
}

.note-content {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.note-actions {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.note-actions-left,
.note-actions-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.note-highlight {
  background: #fde68a;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.note-highlight.is-current {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.log-highlight {
  background: #fde68a;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.log-highlight.is-current {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.empty-tip {
  margin: 0;
  font-size: 0.9rem;
  color: #6b7280;
}

.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #fff;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 10px 4px;
  border-top: 1px solid #eee;
}

.nav-item {
  font-size: 0.78rem;
  text-align: center;
  color: #666;
  border: 0;
  background: none;
  padding: 4px;
}

.nav-item.active {
  color: var(--primary-blue);
  font-weight: 700;
}

dialog {
  border: 0;
  border-radius: 14px;
  width: min(92vw, 380px);
  padding: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-form {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.account-status {
  margin: 0;
  font-size: 0.85rem;
  color: #2563eb;
}

@media (min-width: 900px) {
  .module-section {
    max-width: 980px;
    margin: 0 auto;
  }

  .dashboard-header,
  .target-card {
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
  }

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

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

@media (max-width: 640px) {
  .entry-pair {
    grid-template-columns: 1fr;
  }
}

.logbook-filters {
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 4fr 0.75fr 0.75fr auto;
  gap: 10px;
  align-items: end;
}

.logbook-filters .entry-field:first-child {
  min-width: 220px;
}

.logbook-filters .entry-field:nth-child(2),
.logbook-filters .entry-field:nth-child(3) {
  min-width: 120px;
}

.logbook-filters .entry-field:last-child {
  min-width: 80px;
}

@media (max-width: 900px) {
  .logbook-filters {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .logbook-filters .entry-field:first-child {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .logbook-filters .entry-field:nth-child(2),
  .logbook-filters .entry-field:nth-child(3) {
    min-width: 0;
  }

  .logbook-filters .entry-field:last-child {
    grid-column: 1 / -1;
    min-width: 0;
  }
}

.auth-inline-links {
  margin: -2px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.inline-link-btn {
  border: 0;
  background: transparent;
  color: #2563eb;
  padding: 0;
  cursor: pointer;
  font-size: inherit;
}

.auth-divider {
  color: #94a3b8;
}

.flight-remark {
  margin-top: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
}

.editor-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.editor-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.editor-top h4 {
  margin: 0;
  font-size: 1rem;
  border-left: 4px solid var(--primary-blue);
  padding-left: 10px;
}

.editor-form {
  margin-bottom: 10px;
}

.remark-editor {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
}

.remark-toolbar {
  margin-bottom: 8px;
}

.remark-quill {
  min-height: 140px;
}

.row-selected {
  background: rgba(37, 99, 235, 0.12);
}

.table-wrap tbody tr {
  cursor: pointer;
}
