:root {
  --ink: #1d2522;
  --muted: #68736e;
  --paper: #f4f3ed;
  --surface: #fffefa;
  --line: #dcded5;
  --green: #176b4d;
  --green-soft: #dcece4;
  --coral: #e96c4c;
  --coral-soft: #f8ded6;
  --blue: #27749b;
  --blue-soft: #dcebf2;
  --yellow: #c28c19;
  --yellow-soft: #f4e9c9;
  --danger: #a53f35;
  --shadow: 0 14px 40px rgba(40, 48, 44, 0.08);
  --heading: "Bricolage Grotesque", sans-serif;
  --body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--body); font-size: 15px; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; }
svg { width: 18px; height: 18px; stroke-width: 1.9; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 30; padding: 10px 14px; background: var(--ink); color: white; }
.skip-link:focus { top: 16px; }
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 20px 20px; color: #edf2ee; background: #1d2924; }
.brand { display: flex; gap: 12px; align-items: center; margin: 0 8px 44px; text-decoration: none; font-family: var(--heading); font-weight: 700; line-height: 1.08; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #608174; color: #dbe9e2; background: #294137; font-size: 13px; }
nav { display: grid; gap: 6px; }
.nav-link { display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 6px; color: #aebeb7; text-decoration: none; font-size: 13px; font-weight: 600; }
.nav-link:hover, .nav-link.active { color: #fff; background: #2a3c34; }
.sidebar-footer { display: grid; gap: 12px; margin-top: auto; }
.access-indicator { display: flex; gap: 8px; align-items: center; color: #aebeb7; font-size: 12px; }
.access-indicator span { width: 8px; height: 8px; border-radius: 50%; background: #cda042; box-shadow: 0 0 0 4px rgba(205,160,66,.12); }
.access-indicator.unlocked span { background: #67bf92; }
main { width: min(1500px, 100%); padding: 48px clamp(24px, 5vw, 76px) 80px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 40px; padding-bottom: 34px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: var(--heading); letter-spacing: 0; }
h1 { max-width: 720px; font-size: clamp(38px, 5vw, 68px); line-height: .98; }
h2 { font-size: 27px; line-height: 1.2; }
h3 { font-size: 18px; line-height: 1.25; }
.lede { margin: 15px 0 0; color: var(--muted); }
.topbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; align-items: center; padding-top: 8px; }
.date-chip { white-space: nowrap; padding: 9px 12px; border: 1px solid var(--line); background: rgba(255,255,255,.45); font-size: 12px; }
.button, .icon-button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 40px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-size: 13px; font-weight: 700; }
.button { padding: 9px 14px; }
.button.primary { color: white; background: var(--green); }
.button.primary:hover { background: #0f5940; }
.button.secondary { border-color: var(--line); background: var(--surface); }
.button.ghost { border-color: rgba(140,153,147,.35); background: transparent; }
.sidebar .button.ghost { color: #edf2ee; }
.button.danger { color: var(--danger); border-color: #e6c2bd; background: #fff8f7; }
.full { width: 100%; }
.login-page { min-height: 100vh; background: var(--paper); }
.login-content { width: min(480px, 100%); min-height: 100vh; margin: 0 auto; padding: 48px 24px; display: flex; flex-direction: column; justify-content: center; }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 56px; font-family: var(--heading); font-weight: 700; line-height: 1.08; }
.login-panel { border-top: 3px solid var(--green); padding-top: 30px; }
.login-panel h1 { font-size: 42px; line-height: 1.1; }
.login-panel form { display: grid; gap: 18px; margin-top: 30px; }
.login-panel label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.login-panel .form-error { min-height: 20px; }
.login-panel button:disabled { opacity: .6; cursor: wait; }
.icon-button { width: 40px; padding: 0; border-color: var(--line); background: var(--surface); }
.icon-button:hover, .button.secondary:hover { border-color: #aeb6b1; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(39,116,155,.28); outline-offset: 2px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 28px 0 58px; }
.stat { position: relative; min-height: 130px; padding: 20px; overflow: hidden; border: 1px solid transparent; }
.stat span { display: block; margin-bottom: 15px; font-size: 12px; font-weight: 700; }
.stat strong { font-family: var(--heading); font-size: 35px; }
.stat svg { position: absolute; right: 17px; bottom: 17px; width: 26px; height: 26px; opacity: .52; }
.stat-coral { background: var(--coral-soft); border-color: #efc8bd; }
.stat-green { background: var(--green-soft); border-color: #bfd9cc; }
.stat-blue { background: var(--blue-soft); border-color: #bfd8e4; }
.stat-yellow { background: var(--yellow-soft); border-color: #e5d5a7; }
.content-section { margin-top: 62px; scroll-margin-top: 25px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 18px; }
.record-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.record-card, .course-row, .tool-row, .custom-section { border: 1px solid var(--line); background: var(--surface); box-shadow: 0 3px 0 rgba(46,55,50,.02); }
.record-card { display: flex; flex-direction: column; min-height: 240px; padding: 19px; }
.record-top, .row-actions { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.row-actions { justify-content: flex-end; }
.mini-action { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 4px; color: var(--muted); background: transparent; cursor: pointer; }
.mini-action:hover { color: var(--ink); background: #eeeee8; }
.mini-action.delete:hover { color: var(--danger); background: #fae8e5; }
.status, .level { display: inline-flex; align-items: center; width: fit-content; padding: 4px 8px; border-radius: 3px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.status-planned { color: #66551e; background: var(--yellow-soft); }
.status-in-progress { color: #195978; background: var(--blue-soft); }
.status-completed { color: #14573e; background: var(--green-soft); }
.record-card h3 { margin: 23px 0 4px; }
.provider, .note, .tool-comment { color: var(--muted); font-size: 12px; }
.note { margin: 13px 0; white-space: pre-line; }
.date-stack { display: grid; gap: 2px; margin-top: auto; padding-top: 17px; border-top: 1px solid var(--line); font-size: 11px; }
.date-history { color: #9b7168; }
.filter-row { display: flex; gap: 5px; margin-bottom: 13px; }
.filter { padding: 7px 12px; border: 1px solid transparent; border-radius: 4px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.filter:hover, .filter.active { color: var(--ink); border-color: var(--line); background: var(--surface); }
.course-list, .tool-list { display: grid; gap: 8px; }
.course-row { display: grid; grid-template-columns: minmax(180px, 1.2fr) 110px minmax(160px, 1fr) 70px auto; gap: 20px; align-items: center; padding: 15px 17px; }
.course-title a { font-weight: 700; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.course-title small { display: block; margin-top: 2px; color: var(--muted); }
.progress-wrap { display: grid; grid-template-columns: 1fr 42px; gap: 9px; align-items: center; }
.progress-track { height: 8px; overflow: hidden; border-radius: 8px; background: #e8e9e3; }
.progress-fill { display: block; height: 100%; border-radius: inherit; background: var(--coral); transition: width .45s ease; }
.progress-label { font-size: 11px; font-weight: 700; }
.course-hours { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.tool-row { display: grid; grid-template-columns: minmax(140px, .7fr) 120px minmax(220px, 1.5fr) auto; gap: 24px; align-items: center; padding: 15px 17px; }
.tool-row h3 { font-size: 15px; }
.level-beginner { color: #655b2a; background: #f2e9c9; }
.level-intermediate { color: #195978; background: var(--blue-soft); }
.level-advanced { color: #14573e; background: var(--green-soft); }
.level-expert { color: #7c352d; background: var(--coral-soft); }
.custom-list { display: grid; gap: 16px; }
.custom-section { padding: 20px; }
.custom-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.custom-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.custom-items { display: grid; }
.custom-item { display: grid; grid-template-columns: 28px minmax(180px, .8fr) 1.3fr auto; gap: 15px; align-items: center; min-height: 62px; padding: 11px 0; border-bottom: 1px solid #ecece6; }
.custom-item:last-child { border-bottom: 0; }
.check-button { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 1px solid #b9c0bb; border-radius: 3px; color: transparent; background: white; cursor: pointer; }
.check-button.checked { color: white; border-color: var(--green); background: var(--green); }
.item-completed { color: var(--muted); text-decoration: line-through; }
.kv-list { display: flex; flex-wrap: wrap; gap: 5px; }
.kv { padding: 3px 7px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 10px; }
.empty-state { display: grid; place-items: center; min-height: 130px; border: 1px dashed #c7cac2; color: var(--muted); background: rgba(255,255,255,.28); text-align: center; }
.empty-state svg { width: 24px; height: 24px; margin-bottom: 8px; }
.modal { width: min(620px, calc(100% - 30px)); max-height: calc(100vh - 40px); padding: 0; overflow: auto; border: 0; border-radius: 7px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(20,30,26,.64); backdrop-filter: blur(3px); }
.modal form { display: grid; gap: 19px; padding: 25px; }
.modal-small { width: min(420px, calc(100% - 30px)); }
.modal-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
label { display: grid; gap: 6px; color: #4d5853; font-size: 11px; font-weight: 700; }
label.span-2 { grid-column: 1 / -1; }
input, select, textarea { width: 100%; padding: 10px 11px; border: 1px solid #cbd0cb; border-radius: 4px; color: var(--ink); background: #fff; font-size: 13px; }
textarea { min-height: 90px; resize: vertical; }
.form-hint { margin: -2px 0 0; color: var(--muted); font-size: 10px; font-weight: 500; }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 5px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 40; max-width: 360px; padding: 12px 16px; transform: translateY(18px); opacity: 0; pointer-events: none; border-radius: 4px; color: white; background: #26352f; box-shadow: var(--shadow); transition: .2s ease; }
.toast.visible { transform: translateY(0); opacity: 1; }
.auth-only { display: none; }
body.authenticated .auth-only { display: inline-flex; }

@media (max-width: 1050px) {
  .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .course-row { grid-template-columns: 1fr 100px; gap: 12px 20px; }
  .course-row .course-hours { grid-column: 1; grid-row: 2; }
  .course-row .progress-wrap { grid-column: 1; grid-row: 3; }
  .course-row .row-actions { grid-column: 2; grid-row: 2 / 4; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; z-index: 20; width: 100%; height: auto; padding: 10px 14px; flex-direction: row; align-items: center; }
  .brand { margin: 0; }
  .brand > span:last-child, .nav-link span, .sidebar-footer .access-indicator { display: none; }
  .brand-mark { width: 38px; height: 38px; }
  nav { display: flex; margin-left: auto; }
  .nav-link { padding: 10px; }
  .sidebar-footer { display: block; margin: 0 0 0 6px; }
  .sidebar-footer .button { width: 40px; height: 40px; min-height: 40px; padding: 0; }
  .sidebar-footer .button span { display: none; }
  main { padding: 30px 16px 65px; }
  .topbar { display: block; }
  h1 { font-size: 42px; }
  .topbar-actions { justify-content: flex-start; margin-top: 22px; }
  .stats-grid { margin-bottom: 46px; }
  .stat { min-height: 108px; }
  .record-grid { grid-template-columns: 1fr; }
  .tool-row { grid-template-columns: 1fr auto; gap: 10px; }
  .tool-row .tool-comment { grid-column: 1 / -1; }
  .custom-item { grid-template-columns: 28px 1fr auto; }
  .custom-item .kv-list { grid-column: 2 / -1; }
}

@media (max-width: 480px) {
  .stats-grid { gap: 8px; }
  .stat { min-height: 100px; padding: 14px; }
  .stat strong { font-size: 29px; }
  .date-chip { display: none; }
  .course-row { display: grid; grid-template-columns: 1fr auto; }
  .course-row .status { grid-column: 2; grid-row: 1; }
  .course-row .progress-wrap { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  label.span-2 { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}