:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #616e7c;
    --border: #d9e2ec;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --error: #b42318;
    --error-bg: #fef3f2;
    --warning: #93370d;
    --warning-bg: #fffaeb;
    --success: #067647;
    --success-bg: #ecfdf3;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}
[hidden] { display: none !important; }
a { color: var(--primary); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 24px; padding-bottom: 120px; }
.is-admin main.container { max-width: 1200px; padding-bottom: 48px; }
.is-admin .site-header .container { max-width: 1200px; }

/* Header */
.site-header { background: #0f172a; color: #fff; }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .01em; }
.site-nav { display: flex; align-items: center; gap: 20px; font-size: .95rem; }
.site-nav a, .link-button { color: #cbd5e1; text-decoration: none; }
.site-nav a:hover, .link-button:hover { color: #fff; }
.site-nav form { margin: 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* Cards & sections */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.intro { margin: 8px 0 24px; }
.section { margin-bottom: 32px; scroll-margin-top: 16px; }
.section__intro { color: var(--muted); margin: -.25rem 0 1rem; }
.message { max-width: 640px; margin: 40px auto; }

/* Resume banner */
.resume { background: var(--success-bg); border: 1px solid #abefc6; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; display: grid; gap: 10px; }
.resume--pending { display: block; background: #eff4ff; border-color: #c7d7fe; }
.resume__link { display: flex; gap: 8px; }
.resume__link input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; background: #fff; }

/* Form fields */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field--wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .95rem; }
.req { color: var(--error); }
.hint { margin: 0; font-size: .85rem; color: var(--muted); order: 1; }
.field label { order: 0; }
.field input, .field select, .field textarea { order: 2; }
.field-error { order: 3; margin: 0; color: var(--error); font-size: .85rem; font-weight: 500; }

input, select, textarea {
    width: 100%;
    font: inherit;
    color: inherit;
    padding: 9px 11px;
    border: 1px solid #b8c4d1;
    border-radius: 8px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 76px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 216, .18); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--error); }
.has-error input:focus, .has-error select:focus, .has-error textarea:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .15); }
input[readonly] { background: #f8fafc; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Principals */
.principal { position: relative; border: 1px solid var(--border); margin: 0 0 16px; min-width: 0; }
.principal__title { font-weight: 700; font-size: 1.05rem; padding: 0; float: left; margin-bottom: 16px; }
.principal .grid { clear: both; }
.principal__remove { position: absolute; top: 14px; right: 14px; }

/* Buttons */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-weight: 600; font-size: .95rem;
    padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    background: #e2e8f0; color: var(--text);
}
.button--primary { background: var(--primary); color: #fff; }
.button--primary:hover:not(:disabled) { background: var(--primary-dark); }
.button--secondary { background: #fff; border-color: #b8c4d1; color: var(--text); }
.button--secondary:hover { background: #f1f5f9; }
.button--ghost { background: transparent; color: var(--muted); }
.button--ghost:hover { color: var(--error); background: var(--error-bg); }
.button--small { padding: 6px 12px; font-size: .85rem; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Sticky footer bar */
.footer-bar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border); backdrop-filter: blur(6px); z-index: 10; }
.footer-bar__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.save-status { font-size: .9rem; color: var(--muted); }
.save-status--ok { color: var(--success); }
.save-status--error { color: var(--error); }

/* Alerts */
.alert { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; border: 1px solid; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert--error { background: var(--error-bg); border-color: #fecdca; color: var(--error); }
.alert--warning { background: var(--warning-bg); border-color: #fedf89; color: var(--warning); }
.alert--success { background: var(--success-bg); border-color: #abefc6; color: var(--success); }
.alert a { color: inherit; font-weight: 600; }
.review__section { margin: 10px 0 0; font-weight: 600; }
.review { background: var(--surface); border: 2px solid var(--primary); border-radius: var(--radius); padding: 20px; }
.confirm { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; font-weight: 500; }
.confirm input { width: auto; margin-top: 4px; }

/* Admin */
.login { max-width: 400px; margin: 48px auto; }
.login .field { margin-bottom: 14px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }
.back { margin: 0 0 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); border: 1px solid var(--border); background: #fff; font-size: .9rem; }
.tab.is-active { background: #0f172a; border-color: #0f172a; color: #fff; }
.count { opacity: .7; margin-left: 2px; }
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table__row { cursor: pointer; }
.table__row:hover { background: #f8fafc; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge--draft { background: #fef0c7; color: #93370d; }
.badge--submitted { background: #d1fadf; color: #05603a; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.summary h2 { font-size: 1.05rem; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.summary dl { margin: 0; }
.summary__row { display: grid; grid-template-columns: 40% 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid #eef2f6; }
.summary__row:last-child { border-bottom: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; overflow-wrap: anywhere; }
.summary__row.is-empty dd { color: #9aa5b1; font-style: italic; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: .9rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
aside .field { margin-bottom: 12px; }

/* Settings */
.settings { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.settings form > .grid { margin-bottom: 20px; }
.settings .card > form > .field { margin-bottom: 14px; }
.grid--tight { grid-template-columns: 1fr 1.6fr; gap: 12px; }
.choice { border: 0; padding: 0; margin: 0 0 20px; display: grid; gap: 8px; }
.choice legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.choice label { display: flex; gap: 10px; align-items: center; }
.choice input { width: auto; margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
.test-mail { border-top: 1px solid var(--border); padding-top: 16px; margin: 4px 0 20px; }
.test-mail__row { display: flex; gap: 10px; align-items: flex-end; margin-top: 10px; }
.test-mail__row .field { flex: 1; }
.test-mail .alert { margin: 12px 0 0; }

@media (max-width: 900px) {
    .settings { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .test-mail__row { flex-direction: column; align-items: stretch; }
    h1 { font-size: 1.35rem; }
    .grid { grid-template-columns: 1fr; }
    .card { padding: 16px; }
    .admin-grid { grid-template-columns: 1fr; }
    .summary__row { grid-template-columns: 1fr; gap: 2px; }
    .resume__link { flex-direction: column; }
    .save-status { font-size: .8rem; }
}
