:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1f2933;
  --muted: #667085;
  --line: #e4dfd4;
  --accent: #8b3a2b;
  --accent-soft: #f6ebe7;
  --green: #2f6b4f;
  --green-soft: #e7f3ec;
  --blue: #1e4f7a;
  --blue-soft: #e6f0f8;
  --amber: #9a6700;
  --amber-soft: #fff6dd;
  --red: #9b2c2c;
  --red-soft: #fdecec;
  --shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
  --radius: 16px;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(139, 58, 43, 0.08), transparent 30%),
    linear-gradient(180deg, #f8f4ed 0%, var(--bg) 100%);
  min-height: 100vh;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-title {
  display: inline-flex;
  align-items: center;
  color: #5f2419;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px;
}

.auth-panel {
  max-width: 420px;
}

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 76px);
  margin: -28px;
  padding: 28px;
}

.login-card {
  width: 100%;
}

.login-title {
  margin: 0 0 10px;
  text-align: center;
  font-size: 1.75rem;
}

.login-subtitle {
  margin: 0 0 24px;
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
}

.auth-panel .actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.readonly-summary {
  white-space: pre-wrap;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.topnav-user {
  align-self: center;
  color: var(--muted);
  font-size: 0.95rem;
  margin-right: 4px;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 2.2rem;
}

.page-header {
  margin-bottom: 24px;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
  line-height: 1.5;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  width: 100%;
}

.grid {
  display: grid;
  gap: 18px;
  width: 100%;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 58, 43, 0.35);
}

.card h3 {
  margin: 0 0 8px;
}

.week-card {
  padding: 24px;
}

.week-card-title {
  color: var(--accent);
  font-size: 1.65rem;
  line-height: 1.2;
}

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

.primary-btn,
.ghost-btn,
.danger-btn {
  border-radius: 999px;
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  color: white;
}

.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.danger-btn {
  background: var(--red-soft);
  color: var(--red);
  border-color: #f3caca;
}

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

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

input[type="text"],
input[type="date"],
input[type="password"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: white;
}

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

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.page-actions {
  margin: 0 0 18px;
}

.meta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.95rem;
}

.summary-section {
  margin-top: 18px;
}

.summary-section h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
}

.summary-field {
  position: relative;
  border-radius: 14px;
}

.summary-field.positive {
  background: var(--green-soft);
  border: 1px solid #cfe7d8;
}

.summary-field.improve {
  background: var(--amber-soft);
  border: 1px solid #f1dfaa;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 12px;
  font-size: 0.85rem;
  z-index: 1;
  background: rgba(255, 255, 255, 0.92);
}

.summary-textarea {
  display: block;
  width: 100%;
  min-height: 140px;
  border: none;
  border-radius: 14px;
  padding: 16px 88px 16px 16px;
  line-height: 1.6;
  resize: vertical;
  background: transparent;
  vertical-align: top;
}

.summary-textarea:focus {
  outline: none;
}

.summary-field:focus-within {
  box-shadow: 0 0 0 2px rgba(139, 58, 43, 0.2);
}

.show-original-btn {
  margin-top: 8px;
}

.original-feedback {
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.original-feedback-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.6;
}

.original-feedback-list li + li {
  margin-top: 8px;
}

.summary-box {
  border-radius: 14px;
  padding: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.summary-box.positive {
  background: var(--green-soft);
  border: 1px solid #cfe7d8;
}

.summary-box.improve {
  background: var(--amber-soft);
  border: 1px solid #f1dfaa;
}

.summary-box.notes {
  background: #f7f4ff;
  border: 1px solid #ddd5f5;
}

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

.rating-chip {
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: white;
}

.rating-chip strong {
  display: block;
  margin-bottom: 6px;
}

.rating-chip .score {
  font-size: 1.1rem;
  font-weight: 700;
}

.rating-chip.strong {
  background: var(--green-soft);
}

.rating-chip.exceptional {
  background: var(--blue-soft);
  border-color: #c5d9ea;
}

.rating-chip.mixed {
  background: var(--amber-soft);
}

.rating-chip.weak {
  background: var(--red-soft);
}

.radar-section {
  margin-bottom: 28px;
}

.radar-selector-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.radar-selector-label select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
}

.radar-chart-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 24px;
}

.radar-chart {
  width: min(100%, 420px);
  height: auto;
  overflow: visible;
}

.radar-grid-ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.radar-spoke {
  stroke: var(--line);
  stroke-width: 1;
}

.radar-data {
  fill: rgba(30, 79, 122, 0.18);
  stroke: var(--blue);
  stroke-width: 2;
}

.radar-dot {
  fill: var(--blue);
  stroke: white;
  stroke-width: 1.5;
}

.radar-label {
  fill: var(--muted);
  font-size: 11px;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.history-panel {
  margin-top: 24px;
}

.history-item {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.history-item:first-child {
  border-top: none;
  padding-top: 0;
}

.trend-table {
  width: 100%;
  border-collapse: collapse;
}

.trend-table th,
.trend-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
}

.warning-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--amber-soft);
  border: 1px solid #f1dfaa;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.upload-panel h2 {
  margin: 0 0 8px;
}

.upload-panel-centered {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.upload-panel-inner {
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.upload-panel-inner .meta-row {
  justify-content: center;
  text-align: center;
}

.upload-actions {
  justify-content: center;
  margin-top: 16px;
}

.csv-drop-zone {
  position: relative;
  margin-top: 16px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  padding: 40px 24px;
  background: white;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.csv-drop-zone:hover,
.csv-drop-zone:focus-visible {
  border-color: rgba(139, 58, 43, 0.45);
  background: var(--accent-soft);
  outline: none;
}

.csv-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.csv-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.csv-drop-zone-content {
  pointer-events: none;
}

.csv-drop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}

.csv-drop-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 600;
}

.csv-drop-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.csv-file-name {
  margin: 14px 0 0;
  color: var(--accent);
  font-weight: 600;
  word-break: break-word;
}

.roster-table {
  width: 100%;
  border-collapse: collapse;
}

.roster-table th,
.roster-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--red);
}

.hidden {
  display: none;
}

.loading {
  opacity: 0.65;
  pointer-events: none;
}

@media (max-width: 720px) {
  .content {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .topnav {
    justify-content: space-between;
  }
}
