/* Visual direction C (DECIZII #53): the colours of the school crest, navy and gold.
   No inline styles anywhere: the Content-Security-Policy forbids them (deploy/Caddyfile). */
:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #526071;
  --brand: #163f6e;
  --brand-dark: #0e2c4f;
  --brand-soft: #e8eef6;
  --gold: #f0a018;
  --gold-dark: #d98d0a;
  --on-gold: #1c1606;
  --alert: #9b2c2c;
  --border: #d5dae1;
  --shadow: 0 1px 2px rgba(20, 30, 50, .12), 0 3px 10px rgba(20, 30, 50, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  /* svh, not dvh: the small viewport does not change while the phone's toolbars slide in and
     out, so the page is not re-laid out during scrolling (iOS kept the top of the page
     unreachable after scrolling back up). */
  margin: 0; min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
.wrap { width: 100%; max-width: 40rem; margin: 0 auto; padding: 0 1rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem; z-index: 10; }

/* --- Header and footer --- */
.site-header { background: var(--brand-dark); color: #fff; }
.site-header .wrap { max-width: 72rem; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-top: .6rem; padding-bottom: .6rem; }
.brand { display: flex; align-items: center; gap: .65rem; min-width: 0; color: #fff; font-weight: 700; line-height: 1.2; text-decoration: none; }
.brand img { flex: none; width: auto; height: 2.6rem; }
.brand span { display: block; font-weight: 400; font-size: .75rem; opacity: .85; }
.logout { display: flex; align-items: center; gap: .75rem; margin: 0; }
.who { font-size: .875rem; overflow-wrap: anywhere; }
main.wrap { flex: 1; padding-top: 1.5rem; padding-bottom: 2rem; }
main > * + * { margin-top: 1rem; }
.site-footer { color: var(--muted); font-size: .8rem; text-align: center; padding-bottom: 1.5rem; }
@media (max-width: 520px) { .who { display: none; } .brand span { display: none; } }

/* --- Building blocks --- */
.card { background: var(--surface); border-radius: .75rem; box-shadow: var(--shadow); padding: 1.25rem; }
.card-alert { border-left: .4rem solid var(--alert); }
h1 { margin: 0 0 .75rem; font-size: 1.5rem; font-weight: 800; line-height: 1.25; color: var(--brand-dark); }
h2 { margin: 1rem 0 .5rem; font-size: 1.15rem; font-weight: 800; color: var(--brand-dark); }
.role { color: var(--muted); margin-top: 0; }
.muted, .hint { color: var(--muted); font-size: .9rem; }
.btn {
  display: inline-block; min-height: 2.75rem; padding: .6rem 1.1rem;
  border: 2px solid var(--brand); border-radius: .6rem; background: var(--surface);
  color: var(--brand); font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--brand-soft); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.btn-primary:hover { background: var(--gold-dark); border-color: var(--gold-dark); }
.btn-ghost { background: var(--gold); border-color: var(--gold); color: var(--on-gold); min-height: 2.25rem; padding: .25rem .8rem; }
.btn-ghost:hover { background: var(--gold-dark); border-color: var(--gold-dark); }
.btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 2px; box-shadow: 0 0 0 2px #fff; }
.site-header .btn:focus-visible, .site-header a:focus-visible { outline-color: #fff; box-shadow: none; }
.messages { list-style: none; margin: 0 0 1rem; padding: 0; }
.msg { padding: .75rem 1rem; border-radius: .6rem; border-left: .4rem solid var(--brand); background: var(--surface); box-shadow: var(--shadow); margin-bottom: .5rem; }
.msg-error { border-color: var(--alert); color: var(--alert); }
.msg-success { border-color: #2f6f4f; color: #1f5a3e; }
.badge { display: inline-block; padding: .15rem .65rem; border-radius: 1rem; font-size: .82rem; font-weight: 700; background: var(--brand-soft); color: var(--brand-dark); margin-right: .5rem; }
.badge-SUBMITTED { background: #fff3cd; color: #6b5200; }
.badge-VALIDATED { background: #d9eee3; color: #1f5a3e; }
.badge-RETURNED, .badge-TO_REDO { background: #f6dede; color: var(--alert); }
.badge-REOPENED { background: #ece4f6; color: #4b2a7a; }
.warn { color: #6b5200; font-weight: 700; }
.err { color: var(--alert); font-weight: 600; margin: .35rem 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
@media (max-width: 400px) { .card { padding: 1rem; } h1 { font-size: 1.3rem; } }

/* --- Login: the crest on navy, no header --- */
.page-login { background: linear-gradient(170deg, var(--brand) 0%, var(--brand-dark) 100%); color: #fff; }
.page-login .site-header { display: none; }
.page-login main { display: flex; flex-direction: column; justify-content: center; }
.page-login .site-footer { color: rgba(255, 255, 255, .8); }
.login { text-align: center; padding: 1rem 0; }
.login img { width: auto; height: 12rem; max-height: 34vh; filter: drop-shadow(0 0 1px rgba(255, 255, 255, .7)) drop-shadow(0 .5rem 1.1rem rgba(0, 0, 0, .35)); }
.login h1 { margin: 1.25rem 0 .5rem; font-size: 1.7rem; color: #fff; }
.login p { margin: 0 auto 1.5rem; max-width: 24rem; color: rgba(255, 255, 255, .85); }
.login .btn { display: block; width: 100%; max-width: 22rem; margin: 0 auto; font-size: 1.05rem; }
.login .btn:focus-visible { outline-color: #fff; box-shadow: none; }
.login .note { margin: 1.25rem auto 0; font-size: .85rem; }
.page-login .msg { color: var(--text); }
.page-login .msg-error { color: var(--alert); }

/* --- Application form (mobile first) --- */
.ident { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0 0 .75rem; }
.ident dt { font-weight: 600; margin-top: .5rem; color: var(--muted); font-size: .875rem; }
.ident dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (min-width: 640px) {
  .ident { grid-template-columns: 11rem 1fr; }
  .ident dt { margin-top: 0; padding: .25rem 0; }
  .ident dd { padding: .25rem 0; }
}
/* The form itself is not a card: each question is one. */
form.card:has(> #blocks) { background: transparent; box-shadow: none; padding: 0; counter-reset: step; }
form:has(> #blocks) { counter-reset: step; }
.q { border: 0; border-radius: .75rem; background: var(--surface); box-shadow: var(--shadow); margin: 0 0 .9rem; padding: 1rem; min-width: 0; }
.q.inner { margin: .5rem 0; padding: .75rem; box-shadow: none; border: 1px solid var(--border); }
.q > legend { float: left; width: 100%; padding: 0; margin: 0 0 .5rem; font-weight: 800; font-size: 1.05rem; line-height: 1.3; color: var(--brand-dark); }
.q > legend ~ * { clear: both; }
form:has(> #blocks) fieldset.q:not(.inner) > legend { display: flex; align-items: flex-start; gap: .6rem; }
form:has(> #blocks) fieldset.q:not(.inner) > legend::before {
  counter-increment: step; content: counter(step);
  flex: none; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--gold); color: var(--on-gold); font-size: .9rem; line-height: 1.7rem; text-align: center;
}
.q[aria-invalid="true"] { outline: 2px solid var(--alert); }
.req { font-weight: 400; color: var(--muted); font-size: .85rem; }
.opt { display: flex; align-items: center; gap: .65rem; min-height: 2.9rem; margin-top: .45rem; padding: .5rem .75rem; border: 2px solid var(--border); border-radius: .6rem; cursor: pointer; }
.opt input { width: 1.3rem; height: 1.3rem; margin: 0; flex: none; accent-color: var(--brand); }
.opt:has(input:checked) { border-color: var(--brand); background: var(--brand); color: #fff; font-weight: 600; }
.opt:has(input:checked) input { accent-color: var(--gold); }
.opt:has(input:focus-visible) { outline: 3px solid var(--brand-dark); outline-offset: 2px; }
.sub { margin: .5rem 0 .25rem .75rem; padding-left: .75rem; border-left: 3px solid var(--gold); }
.sub .opt:has(input:checked) { background: var(--brand-soft); color: var(--brand-dark); }
.sub .opt:has(input:checked) input { accent-color: var(--brand); }
.group { margin-bottom: .9rem; }
.group-title { font-weight: 700; margin: .5rem 0 0; }
.field { display: block; margin-top: .6rem; }
.field input[type=text], .field textarea { display: block; width: 100%; max-width: 100%; margin-top: .25rem; padding: .6rem .7rem; font: inherit; border: 2px solid var(--border); border-radius: .6rem; min-height: 2.75rem; }
.field select, .field input[type=date], .field input[type=search] { display: block; margin-top: .25rem; padding: .5rem .6rem; font: inherit; border: 2px solid var(--border); border-radius: .6rem; min-height: 2.75rem; background: var(--surface); }
/* In the form, a select with long option labels (the ministry's exam list) stays in its card. */
.q .field select { width: 100%; max-width: 100%; text-overflow: ellipsis; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 0; border-color: var(--brand); }
.err-summary { border: 2px solid var(--alert); border-radius: .75rem; background: var(--surface); padding: .5rem 1rem; margin-bottom: 1rem; }
.err-summary ul { margin: 0; padding-left: 1.2rem; }
.err-summary a { color: var(--alert); }
.gdpr { font-size: .875rem; color: var(--muted); }
details.q > summary, details.report > summary { cursor: pointer; font-weight: 700; min-height: 2.75rem; display: flex; align-items: center; color: var(--brand-dark); }
.progress { margin: 0 0 1rem; }
.progress[hidden] { display: none; }
.progress progress { display: block; width: 100%; height: .6rem; border: 0; border-radius: .6rem; overflow: hidden; background: #dfe4ea; -webkit-appearance: none; appearance: none; }
.progress progress::-webkit-progress-bar { background: #dfe4ea; }
.progress progress::-webkit-progress-value { background: var(--gold); border-radius: .6rem; }
.progress progress::-moz-progress-bar { background: var(--gold); border-radius: .6rem; }
.progress span { display: block; margin-top: .3rem; font-size: .85rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; position: sticky; bottom: 0; background: var(--surface); padding: .75rem; border-radius: .75rem .75rem 0 0; box-shadow: 0 -2px 10px rgba(20, 30, 50, .12); margin-top: 1rem; }
.actions .btn { flex: 1 1 8rem; padding-left: .5rem; padding-right: .5rem; }

/* --- Lists: homeroom teacher panel, secretariat, reports --- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.chip { display: inline-block; padding: .4rem .9rem; min-height: 2.5rem; border: 2px solid var(--border); border-radius: 1.5rem; text-decoration: none; font-weight: 600; color: var(--brand); background: var(--surface); }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .75rem; margin: 1rem 0; }
.tile { display: block; padding: .75rem .9rem; border-radius: .75rem; background: var(--brand); color: rgba(255, 255, 255, .88); font-size: .85rem; line-height: 1.3; text-decoration: none; border: 3px solid var(--brand); }
.tile b { display: block; font-size: 1.8rem; font-weight: 800; line-height: 1.15; color: var(--gold); }
.tile:hover { background: var(--brand-dark); }
.tile.on { border-color: var(--gold); background: var(--brand-dark); }
.rows li + li { border-top: 1px solid var(--border); }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem .75rem; min-height: 3rem; padding: .5rem 0; text-decoration: none; color: var(--text); }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.sheet { width: 100%; border-collapse: collapse; font-size: .9rem; }
.sheet th, .sheet td { border: 1px solid var(--border); padding: .5rem .6rem; text-align: left; vertical-align: top; }
.sheet th { background: var(--brand); border-color: var(--brand); color: #fff; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.sheet td a { font-weight: 600; }
.sheet .sign { min-width: 7rem; }
.sheet .cnp { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet td form { margin: 0; }
.wrap.wide { max-width: 72rem; }
.inline { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: flex-end; margin: .5rem 0; }
.inline .field { margin-top: 0; }
.history > li { padding: .75rem 0; }
.history > li + li { border-top: 1px solid var(--border); }
.history .events { margin: .25rem 0; padding-left: 1.2rem; }
.history .changes { margin-top: .5rem; }
.actions-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.scroll-x { overflow-x: auto; }

@media print {
  .site-header, .site-footer, .skip, .noprint { display: none !important; }
  body { display: block; background: #fff; }
  .card { box-shadow: none; padding: 0; }
  .wrap { max-width: none; }
  .sheet th { background: none; color: #000; border-color: #000; }
  .sheet td { border-color: #000; }
}
