:root {
  --orange: #f46a08;
  --orange-dark: #d95100;
  --orange-soft: #fff1e7;
  --ink: #172033;
  --muted: #6c7484;
  --line: #e4e7ed;
  --surface: #ffffff;
  --background: #f5f6f8;
  --success: #16865c;
  --success-soft: #e8f7f0;
  --warning: #b66a00;
  --warning-soft: #fff4d9;
  --danger: #c43d3d;
  --danger-soft: #fdecec;
  --shadow: 0 18px 45px rgba(28, 36, 52, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--background); }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }

.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand img { width: 46px; height: 46px; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 1.05rem; letter-spacing: .04em; }
.brand small { margin-top: 4px; color: var(--muted); font-weight: 600; }

.button { border: 0; border-radius: 11px; padding: 11px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; cursor: pointer; transition: .2s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.button-primary { background: var(--orange); color: #fff; box-shadow: 0 8px 18px rgba(244, 106, 8, .22); }
.button-primary:hover { background: var(--orange-dark); }
.button-secondary { background: #eef0f4; color: var(--ink); }
.button-ghost { border: 1px solid var(--line); background: #fff; }
.button-block { width: 100%; }
.button-group { display: flex; flex-wrap: wrap; gap: 10px; }

input, select { width: 100%; padding: 12px 13px; border: 1px solid #d9dde5; border-radius: 11px; background: #fff; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(244, 106, 8, .12); }
label, legend { display: block; margin-bottom: 7px; font-size: .9rem; font-weight: 750; }
small { color: var(--muted); }

.alert { margin: 0 0 18px; padding: 13px 15px; border-radius: 12px; font-weight: 650; }
.alert-success { color: var(--success); background: var(--success-soft); }
.alert-warning { color: var(--warning); background: var(--warning-soft); }
.alert-danger { color: var(--danger); background: var(--danger-soft); }

.public-body { background: radial-gradient(circle at 10% 0, #fff4e9, transparent 32%), var(--background); }
.public-header { max-width: 1180px; margin: 0 auto; padding: 24px 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.public-main { max-width: 1180px; margin: 0 auto; padding: 12px 28px 55px; }
.hero-card { min-height: 218px; padding: 38px 42px; border-radius: 26px; display: flex; align-items: center; justify-content: space-between; gap: 30px; color: #fff; background: linear-gradient(125deg, #141b28, #2b3546 65%, #3c2418); box-shadow: var(--shadow); overflow: hidden; }
.hero-card h1 { max-width: 720px; margin-bottom: 12px; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.035em; line-height: 1.04; }
.hero-card p { color: #d9dce2; font-size: 1.04rem; }
.hero-icon { width: 120px; height: 120px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.17); border-radius: 30px; background: rgba(255,255,255,.08); color: #ff8d3d; font-size: 3.7rem; transform: rotate(-3deg); }
.eyebrow { display: inline-block; margin-bottom: 14px; color: #ff9e5c; font-size: .75rem; font-weight: 850; text-transform: uppercase; letter-spacing: .16em; }
.training-picker { margin: 22px 0 0; max-width: 520px; }
.signature-layout { margin-top: 25px; display: grid; grid-template-columns: .88fr 1.12fr; gap: 22px; align-items: start; }
.panel, .content-card { background: var(--surface); border: 1px solid rgba(219, 223, 231, .85); border-radius: var(--radius); box-shadow: 0 10px 34px rgba(26, 35, 49, .055); }
.panel { padding: 26px; }
.panel-heading { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 22px; }
.panel-heading h2 { margin-bottom: 5px; font-size: 1.25rem; }
.panel-heading p { margin: 0; color: var(--muted); }
.step { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--orange); font-weight: 850; }
.search-box { position: relative; }
.search-box input { padding-right: 42px; }
.search-box span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 1.3rem; color: var(--muted); }
.label-secondary { margin-top: 15px; }
.search-results { display: grid; gap: 8px; margin-top: 14px; max-height: 360px; overflow: auto; }
.employee-result { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; background: #fff; display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; text-align: left; }
.employee-result:hover { border-color: var(--orange); background: var(--orange-soft); }
.employee-result span { display: flex; flex-direction: column; gap: 3px; }
.employee-result small { font-size: .78rem; }
.employee-result em { color: var(--orange-dark); font-size: .78rem; font-style: normal; font-weight: 800; }
.employee-result.signed { opacity: .65; cursor: not-allowed; }
.employee-result.signed em { color: var(--success); }
.search-empty { padding: 14px; border-radius: 11px; background: #f5f6f8; color: var(--muted); text-align: center; }
.search-empty.error { color: var(--danger); background: var(--danger-soft); }
.sign-panel { transition: opacity .2s, filter .2s; }
.sign-panel.is-disabled { opacity: .58; filter: grayscale(.25); pointer-events: none; }
.status-fieldset { border: 0; padding: 0; margin: 0 0 20px; display: flex; gap: 12px; }
.status-fieldset legend { width: 100%; }
.status-fieldset label { margin: 0; flex: 1; }
.status-fieldset input { position: absolute; opacity: 0; width: 1px; }
.status-fieldset span { display: block; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; text-align: center; cursor: pointer; }
.status-fieldset input:checked + span { color: var(--orange-dark); border-color: var(--orange); background: var(--orange-soft); }
.canvas-wrap { position: relative; height: 220px; border: 2px dashed #cdd2dc; border-radius: 14px; background: linear-gradient(#fff, #fbfbfc); overflow: hidden; touch-action: none; }
#signature-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.signature-line { position: absolute; left: 12%; right: 12%; bottom: 36px; border-top: 1px solid #b7bdc8; padding-top: 5px; color: #989fab; text-align: center; font-size: .74rem; pointer-events: none; }
.action-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.inline-message { margin-top: 14px; padding: 11px 13px; border-radius: 10px; font-weight: 700; }
.inline-message.success { color: var(--success); background: var(--success-soft); }
.inline-message.error { color: var(--danger); background: var(--danger-soft); }
.inline-message.info { color: #315b8e; background: #eaf2fd; }
.public-footer { max-width: 1180px; margin: 0 auto; padding: 0 28px 35px; color: var(--muted); font-size: .83rem; text-align: center; }
.empty-state { margin-top: 24px; padding: 45px; background: #fff; border: 1px dashed #cbd0d9; border-radius: var(--radius); text-align: center; }
.empty-state.compact { margin: 0; padding: 25px; }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #fff0e5, transparent 35%), #f3f4f6; }
.login-card { width: min(100%, 440px); padding: 34px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-brand { margin-bottom: 30px; }
.login-card h1 { margin-bottom: 7px; font-size: 2rem; }
.login-card > p { margin-bottom: 24px; color: var(--muted); }
.stack-form { display: grid; gap: 11px; }
.stack-form .button { margin-top: 7px; }
.back-link { display: inline-block; margin-top: 18px; color: var(--muted); font-size: .88rem; font-weight: 700; }

.admin-body { background: #f4f5f7; }
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: #151c28; color: #fff; display: flex; flex-direction: column; z-index: 20; }
.sidebar .brand { padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand small { color: #9ea6b5; }
.nav-list { display: grid; gap: 6px; margin-top: 25px; }
.nav-list a { padding: 12px 13px; border-radius: 10px; color: #d7dbe3; font-weight: 650; }
.nav-list a:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar-user { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 7px; }
.sidebar-user span { font-weight: 750; }
.sidebar-user a { color: #ff9a55; font-size: .85rem; }
.admin-main { min-width: 0; padding: 26px 30px 50px; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.topbar h1 { margin: 0 0 3px; font-size: 1.8rem; }
.topbar p { margin: 0; color: var(--muted); }
.menu-button { display: none; width: 42px; height: 42px; border: 0; border-radius: 10px; background: #fff; box-shadow: 0 4px 15px rgba(0,0,0,.06); }
.admin-footer { padding-top: 30px; color: var(--muted); font-size: .8rem; text-align: center; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats-grid-small { margin: 20px 0; }
.stat-card { min-height: 130px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: #fff; display: flex; flex-direction: column; justify-content: center; box-shadow: 0 8px 26px rgba(26, 35, 49, .04); }
.stat-card span { color: var(--muted); font-size: .84rem; font-weight: 700; }
.stat-card strong { margin: 7px 0 2px; font-size: 2rem; line-height: 1; }
.stat-card small { font-size: .76rem; }
.content-card { padding: 24px; margin-bottom: 20px; }
.narrow-card { max-width: 820px; }
.card-header { margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.card-header.wrap { flex-wrap: wrap; }
.card-header h2 { margin: 0 0 5px; font-size: 1.25rem; }
.card-header p { margin: 0; color: var(--muted); }
.training-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.training-card { padding: 19px; border: 1px solid var(--line); border-radius: 15px; }
.training-title-row, .metric-row, .progress-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.training-title-row h3 { margin: 0 0 5px; }
.metric-row { margin: 19px 0 11px; color: var(--muted); font-size: .8rem; flex-wrap: wrap; }
.metric-row strong { color: var(--ink); }
.progress { height: 9px; border-radius: 99px; background: #eceef2; overflow: hidden; }
.progress.large { height: 13px; margin: 5px 0 24px; }
.progress span { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--orange), #ff9a42); }
.progress-label { margin-top: 7px; color: var(--muted); font-size: .78rem; }
.progress-label strong { color: var(--orange-dark); }
.text-link { color: var(--orange-dark); font-weight: 800; font-size: .86rem; }
.badge { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-muted { color: #697182; background: #eef0f3; }
.upload-form { display: grid; grid-template-columns: 1fr 1.15fr auto; gap: 14px; align-items: end; }
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th, .data-table td { padding: 13px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.data-table td small { display: block; margin-top: 4px; }
.table-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.table-actions form { margin: 0; }
.table-actions button, .text-button { border: 0; padding: 0; background: none; color: var(--ink); cursor: pointer; font: inherit; font-weight: 700; }
.danger-link { color: var(--danger) !important; }
.table-tools { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.table-tools input { max-width: 380px; }
.table-tools span { color: var(--muted); font-size: .8rem; }
.two-column { display: grid; grid-template-columns: .8fr 1.2fr; gap: 20px; align-items: start; }
.requirements-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.requirements-grid > div { padding: 12px; border: 1px solid var(--line); border-radius: 11px; display: flex; align-items: center; gap: 9px; }
.requirements-grid strong { margin-left: auto; font-size: .78rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { background: var(--success); }
.status-dot.error { background: var(--danger); }
.export-heading { margin: 20px 0; display: flex; align-items: center; gap: 16px; }
.export-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 15px; color: #fff; background: var(--orange); font-size: 1.7rem; }
.export-heading h2 { margin-bottom: 4px; }
.export-heading p { margin: 0; color: var(--muted); }
.export-summary { display: flex; gap: 20px; padding: 14px 0 21px; border-bottom: 1px solid var(--line); color: var(--muted); }
.export-summary strong { color: var(--ink); }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 22px; }
.export-option { padding: 19px; border: 1px solid var(--line); border-radius: 15px; display: flex; gap: 14px; align-items: flex-start; }
.export-option:hover { border-color: var(--orange); background: var(--orange-soft); }
.export-option div { display: flex; flex-direction: column; gap: 5px; }
.file-type { flex: 0 0 auto; padding: 7px 8px; border-radius: 8px; background: #e9f1ff; color: #275a99; font-size: .7rem; font-weight: 900; }
.file-type.pdf { color: #9b2d2d; background: #fdeaea; }

@media (max-width: 980px) {
  .signature-layout, .two-column { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .training-cards { grid-template-columns: 1fr; }
  .upload-form { grid-template-columns: 1fr; }
  .admin-shell { display: block; }
  .sidebar { position: fixed; left: -270px; width: 250px; transition: left .2s ease; box-shadow: 20px 0 40px rgba(0,0,0,.18); }
  .sidebar.is-open { left: 0; }
  .menu-button { display: inline-grid; place-items: center; }
}

@media (max-width: 680px) {
  .public-header { padding: 18px; }
  .public-header .button { display: none; }
  .public-main { padding: 6px 16px 38px; }
  .hero-card { min-height: auto; padding: 27px 23px; border-radius: 20px; }
  .hero-icon { display: none; }
  .panel { padding: 20px; }
  .action-row { flex-direction: column-reverse; }
  .action-row .button { width: 100%; }
  .status-fieldset { flex-direction: column; }
  .admin-main { padding: 20px 14px 40px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 105px; padding: 15px; }
  .stat-card strong { font-size: 1.55rem; }
  .content-card { padding: 17px; }
  .card-header { align-items: flex-start; flex-direction: column; }
  .requirements-grid, .export-grid { grid-template-columns: 1fr; }
  .export-summary { flex-direction: column; gap: 7px; }
  .topbar p { display: none; }
  .topbar h1 { font-size: 1.45rem; }
}
