/* PEF2 back office — single stylesheet. Modules use these classes only. */
:root {
  --bg: #f4f6f5; --surface: #ffffff; --surface-2: #f8faf9; --border: #dfe5e3; --border-strong: #c5cfcc;
  --text: #17201f; --text-2: #4b5957; --muted: #74827f;
  --primary: #0f5b58; --primary-hover: #0b4744; --primary-soft: #e3f0ee; --primary-text: #ffffff;
  --accent: #c7861c; --accent-soft: #fbf1df;
  --success: #1d7a46; --success-soft: #e2f4e9; --warning: #a76400; --warning-soft: #fff3dc;
  --danger: #b42828; --danger-soft: #fbe6e6; --info: #1f5f9e; --info-soft: #e5eef8;
  --sidebar: #0e2b2a; --sidebar-text: #c9d8d5; --sidebar-active: #1a4644;
  --radius: 8px; --radius-sm: 5px; --shadow: 0 1px 2px rgba(16, 40, 38, .06), 0 1px 1px rgba(16, 40, 38, .04);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; } .right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: #fff; text-decoration: none !important; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: #1b1300; font-weight: 800; display: grid; place-items: center; font-size: 13px; }
.brand-text { font-weight: 650; font-size: 15px; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a { color: var(--sidebar-text); padding: 8px 10px; border-radius: 6px; display: flex; gap: 10px; align-items: center; text-decoration: none; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-icon { width: 18px; text-align: center; opacity: .85; }
.sidebar-foot { padding: 14px 16px; }
.env-tag { font-size: 11px; color: #9fb6b2; border: 1px dashed #3b5e5b; border-radius: 6px; padding: 6px 8px; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.topbar-title { font-weight: 600; color: var(--text-2); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.locale-switch select { padding: 4px 6px; font-size: 12px; width: auto; }
.bell { position: relative; font-size: 17px; text-decoration: none !important; }
.bell-count { position: absolute; top: -6px; right: -10px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 10px; padding: 1px 5px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; gap: 9px; align-items: center; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: 11.5px; }
.user-dropdown { position: absolute; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.1); min-width: 180px; padding: 6px; display: flex; flex-direction: column; }
.user-dropdown a, .user-dropdown .linklike { padding: 8px 10px; border-radius: 5px; text-align: left; color: var(--text); }
.user-dropdown a:hover, .user-dropdown .linklike:hover { background: var(--surface-2); text-decoration: none; }
.content { padding: 24px; max-width: 1440px; width: 100%; }
body.bare { background: linear-gradient(160deg, #0e2b2a 0%, #13403e 55%, #1b524e 100%); min-height: 100vh; }
.bare-main { max-width: 440px; margin: 0 auto; padding: 8vh 16px 40px; }
.auth-card { background: var(--surface); border-radius: 12px; padding: 30px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-card h1 { margin-bottom: 6px; }
.auth-brand { display: flex; align-items: center; gap: 10px; color: #fff; margin-bottom: 18px; font-weight: 650; font-size: 18px; }

/* page structure */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header .subtitle { margin: 4px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-block; font-size: 12.5px; margin-bottom: 6px; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
@media (max-width: 1100px) { .grid-main, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) { .shell { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } .grid-2, .grid-main, .grid-3, .grid-4 { grid-template-columns: 1fr; } .content { padding: 16px; } .user-meta { display: none; } }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.card-actions { display: flex; gap: 6px; align-items: center; }
.card-body { padding: 16px; }
.card-body > .table-wrap { margin: -16px; }
.card + .card { margin-top: 0; }

/* stats */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-hint { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.stat-warning { border-left: 3px solid var(--warning); } .stat-danger { border-left: 3px solid var(--danger); } .stat-success { border-left: 3px solid var(--success); } .stat-accent { border-left: 3px solid var(--accent); } .stat-info { border-left: 3px solid var(--info); }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafcfb; }
.table.compact td { padding: 6px 10px; }
.empty-cell { text-align: center; color: var(--muted); padding: 28px !important; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-neutral { background: #eef1f0; color: #4b5957; } .badge-info { background: var(--info-soft); color: var(--info); }
.badge-success { background: var(--success-soft); color: var(--success); } .badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); } .badge-accent { background: var(--accent-soft); color: #8a5a0c; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; border: 1px solid transparent; text-decoration: none !important; white-space: nowrap; line-height: 1.2; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-primary { background: var(--primary); color: var(--primary-text); } .btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); } .btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--primary); } .btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: #fff; } .btn-danger:hover { background: #962020; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn.confirming { background: var(--warning); color: #fff; border-color: var(--warning); }
.linklike { background: none; border: none; font: inherit; color: var(--primary); cursor: pointer; padding: 0; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.reason-input { width: 200px; padding: 5px 8px !important; font-size: 12.5px !important; }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-top: 8px; grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.field .req { color: var(--danger); margin-left: 3px; }
.field .help { color: var(--muted); font-size: 12px; }
.field .error-text { color: var(--danger); font-size: 12px; font-weight: 500; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); background: #fffafa; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=url], input[type=file], input:not([type]), select, textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 91, 88, .25); border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--primary); }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 150px; }
.filters input, .filters select { padding: 6px 8px; }

/* alerts */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.alert-info { background: var(--info-soft); border-color: #bcd3ec; color: #19466f; }
.alert-success { background: var(--success-soft); border-color: #b7e0c6; color: #145a33; }
.alert-warning { background: var(--warning-soft); border-color: #f0d49c; color: #7a4a00; }
.alert-error { background: var(--danger-soft); border-color: #f1c0c0; color: #8c1d1d; }
.alert ul { margin: 6px 0 0; padding-left: 20px; font-weight: 400; }

/* key/values */
.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none !important; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { margin-left: 6px; background: #eef1f0; color: var(--text-2); border-radius: 10px; padding: 0 6px; font-size: 11px; }

/* stepper */
.stepper { list-style: none; padding: 0; margin: 0 0 18px; display: flex; gap: 0; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 10px; }
.stepper li { flex: 1; min-width: 92px; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; text-align: center; }
.stepper li::before { content: ""; position: absolute; top: 12px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper li.done::before, .stepper li.current::before { background: var(--primary); }
.step-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; z-index: 1; color: var(--muted); }
.stepper li.done .step-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.stepper li.current .step-dot { border-color: var(--accent); background: var(--accent); color: #1b1300; box-shadow: 0 0 0 4px var(--accent-soft); }
.step-label { font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.stepper li.current .step-label { color: var(--text); }

/* misc */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty-state h3 { margin-bottom: 6px; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 0 0; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: none; }
.check-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.check-ok { background: var(--success-soft); color: var(--success); } .check-missing { background: var(--danger-soft); color: var(--danger); } .check-pending { background: var(--warning-soft); color: var(--warning); } .check-optional { background: #eef1f0; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.timeline li { padding: 0 0 14px 16px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline .when { font-size: 12px; color: var(--muted); }
.progress { height: 8px; border-radius: 6px; background: #e7ecea; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.progress.warn > span { background: var(--warning); } .progress.danger > span { background: var(--danger); }
pre.code { background: #0e2b2a; color: #d7e7e4; padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 12px; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--text-2); background: var(--surface-2); }
.split { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
details.disclosure > summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.htmx-indicator { opacity: 0; transition: opacity .2s; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
@media print { .sidebar, .topbar, .page-actions, .no-print { display: none !important; } .shell { display: block; } body { background: #fff; } .card { box-shadow: none; } }
.check-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
