/* Tracer Study System — hand-written CSS (no framework, same approach as TES) */
:root {
  --ink: #1b2430; --muted: #5b6676; --line: #dde3ea; --bg: #f5f7fa; --card: #fff;
  --brand: #1f3864; --brand-2: #2f5597; --accent: #0f7b6c; --warn: #b26b00; --err: #b42318; --ok-bg: #e7f5ee; --err-bg: #fdecea; --info-bg: #eaf1fb;
  --radius: 10px;
  font-family: "Kantumruy Pro", "Inter", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.6; }
a { color: var(--brand-2); }
h1 { font-size: 1.45rem; margin: 0 0 .8rem; line-height: 1.35; }
h2 { font-size: 1.1rem; margin: 0 0 .7rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
[hidden] { display: none !important; }

/* Forms */
input[type=text], input[type=number], input[type=email], input[type=tel], input[type=url], input[type=date], input[type=password], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: inherit; padding: .6rem .7rem; border: 1px solid #c4cdd8; border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; border-color: var(--brand-2); }
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: .95rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.check input { width: auto; margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; padding: .6rem 1.1rem;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: #fff; color: var(--brand); border-color: #c4cdd8; }
.btn-ghost:hover { border-color: var(--brand-2); }
.btn-sm { padding: .35rem .7rem; min-height: 36px; font-size: .9rem; }
.link-btn { background: none; border: 0; color: var(--err); cursor: pointer; padding: 0; font: inherit; }
.stack > * + * { margin-top: .9rem; }
.narrow { max-width: 640px; }
.grid-2 { display: grid; gap: .9rem; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: .9rem; grid-template-columns: repeat(3, 1fr); }
.inline-form { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: 1rem; }
.inline-form label { min-width: 180px; }
.inline { display: inline; }
fieldset.plain { border: 0; padding: 0; margin: 0; }
fieldset.plain legend { font-weight: 600; margin-bottom: .3rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-success { background: var(--ok-bg); color: #0b5d3b; }
.alert-error { background: var(--err-bg); color: var(--err); }
.alert-info { background: var(--info-bg); color: #1d3f72; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.2rem; }
.center { text-align: center; }
.badge { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .8rem; background: #eef1f5; color: var(--muted); font-weight: 600; white-space: nowrap; }
.badge-open, .badge-completed { background: var(--ok-bg); color: #0b5d3b; }
.badge-draft, .badge-started { background: var(--info-bg); color: #1d3f72; }
.badge-closed, .badge-refused { background: #eef1f5; color: var(--muted); }
.badge-warn { background: #fff4e0; color: var(--warn); }

/* ---------------- Survey (mobile first) ---------------- */
.survey-header { background: var(--brand); color: #fff; }
.survey-header-inner { max-width: 760px; margin: 0 auto; padding: .8rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.brand-uni { font-size: .85rem; opacity: .85; }
.brand-title { font-weight: 700; }
.lang-switch { display: flex; gap: .25rem; }
.lang-switch a { padding: .3rem .65rem; border-radius: 999px; text-decoration: none; font-size: .9rem; color: inherit; border: 1px solid rgba(127,127,127,.35); }
.survey-header .lang-switch a { color: #fff; border-color: rgba(255,255,255,.45); }
.lang-switch a.active { background: #fff; color: var(--brand); border-color: #fff; font-weight: 700; }
.admin-main .lang-switch a.active, .auth-lang a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.survey-main { max-width: 760px; margin: 0 auto; padding: 1rem; }
.survey-footer { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 2rem; color: var(--muted); font-size: .85rem; text-align: center; }
.progress { height: 8px; background: #e3e8ef; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); transition: width .3s; }
.progress-label { margin: .35rem 0 .2rem; color: var(--muted); font-size: .85rem; }
.wave-title { margin: 0; color: var(--muted); font-size: .9rem; }
.section-title { margin-top: .3rem; color: var(--brand); }
.section-intro { background: #fff; border-left: 4px solid var(--accent); padding: .8rem 1rem; border-radius: 6px; }
.resume-box { background: var(--info-bg); border-radius: var(--radius); padding: .8rem 1rem; margin: .8rem 0; }
.resume-box p { margin: 0 0 .5rem; }
.resume-row { display: flex; gap: .5rem; align-items: center; margin: .4rem 0 .8rem; }
.resume-row input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }

.q { border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; min-width: 0; }
.q.has-error { border-color: var(--err); background: #fffafa; }
.q-label { font-weight: 600; padding: 0; margin-bottom: .5rem; float: left; width: 100%; }
.q-label + * { clear: both; }
.req { color: var(--err); }
.q-help { color: var(--muted); font-size: .9rem; margin: 0 0 .6rem; clear: both; }
.q-error { color: var(--err); font-size: .9rem; margin: .4rem 0 0; font-weight: 600; }
.choices { display: grid; gap: .45rem; clear: both; }
.choice { display: flex; gap: .65rem; align-items: flex-start; font-weight: 400; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; min-height: 44px; }
.choice:hover { border-color: #b8c3d1; }
.choice input { width: 1.15rem; height: 1.15rem; margin: .2rem 0 0; flex: none; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand-2); background: #f2f6fc; }
.input-wrap { position: relative; clear: both; }
.input-unit { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-unit + input { padding-left: 1.6rem; }
.other-wrap { margin-top: .7rem; }
.other-label { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.matrix { clear: both; display: grid; gap: .7rem; }
.matrix-row { border-top: 1px solid var(--line); padding-top: .7rem; }
.matrix-row:first-child { border-top: 0; padding-top: 0; }
.matrix-row.has-error .matrix-label { color: var(--err); }
.matrix-label { font-weight: 600; margin-bottom: .4rem; }
.matrix-choices { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill { font-weight: 400; display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; cursor: pointer; font-size: .92rem; min-height: 40px; }
.pill input { margin: 0; accent-color: var(--brand); }
.pill:has(input:checked) { border-color: var(--brand-2); background: #e6eefb; font-weight: 600; }
.survey-nav { display: flex; gap: .5rem; align-items: center; margin: 1.2rem 0; }
.survey-nav .btn-primary { margin-left: auto; min-width: 120px; }
.survey-nav .btn-ghost { padding: .55rem .8rem; }
@media (max-width: 420px) { .survey-nav .btn { font-size: .92rem; } .survey-nav .btn-primary { min-width: 100px; } }
.done-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--accent); font-size: 2rem; display: grid; place-items: center; margin: .5rem auto 1rem; }

/* ---------------- Staff area ---------------- */
.admin-body { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--brand); color: #fff; flex: none; padding: 1rem .7rem; }
.sidebar-brand { font-weight: 700; padding: .3rem .6rem 1rem; line-height: 1.4; }
.sidebar nav a { display: block; color: #dfe7f5; text-decoration: none; padding: .55rem .7rem; border-radius: 8px; margin-bottom: .15rem; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 700; }
.admin-main { flex: 1; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1.5rem; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-user { display: flex; gap: .8rem; align-items: center; }
.topbar-user a { text-decoration: none; color: var(--ink); font-size: .92rem; }
.content { padding: 1.5rem; max-width: 1200px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 1.2rem; align-items: start; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .82rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
td.num, th.num { text-align: right; }
tr.muted td { color: var(--muted); }
tr.derived td { background: #fffbea; }
input.num-input { width: 110px; text-align: right; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.kpi-warn { border-color: #f0c36d; background: #fffaf0; }
.kpi-label { color: var(--muted); font-size: .88rem; font-weight: 600; }
.kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.3; color: var(--brand); }
.kpi-small { font-size: 1.3rem; }
.kpi-sub { color: var(--muted); font-size: .85rem; }
.ind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; }
.ind { border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
.ind-label { font-size: .88rem; color: var(--muted); min-height: 2.6em; }
.ind-value { font-size: 1.5rem; font-weight: 700; color: var(--brand); }
.ind-sub { font-size: .8rem; color: var(--muted); }
.bar { position: relative; height: 10px; background: #e9edf2; border-radius: 999px; min-width: 120px; }
.bar-fill { height: 100%; background: #9db5dd; border-radius: 999px; }
.bar-fill.ok { background: var(--accent); }
.bar-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .5; }
.meta-row { display: flex; flex-wrap: wrap; gap: .9rem; align-items: center; }
.meta-row .inline-form { margin: 0 0 0 auto; }
.plo-item { border-bottom: 1px solid var(--line); padding: .6rem 0; }
.plo-item:last-child { border-bottom: 0; }
.plo-item p { margin: .2rem 0; }
.plo-head { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-main { width: 100%; max-width: 420px; }
.auth-lang { justify-content: flex-end; margin-bottom: .8rem; }
.auth-card { padding: 1.6rem; }
.auth-title { font-size: 1.25rem; color: var(--brand); margin-bottom: .2rem; }

@media (max-width: 860px) {
  .admin-body { flex-direction: column; }
  .sidebar { width: 100%; padding: .6rem; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: .2rem; }
  .sidebar nav a { margin: 0; padding: .4rem .6rem; font-size: .9rem; }
  .sidebar-brand { padding-bottom: .4rem; }
  .two-col, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
}
@media (min-width: 640px) {
  .choices.cols-2 { grid-template-columns: 1fr 1fr; }
}
