:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #1f2733;
    --muted: #6b7480;
    --line: #e2e5ea;
    --accent: #2f6fed;
    --accent-dark: #244fb0;
    --ok: #1f8a4c;
    --ok-bg: #e6f5ec;
    --warn: #9a6b00;
    --warn-bg: #fdf3d8;
    --err: #b42318;
    --err-bg: #fdecea;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--card); border-bottom: 1px solid var(--line);
    padding: 0 1.25rem; height: 56px;
}
.brand { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.lang-switch { display: inline-flex; gap: .25rem; }
.lang {
    font-size: .8rem; padding: .15rem .4rem; border-radius: 6px;
    color: var(--muted);
}
.lang.active { background: var(--accent); color: #fff; }
.lang.active:hover { text-decoration: none; }
.btn-link { color: var(--muted); font-size: .9rem; }

/* Layout */
.container { max-width: 960px; margin: 1.5rem auto; padding: 0 1rem; }
.footer {
    max-width: 960px; margin: 2rem auto 3rem; padding: 1rem;
    color: var(--muted); font-size: .8rem; text-align: center;
}

/* Cards */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem; margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }

/* Flash messages */
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error   { background: var(--err-bg); color: var(--err); }
.flash-info    { background: #eaf1fe; color: var(--accent-dark); }

/* Forms */
form .field, .card .field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=tel], input[type=date], input[type=file],
select, textarea {
    width: 100%; padding: .55rem .65rem; border: 1px solid var(--line);
    border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input[type=file] { padding: .4rem .5rem; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47,111,237,.15);
}
.checkbox { display: flex; align-items: center; gap: .5rem; }
/* a small headline above a checkbox, styled like a field label */
.field-label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
fieldset.lockable { border: 0; margin: 0; padding: 0; }
fieldset.lockable:disabled { opacity: .7; }
.locked-banner {
    background: #fff7ed; border: 1px solid #fdba74; color: #9a3412;
    padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem;
}
.btn-lock { background: #16a34a; }
.btn-lock:hover { background: #15803d; }
.checkbox input { width: auto; }
.checkbox label { margin: 0; font-weight: 400; }

.btn {
    display: inline-block; background: var(--accent); color: #fff;
    border: none; border-radius: 8px; padding: .6rem 1.1rem;
    font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-secondary { background: #eef0f4; color: var(--ink); }
.btn-secondary:hover { background: #e2e5ea; }
.btn-danger { background: var(--err); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }

/* Login */
.login-wrap { max-width: 380px; margin: 4rem auto; }
.login-wrap .card { padding: 1.75rem; }
.login-wrap h1 { font-size: 1.3rem; margin-top: 0; }

/* Events list */
.event-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.event-card .meta { color: var(--muted); font-size: .9rem; margin: .25rem 0; }
.badge {
    display: inline-block; background: #eef1fe; color: var(--accent-dark);
    border-radius: 999px; padding: .1rem .6rem; font-size: .78rem; margin: 0 .25rem .25rem 0;
}
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-soon { background: var(--warn-bg); color: var(--warn); }
.badge-overdue { background: #fee2e2; color: #b91c1c; }
.deadline-item { display: inline-flex; align-items: center; gap: .35rem; margin-right: .6rem; }

/* Event nav */
.event-head { margin-bottom: .5rem; }
.event-head h1 { margin: .3rem 0 .2rem; font-size: 1.4rem; }
.event-meta { color: var(--muted); margin: 0 0 .5rem; font-size: .9rem; }
.back-link { font-size: .85rem; color: var(--muted); }
.subnav {
    display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--line); padding-bottom: .25rem;
}
.subnav-item {
    padding: .45rem .8rem; border-radius: 8px 8px 0 0; color: var(--muted);
    font-size: .9rem; font-weight: 600;
}
.subnav-item:hover { background: #eef0f4; text-decoration: none; }
.subnav-item.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { color: var(--muted); font-weight: 600; }

/* Stats */
.stats { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat { flex: 1 1 140px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.stat .num { font-size: 1.6rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .85rem; }

.tasklist { list-style: none; padding: 0; margin: 0; }
.tasklist li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.tasklist li:last-child { border-bottom: none; }
.task-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.task-row .task-deadline { flex: 0 0 auto; text-align: right; }
.message-body { line-height: 1.6; }
.finalize-card { border: 2px solid #16a34a; }
.finalize-card h2 { margin-top: 0; }
/* Referent: name fields left, clickable profile photo right. */
.person-row { display: flex; gap: 1.25rem; align-items: flex-start; }
.person-row .person-fields { flex: 1 1 50%; min-width: 0; }
.person-row .person-photo { flex: 0 0 auto; width: 160px; text-align: center; }
.photo-button { padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; line-height: 0; overflow: hidden; }
.photo-button:hover { border-color: #16a34a; }
.photo-button:disabled { cursor: default; opacity: .7; }
.photo-button img { display: block; width: 150px; height: 150px; object-fit: cover; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
    .person-row { flex-direction: column; }
    .person-row .person-photo { width: 100%; text-align: left; }
}

/* Phone: country prefix select and number input side by side. The base rule
   sets width:100% on inputs/selects, which would make the select claim the whole
   row, so both get an explicit basis here. */
.phone-row { display: flex; flex-wrap: nowrap; gap: .5rem; align-items: center; }
.phone-row .phone-dial { flex: 0 0 14rem; width: 14rem; max-width: 45%; }
.phone-row .phone-number { flex: 1 1 auto; width: auto; min-width: 6rem; }
@media (max-width: 520px) {
    .phone-row { flex-wrap: wrap; }
    .phone-row .phone-dial { flex: 1 1 100%; width: 100%; max-width: none; }
    .phone-row .phone-number { flex: 1 1 100%; width: 100%; }
}
.req { color: #b91c1c; font-weight: 700; margin-left: .15rem; }
.section-title { margin: 2rem 0 .75rem; padding-bottom: .4rem; border-bottom: 2px solid var(--line); font-size: 1.15rem; }
.char-counter { margin: .25rem 0 0; text-align: right; font-variant-numeric: tabular-nums; }
.char-counter-warn { color: var(--warn, #b45309); }
.char-counter-full { color: #b91c1c; font-weight: 600; }
.message-body p { margin: 0 0 .8rem; }
.message-body ul, .message-body ol { margin: 0 0 .8rem 1.4rem; }
.message-body a { color: var(--link, #2563eb); text-decoration: underline; }
.message-body h3, .message-body h4, .message-body h5 { margin: 1rem 0 .5rem; }
.message-body blockquote { margin: 0 0 .8rem; padding-left: .9rem; border-left: 3px solid var(--line); color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt { margin-top: 1rem; }
.row-actions { display: flex; gap: .5rem; align-items: center; }
/* status badge sits to the right of the row's buttons */
.row-actions .row-badge { margin-left: auto; }
/* the ready badge shares the right-hand slot with the deadline badge */
.task-row .task-deadline { display: inline-flex; align-items: center; gap: .4rem; }
.inline-form { display: inline; }
