:root {
  --navy: #102a56;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #047857;
  --red: #b91c1c;
  --red-soft: #fff1f2;
  --amber: #b45309;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe3ee;
  --surface: #ffffff;
  --background: #f4f7fb;
  --radius: 16px;
  --shadow: 0 12px 35px rgba(15, 42, 86, .09);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.screen { min-height: 100vh; }
.center-screen, .auth-screen { display: grid; place-items: center; padding: 24px; }
.center-screen { color: var(--muted); gap: 14px; align-content: center; }
.loader { width: 38px; height: 38px; border: 4px solid #dbeafe; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-screen {
  background:
    radial-gradient(circle at 10% 10%, rgba(29, 78, 216, .18), transparent 28%),
    radial-gradient(circle at 90% 85%, rgba(4, 120, 87, .14), transparent 24%),
    linear-gradient(145deg, #eff6ff, #f8fafc 55%, #eef2ff);
}
.auth-card {
  width: min(450px, 100%);
  padding: 34px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(219,227,238,.9);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(15,42,86,.17);
  text-align: center;
}
.role-card { width: min(520px, 100%); }
.brand-mark {
  width: 64px; height: 64px; margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 18px; background: var(--navy); color: white;
  font-size: 23px; font-weight: 800; letter-spacing: .04em;
}
.brand-mark.small { width: 44px; height: 44px; margin: 0; border-radius: 12px; font-size: 16px; background: rgba(255,255,255,.14); }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow.light { color: #bfdbfe; }
.auth-card h1 { margin: 0; font-size: clamp(23px, 5vw, 31px); line-height: 1.2; }
.muted { color: var(--muted); }
.auth-form { display: grid; gap: 10px; margin-top: 26px; text-align: left; }
label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: #334155; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 11px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(59,130,246,.13); }
textarea { resize: vertical; }
.form-error { margin: 14px 0 0; padding: 10px; color: var(--red); background: var(--red-soft); border-radius: 10px; font-size: 13px; }
.text-button { border: 0; background: transparent; color: var(--blue); margin-top: 18px; font-size: 13px; }
.role-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 24px 0 4px; padding: 5px; background: #f1f5f9; border-radius: 13px; }
.role-option { border: 0; padding: 10px; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; }
.role-option.active { background: white; color: var(--blue); box-shadow: 0 2px 8px rgba(15,42,86,.1); }

.button {
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 15px; font-size: 13px; font-weight: 750;
  transition: transform .15s, background .15s, border-color .15s;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.primary { background: var(--blue); color: white; }
.button.primary:hover { background: #1e40af; }
.button.secondary { color: #334155; background: white; border-color: #cbd5e1; }
.button.secondary:hover { background: #f8fafc; }
.button.danger { color: white; background: var(--red); }
.button.ghost { color: white; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); }
.button.wide { width: 100%; margin-top: 7px; padding: 12px; }

.app-header { position: sticky; top: 0; z-index: 20; color: white; background: linear-gradient(100deg, #102a56, #173b72 55%, #102a56); box-shadow: 0 5px 22px rgba(15,42,86,.23); }
.header-inner { max-width: 1440px; margin: auto; padding: 13px 22px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.brand-row, .user-row { display: flex; align-items: center; gap: 12px; }
.header-inner h1 { margin: 0; font-size: 17px; }
.user-row { text-align: right; }
.user-row strong, .user-row span { display: block; }
.user-row span { color: #bfdbfe; font-size: 11px; margin-top: 2px; }
.main-nav { display: flex; gap: 3px; max-width: 1440px; margin: auto; padding: 0 20px; overflow-x: auto; border-top: 1px solid rgba(255,255,255,.09); }
.nav-button { flex: 0 0 auto; border: 0; border-bottom: 3px solid transparent; padding: 11px 15px 9px; color: #cbd5e1; background: transparent; font-size: 13px; font-weight: 700; }
.nav-button.active { color: #6ee7b7; border-bottom-color: #34d399; }

.page { max-width: 1440px; margin: auto; padding: 26px 22px 50px; }
.view { display: grid; gap: 18px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.page-heading h2 { margin: 0; font-size: 25px; }
.page-heading p { margin-bottom: 5px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 3px 12px rgba(15,42,86,.035); }
.project-nav { display: flex; align-items: center; gap: 8px; }
.counter { min-width: 65px; padding: 7px 9px; text-align: center; border-radius: 9px; background: #e2e8f0; font-size: 12px; font-weight: 800; color: #475569; }
.project-hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: start; }
.project-hero h3 { font-size: 21px; margin: 10px 0; }
.project-hero p { margin: 8px 0; }
.project-description { color: #475569; line-height: 1.65; white-space: pre-line; }
.code-badge { display: inline-block; padding: 5px 9px; color: white; background: var(--blue); border-radius: 7px; font-size: 12px; font-weight: 800; }
.score-total { min-width: 145px; padding: 17px; border: 1px solid #bfdbfe; border-radius: 15px; background: var(--blue-soft); text-align: center; }
.score-total span, .score-total small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.score-total strong { display: block; color: var(--blue); font-size: 40px; line-height: 1.15; }
.criteria-grid { display: grid; gap: 14px; margin-bottom: 18px; }
.criteria-group { background: white; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.criteria-group h3 { margin: 0; padding: 13px 16px; background: #f1f5f9; font-size: 14px; }
.criteria-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, .7fr); gap: 18px; align-items: center; padding: 15px 16px; border-top: 1px solid #edf1f6; }
.criteria-item:first-of-type { border-top: 0; }
.criteria-item h4 { margin: 0 0 5px; font-size: 14px; }
.criteria-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.score-control { display: grid; grid-template-columns: 1fr 70px; gap: 10px; align-items: center; }
.score-control input[type=range] { padding: 0; accent-color: var(--blue); }
.score-control input[type=number] { text-align: center; font-weight: 800; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.form-actions .muted { margin-right: auto; font-size: 12px; }

.search-box { width: min(410px, 100%); }
.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.project-card { display: flex; flex-direction: column; gap: 10px; min-height: 245px; }
.project-card h3 { margin: 0; font-size: 16px; line-height: 1.4; }
.project-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.project-card .description { flex: 1; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.project-card .description.expanded { display: block; overflow: visible; white-space: pre-line; }
.project-card-actions { display: flex; justify-content: flex-end; border-top: 1px solid #edf1f6; padding-top: 12px; }
.empty-state { grid-column: 1 / -1; text-align: center; color: var(--muted); }
.button.compact { padding: 6px 9px; font-size: 11px; }

.table-panel { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px; background: #f1f5f9; text-align: left; color: #475569; white-space: nowrap; }
td { padding: 11px; border-top: 1px solid #e8edf4; vertical-align: top; }
tbody tr:hover { background: #f8fafc; }
.matrix-table { min-width: 1220px; }
.matrix-table th:not(:nth-child(3)), .matrix-table td:not(:nth-child(3)) { text-align: center; }
.status { display: inline-block; padding: 4px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.status.done { color: var(--green); background: #d1fae5; }
.status.pending { color: var(--muted); background: #e2e8f0; }
.stat-inline { padding: 12px 16px; border-radius: 13px; background: white; border: 1px solid var(--line); }
.stat-inline strong { color: var(--green); font-size: 25px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.stat-card { padding: 16px; border-radius: 15px; background: white; border: 1px solid var(--line); }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin-top: 7px; font-size: 24px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.action-card { display: flex; flex-direction: column; align-items: flex-start; min-height: 185px; }
.action-card h3 { margin: 0 0 7px; }
.action-card p { flex: 1; color: var(--muted); line-height: 1.55; }
.danger-card { border-color: #fecdd3; background: #fffafa; }
.file-button { position: relative; overflow: hidden; display: inline-block; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(15,23,42,.62); backdrop-filter: blur(3px); }
.modal-card { width: min(500px, 100%); padding: 24px; border-radius: 20px; background: white; box-shadow: var(--shadow); }
.modal-card h2 { margin-top: 0; }
.modal-card p { color: var(--muted); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.detail-modal-card { width: min(1050px, 100%); max-height: calc(100vh - 40px); overflow: auto; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.modal-heading h2 { margin: 10px 0 0; }
.evaluation-detail-body { display: grid; gap: 13px; margin-top: 18px; }
.evaluation-card { border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.evaluation-card-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; background: #f1f5f9; }
.evaluation-card-header h3 { margin: 0; font-size: 14px; }
.evaluation-card-header strong { color: var(--blue); font-size: 18px; }
.evaluation-card-content { padding: 14px; }
.evaluation-card-content p { margin: 0 0 12px; color: #475569; white-space: pre-line; }
.criterion-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; font-size: 12px; }
.criterion-detail { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed #e2e8f0; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; max-width: min(420px, calc(100vw - 44px)); padding: 13px 16px; color: white; background: #172033; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.is-busy { cursor: progress; }
.is-busy button, .is-busy .file-button { pointer-events: none; }

@media (max-width: 980px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .header-inner, .page-heading { align-items: stretch; flex-direction: column; }
  .user-row { justify-content: space-between; text-align: left; }
  .header-inner h1 { font-size: 14px; }
  .page { padding: 20px 14px 40px; }
  .project-hero { grid-template-columns: 1fr; }
  .score-total { width: 100%; }
  .criteria-item { grid-template-columns: 1fr; }
  .project-grid, .settings-grid, .stats-grid { grid-template-columns: 1fr; }
  .search-box { width: 100%; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .muted { width: 100%; }
  .criterion-detail-grid { grid-template-columns: 1fr; }
}
