:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --accent: #1f5f99;
  --accent-hover: #174a78;
  --border: #d8dee6;
  --error: #b42318;
  --success: #067647;
  --warning: #b54708;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: #0f2744;
  color: #fff;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-block:hover .brand-text {
  color: #fff;
}

.site-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  flex-shrink: 0;
}

.brand-text {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.25;
  color: #e8f0fa;
}

.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.login-logo {
  display: block;
  max-width: min(220px, 70vw);
  height: auto;
  object-fit: contain;
}

.header-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.header-nav a {
  color: #dbeafe;
  text-decoration: none;
}

.header-nav a:hover {
  color: #fff;
}

.user-chip {
  background: rgba(255, 255, 255, 0.12);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(15, 39, 68, 0.06);
}

.login-card {
  max-width: 420px;
  margin: 2rem auto 3rem;
  text-align: center;
}

.login-card h1 {
  font-size: 1.35rem;
  margin: 0 0 0.35rem;
}

.login-card .form {
  text-align: left;
  margin-top: 1rem;
}

.form label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-weight: 600;
}

.form input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.form textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn-small {
  margin-top: 0;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
}

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

.page-header h1 {
  margin-bottom: 0.25rem;
}

.reviewer-meta {
  color: var(--muted);
}

.proposals-count {
  margin: 0.5rem 0 0;
  font-size: 1.05rem;
}

.sep {
  margin: 0 0.35rem;
}

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.data-table th {
  background: #eef3f8;
  position: sticky;
  top: 0;
}

.summary-cell {
  min-width: 280px;
  max-width: 420px;
}

.summary-body {
  white-space: pre-wrap;
  margin: 0.5rem 0 0;
  max-height: 320px;
  overflow: auto;
  font-size: 0.92rem;
}

details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.flash-list {
  list-style: none;
  padding: 0;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.flash-error {
  background: #fef3f2;
  color: var(--error);
}

.flash-success {
  background: #ecfdf3;
  color: var(--success);
}

.flash-warning {
  background: #fffaeb;
  color: var(--warning);
}

.muted {
  color: var(--muted);
}

.empty-state {
  padding: 2rem;
  background: var(--card);
  border-radius: 12px;
  border: 1px dashed var(--border);
}

.proposal-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
}

.proposal-meta dt {
  font-weight: 600;
  color: var(--muted);
}

.actions-row {
  margin: 1rem 0;
}

.review-meta-card {
  margin-bottom: 1rem;
}

.rubric-title {
  margin-top: 1.25rem;
  margin-bottom: 0.25rem;
}

.rubric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.rubric-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: #fbfcfe;
}

.rubric-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.rubric-max {
  color: var(--muted);
  font-size: 0.9rem;
}

.rubric-label {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 0.5rem;
}

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

.attachments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.attachment-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

.attachment-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.attachment-name {
  margin: 0;
  font-size: 1.05rem;
}

.attachment-meta {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.attachment-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.file-preview {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.file-preview summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.pdf-preview-wrap {
  margin-top: 0.5rem;
  width: 100%;
  /* Safari richiede altezza esplicita sul contenitore, non solo min-height */
  height: min(80vh, 900px);
  min-height: 520px;
}

.pdf-preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

/* Safari: iframe PDF dentro <details> */
.file-preview[open] .pdf-preview-wrap {
  height: min(80vh, 900px);
}

.excel-preview-panel {
  margin-top: 0.5rem;
}

.excel-preview-scroll {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.excel-preview-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 100%;
}

.excel-preview-table td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  vertical-align: top;
  white-space: pre-wrap;
  max-width: 280px;
}

.preview-note {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-note a {
  color: var(--accent);
}

.status-legend-box {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.status-legend-title {
  margin: 0 0 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.status-legend-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.status-legend-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.status-legend-note {
  margin: 0.6rem 0 0;
  font-size: 0.88rem;
}

.status-dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.status-empty {
  background: #d92d20;
}

.status-partial {
  background: #f79009;
}

.status-complete {
  background: #12b76a;
}

.review-status-cell {
  min-width: 9rem;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-pill.status-empty {
  background: #fef3f2;
  color: #b42318;
  border-color: #fecdca;
}

.status-pill.status-partial {
  background: #fffaeb;
  color: #b54708;
  border-color: #fedf89;
}

.status-pill.status-complete {
  background: #ecfdf3;
  color: #067647;
  border-color: #abefc6;
}

.status-fraction {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .brand-text {
    font-size: 0.82rem;
  }

  .site-logo {
    height: 36px;
    max-width: 96px;
    padding: 3px 6px;
  }

  .header-nav {
    gap: 0.5rem;
    font-size: 0.88rem;
  }

  .user-chip {
    display: none;
  }
}

code {
  font-size: 0.9em;
  background: #eef3f8;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
