:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dde3e9;
  --text: #1f2933;
  --muted: #6b7885;
  --accent: #1f6feb;
  --accent-dark: #1a5ac4;
  --success-bg: #e6f5ec;
  --success-text: #1c7c46;
  --error-bg: #fdecec;
  --error-text: #b3261e;
  --info-bg: #eef4ff;
  --info-text: #1a4fa0;
  --locked-bg: #f7f8fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

/* ---------- layout ---------- */
.container { max-width: 1080px; margin: 24px auto 48px; padding: 0 16px; }
.container.narrow { max-width: 520px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 16px; }
h3 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); }

/* ---------- topbar ---------- */
.topbar { background: #12233b; color: #fff; }
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark { font-weight: 700; letter-spacing: 2px; }
.brand-text { font-size: 14px; opacity: .9; }
.topbar-actions { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.topbar-actions a { color: #cfe0ff; text-decoration: none; }
.topbar-actions a:hover { text-decoration: underline; }
.topbar-actions .user { display: flex; align-items: center; gap: 8px; opacity: .85; }
.topbar-actions .user img { border-radius: 50%; }
.link-button {
  background: none; border: none; color: #cfe0ff; cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline;
}

.site-footer {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 24px 16px 40px;
}

/* ---------- forms ---------- */
fieldset { border: none; margin: 0; padding: 0; }
fieldset[disabled] .card { background: var(--locked-bg); }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 13px; color: var(--muted); }
.field-value {
  margin: 0; padding: 8px 10px; background: var(--locked-bg);
  border: 1px solid var(--border); border-radius: 6px; min-height: 38px;
}

input[type="text"], input[type="date"], input[type="number"], select, textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 20px; }

.inline-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.inline-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.inline-form select { width: auto; min-width: 120px; }

.button {
  display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: 6px; padding: 9px 18px; font: inherit; cursor: pointer; text-decoration: none;
}
.button:hover { background: var(--accent-dark); }
.button-secondary { background: #fff; color: var(--accent); }
.button-secondary:hover { background: #eef4ff; }
.actions { display: flex; gap: 12px; margin: 8px 0 32px; }

.login-card { text-align: center; margin-top: 60px; }
.google-button { margin-top: 16px; }

/* ---------- criterion block ---------- */
.criterion { border-top: 1px solid var(--border); padding: 16px 0; }
.criterion:first-of-type { border-top: none; padding-top: 0; }
.criterion-locked { opacity: .75; }
.criterion-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.max-points { font-size: 13px; color: var(--muted); white-space: nowrap; }

.criterion-body { display: grid; grid-template-columns: 1fr 220px; gap: 24px; margin-top: 10px; }
.criterion-body-dual { grid-template-columns: 1fr 110px 220px; }
@media (max-width: 980px) {
  .criterion-body, .criterion-body-dual { grid-template-columns: 1fr; }
}

.self-readonly { background: #fff; text-align: center; }
.self-readonly .locked-value { font-size: 20px; color: var(--text); font-weight: 600; }
.reviewer-input { border-color: var(--accent); background: #f5f9ff; }

.readonly-text {
  background: var(--locked-bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; margin: 0 0 14px;
}
.month-heading { font-size: 13px; color: var(--muted); margin: 0 0 4px; }

.rubric-levels, .rubric-formula { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.rubric-levels li { display: flex; gap: 10px; padding: 3px 0; }
.level-score {
  flex: 0 0 34px; text-align: center; font-weight: 700; color: var(--accent);
  background: #eef4ff; border-radius: 4px; height: fit-content;
}
.rubric-formula li { padding: 3px 0; color: var(--text); }
.note { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }

.self-input {
  background: var(--locked-bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  height: fit-content;
}
.self-label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.level-choices { display: flex; flex-direction: column; gap: 6px; }
.choice { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.choice input { width: auto; }
.score-number { width: 90px; display: inline-block; }
.of-max { color: var(--muted); margin-left: 6px; }
.locked-value { font-size: 22px; margin: 0; color: var(--muted); }

/* ---------- summary ---------- */
.summary-card .total-line { font-size: 18px; margin: 0 0 10px; }
.summary-card .total-line strong { font-size: 26px; color: var(--accent); }
.summary-card .total-line .muted { font-size: 13px; display: block; }
.breakdown { list-style: none; padding: 0; margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- tables ---------- */
.data-table, .sheet-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { color: var(--muted); font-size: 12.5px; text-transform: uppercase; }
.row-actions { display: flex; gap: 12px; }

.sheet-table { border: 1px solid var(--border); margin-bottom: 20px; background: #fff; }
.sheet-table th, .sheet-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.sheet-table th { background: #f0f3f7; font-size: 13px; }
.sheet-table .num { text-align: center; white-space: nowrap; }
.sheet-table .dimension-row td { background: #eef4ff; font-weight: 600; }
.sheet-table .total-row td { font-weight: 700; background: #f7f8fa; }
.long-text { white-space: pre-wrap; }
.criterion-name { width: 45%; }

/* ---------- badges & alerts ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-draft { background: #fff4e0; color: #96590f; }
.badge-submitted { background: var(--success-bg); color: var(--success-text); }
.badge-closed { background: #eceff3; color: var(--muted); }

.alert { border-radius: 8px; padding: 12px 16px; margin: 0 0 16px; font-size: 14px; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-info { background: var(--info-bg); color: var(--info-text); }

/* ---------- print sheet ---------- */
.sheet-title { text-align: center; margin-bottom: 20px; }
.sheet-title .company { font-weight: 700; letter-spacing: 3px; margin: 0; }
.sheet-title .period { color: var(--muted); margin: 4px 0 0; }
.breakdown-line { color: var(--muted); font-size: 14px; }

@media print {
  .topbar, .site-footer, .no-print { display: none; }
  body { background: #fff; font-size: 12px; }
  .container { margin: 0; max-width: none; }
  .sheet-table { page-break-inside: auto; }
}

.container.narrow-wide { max-width: 760px; }
