@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600;700;800&display=swap');

:root {
  --brand: #40083f;
  --brand-2: #a85c9f;
  --brand-soft: #f2e5f0;
  --surface: #ffffff;
  --canvas: #f8f4ef;
  --ink: #281528;
  --muted: #705f70;
  --line: #e7dce5;
  --danger: #a43e4a;
  --success: #2e7257;
  --warning: #8b651e;
  --shadow: 0 18px 45px rgba(64, 8, 63, .09);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: 'Raleway', Arial, sans-serif; line-height: 1.5; }
button, input, select { font: inherit; }
a { color: inherit; }

.app-header { position: sticky; top: 0; z-index: 50; background: rgba(64, 8, 63, .97); color: white; box-shadow: 0 8px 24px rgba(64, 8, 63, .18); }
.nav-wrap { max-width: 1220px; min-height: 72px; margin: auto; padding: 0 24px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 13px; text-decoration: none; margin-right: auto; }
.brand img { width: 156px; height: auto; filter: brightness(0) invert(1); }
.brand span { padding-left: 13px; border-left: 1px solid rgba(255,255,255,.28); font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; opacity: .76; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link, .logout-button { border: 0; background: transparent; color: rgba(255,255,255,.78); text-decoration: none; padding: 11px 13px; border-radius: 10px; cursor: pointer; font-size: .86rem; font-weight: 600; }
.nav-link:hover, .nav-link.active, .logout-button:hover { color: #fff; background: rgba(255,255,255,.11); }
.logout-form { margin: 0; }
.nav-toggle { display: none; border: 1px solid rgba(255,255,255,.25); background: transparent; color: white; border-radius: 9px; width: 42px; height: 42px; cursor: pointer; }

.page { max-width: 1220px; margin: 0 auto; padding: 42px 24px 70px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--brand-2); font-size: .76rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, h3 { margin-top: 0; letter-spacing: -.025em; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 3.5vw, 2.65rem); line-height: 1.1; }
h2 { font-size: 1.25rem; }
.lead, .muted { color: var(--muted); }
.lead { margin: 0; max-width: 700px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.panel-header { padding: 22px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-header h2 { margin: 0; }
.panel-body { padding: 24px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 18px; }
.section-title { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; margin: 8px 0 0; color: var(--brand); font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.section-title::after { content: ''; height: 1px; flex: 1; background: var(--line); }

.field { display: grid; gap: 7px; }
.field label { font-size: .84rem; font-weight: 700; }
.field small { color: var(--muted); }
.input, .select { width: 100%; min-height: 48px; border: 1px solid #d8cbd6; border-radius: 11px; padding: 10px 13px; background: #fff; color: var(--ink); outline: none; transition: .2s; }
.input:focus, .select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(168,92,159,.13); }
.input-invalid { border-color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn { min-height: 44px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; font-weight: 700; transition: transform .15s, box-shadow .15s, background .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), #67205f); color: white; box-shadow: 0 8px 20px rgba(64,8,63,.18); }
.btn-secondary { background: white; color: var(--brand); border-color: #cdbdca; }
.btn-danger { background: #fff; color: var(--danger); border-color: #e6bfc4; }
.btn-small { min-height: 36px; padding: 7px 11px; font-size: .8rem; }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 240px; }
.search .input { padding-left: 40px; }
.search::before { content: ''; position: absolute; left: 15px; top: 17px; width: 12px; height: 12px; border: 2px solid var(--muted); border-radius: 50%; opacity: .7; }
.search::after { content: ''; position: absolute; left: 27px; top: 29px; width: 7px; height: 2px; background: var(--muted); transform: rotate(45deg); opacity: .7; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #f4ebf3; color: var(--brand); font-size: .71rem; letter-spacing: .08em; text-transform: uppercase; text-align: left; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fcf9fc; }
td { font-size: .9rem; }
.table-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.pagination { display: flex; justify-content: center; gap: 6px; padding: 20px; }
.page-button { min-width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--brand); cursor: pointer; }
.page-button.active { background: var(--brand); color: white; border-color: var(--brand); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { padding: 18px; background: white; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 9px 26px rgba(64,8,63,.06); }
.stat-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.stat-value { margin-top: 7px; color: var(--brand); font-size: 1.55rem; font-weight: 800; }

.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.result { padding: 17px; border-radius: 13px; background: #faf6f9; border: 1px solid var(--line); }
.result span { display: block; color: var(--muted); font-size: .76rem; margin-bottom: 5px; }
.result strong { color: var(--brand); font-size: 1.08rem; }
.badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: .72rem; font-weight: 800; background: var(--brand-soft); color: var(--brand); }
.alert { padding: 14px 16px; border-radius: 11px; border: 1px solid; margin-bottom: 18px; }
.alert-error { color: #7d2732; background: #fff0f2; border-color: #edc2c8; }
.alert-success { color: #205b44; background: #eef9f4; border-color: #b9ddcf; }
.alert-warning { color: #6f511a; background: #fff8e9; border-color: #ead5a5; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1fr) minmax(420px, .82fr); background: white; }
.login-visual { position: relative; overflow: hidden; padding: 8vw; color: white; display: flex; flex-direction: column; justify-content: flex-end; background: linear-gradient(145deg, #2b052b 0%, var(--brand) 42%, #72256a 100%); }
.login-visual::before, .login-visual::after { content: ''; position: absolute; width: 360px; height: 730px; border: 42px solid rgba(255,255,255,.10); border-radius: 50%; transform: rotate(38deg); right: -80px; top: -210px; }
.login-visual::after { right: auto; left: -210px; top: auto; bottom: -390px; border-color: rgba(168,92,159,.35); }
.login-copy { position: relative; z-index: 2; max-width: 560px; }
.login-copy img { width: min(310px, 80%); filter: brightness(0) invert(1); margin-bottom: 40px; }
.login-copy h1 { font-size: clamp(2.1rem, 4vw, 4rem); }
.login-copy p { color: rgba(255,255,255,.76); font-size: 1.04rem; }
.eyebrow-light { color: #dab2d5; }
.login-form-area { display: grid; place-items: center; padding: 40px; background: var(--canvas); }
.login-card { width: min(430px, 100%); }
.login-card h2 { font-size: 1.8rem; margin-bottom: 8px; }
.login-card .stack { margin-top: 28px; }

.modal-backdrop { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(31,7,30,.62); padding: 24px; place-items: center; }
.modal-backdrop.open { display: grid; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: white; border-radius: 18px; box-shadow: 0 25px 80px rgba(0,0,0,.28); }
.modal-head, .modal-body, .modal-foot { padding: 20px 24px; }
.modal-head { border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal-foot { border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.close-button { border: 0; background: transparent; font-size: 1.5rem; cursor: pointer; color: var(--muted); }

.chart-box { height: 340px; }
.chart-panel { margin-bottom: 28px; }
.assessments-list { margin-top: 34px; }
.assessments-head { margin-bottom: 0; }
.result-badge { margin-top: 8px; }
.result-panel { margin-top: 22px; }
.result-note { margin: 18px 0; }
.print-report-brand, .print-report-stamp { display: none; }
.print-report-meta { display: none; }
.page-message { margin: 18px 18px 0; }
.success-page { min-height: calc(100vh - 72px); display: grid; place-items: center; }
.success-panel { width: min(640px, 100%); }
.success-content { padding: 48px; text-align: center; display: grid; justify-items: center; }
.success-content .actions { justify-content: center; margin-top: 12px; }
.success-mark { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 22px; color: white; background: linear-gradient(135deg, var(--brand), var(--brand-2)); font-size: 2rem; font-weight: 800; }
.evaluation-card { background: white; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.evaluation-head { background: #f5edf4; padding: 15px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.evaluation-body { padding: 18px; }

.setup-page { min-height: 100vh; max-width: 980px; margin: 0 auto; padding: 40px 20px 70px; }
.setup-hero { display: flex; align-items: center; gap: 26px; padding: 34px 40px; margin-bottom: 22px; color: white; border-radius: 20px; background: linear-gradient(135deg, #2b052b, var(--brand) 55%, #72256a); box-shadow: 0 18px 45px rgba(64,8,63,.18); }
.setup-hero img { width: 205px; filter: brightness(0) invert(1); }
.setup-hero h1 { margin: 4px 0 8px; color: white; }
.setup-hero p:not(.eyebrow) { margin: 0; color: rgba(255,255,255,.8); }
.setup-card { overflow: hidden; }
.requirements { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 28px; }
.requirement { padding: 10px 12px; border-radius: 9px; font-size: .82rem; }
.requirement span { margin-right: 8px; font-size: .68rem; font-weight: 800; letter-spacing: .06em; }
.requirement-ok { color: #23653d; background: #edf8f1; }
.requirement-fail { color: #8a2f3c; background: #fff0f1; }
.setup-note { grid-column: 1 / -1; padding: 14px; color: var(--muted); font-size: .84rem; border: 1px solid var(--line); border-radius: 10px; background: #faf6f9; }
.setup-submit { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.setup-submit .muted { margin: 0; }

@media (max-width: 900px) {
  .stats, .result-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { min-height: 300px; padding: 48px 32px; }
  .login-copy img { margin-bottom: 22px; width: 230px; }
  .login-copy h1 { font-size: 2.15rem; }
}

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-wrap { min-height: 64px; padding: 0 16px; }
  .brand img { width: 135px; }
  .brand span { display: none; }
  .nav-links { display: none; position: absolute; left: 12px; right: 12px; top: 68px; padding: 10px; border-radius: 14px; background: var(--brand); box-shadow: var(--shadow); align-items: stretch; flex-direction: column; }
  .nav-links.open { display: flex; }
  .nav-link, .logout-button { width: 100%; text-align: left; }
  .page { padding: 30px 15px 50px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .panel-header, .panel-body { padding: 18px; }
  .result-grid, .stats { grid-template-columns: 1fr 1fr; }
  .hide-mobile { display: none; }
  th, td { padding: 12px; }
  .setup-page { padding: 24px 15px 50px; }
  .setup-hero { align-items: flex-start; flex-direction: column; padding: 28px 24px; }
  .setup-hero img { width: 180px; }
  .requirements { grid-template-columns: 1fr; }
  .setup-submit { align-items: stretch; flex-direction: column; }
}

@media (max-width: 480px) {
  .result-grid, .stats { grid-template-columns: 1fr; }
  .login-form-area { padding: 30px 20px; }
  .login-visual { min-height: 260px; padding: 36px 22px; }
  .login-copy p { display: none; }
  .actions .btn { width: 100%; }
}

@media print {
  .app-header, .no-print, .btn, .toolbar { display: none !important; }
  body, html { background: white; }
  .page { max-width: none; padding: 0; }
  .panel, .evaluation-card { box-shadow: none; break-inside: avoid; }
  body.new-assessment-page > .app-header, body.new-assessment-page form > .panel:first-child { display: none !important; }
  body.new-assessment-page .result-panel { display: block !important; margin: 0; border: 0; box-shadow: none; }
  body.new-assessment-page .result-panel .panel-header, body.new-assessment-page .result-panel .result-note, body.new-assessment-page .result-panel .actions { display: none !important; }
  body.new-assessment-page .result-panel .panel-body { padding: 30px 34px; }
  .result-panel { display: block !important; border: 0; }
  .result-panel .panel-header, .result-panel .result-note { display: none; }
  .print-report-brand { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 34px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
  .print-report-brand img { width: 220px; }
  .print-report-brand p { margin: 0; font-size: 1.4rem; font-weight: 700; }
  .print-report-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-bottom: 26px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
  .print-report-meta div { padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .print-report-meta div:nth-child(3n) { border-right: 0; }
  .print-report-meta div:nth-last-child(-n+3) { border-bottom: 0; }
  .print-report-meta span { display: block; color: var(--muted); font-size: .68rem; }
  .print-report-meta strong { font-size: .86rem; }
  .print-report-stamp { display: flex; justify-content: flex-end; margin-top: 28px; }
  .print-report-stamp img { width: 110px; }
}
