:root {
  color-scheme: light;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: #172b45;
  background: #f3f6fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --page: #f3f6fa;
  --surface: #fff;
  --surface-soft: #f7f9fc;
  --text: #172b45;
  --muted: #596b80;
  --line: #dce4ed;
  --accent: #24618b;
  --accent-dark: #194b70;
  --accent-soft: #eaf2f8;
  --shadow: 0 12px 32px rgb(34 51 77 / 6%);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; min-height: 100vh; background: var(--page); color: var(--text); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgb(36 97 139 / 35%); outline-offset: 2px;
}
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; display: flex; flex: 0 0 228px; flex-direction: column;
  width: 228px; height: 100vh; padding: 24px 15px 16px; border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 11px; margin: 0 5px 25px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 41px; height: 41px; place-items: center; border-radius: 13px; background: var(--accent-dark); color: #fff; font-size: 19px; font-weight: 800; letter-spacing: -.05em; }
.brand-text { display: grid; gap: 2px; }
.brand-text strong { font-size: 15px; letter-spacing: -.02em; }
.brand-text small { color: var(--muted); font-size: 12px; }
.site-label { display: flex; align-items: center; gap: 7px; margin: 0 10px 20px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.status-dot, .footer-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #51a17d; }
.navigation { display: grid; gap: 5px; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: #475b73; font-size: 12px; font-weight: 600; text-align: left; text-decoration: none; }
.nav-link > span:first-child { display: grid; width: 20px; place-items: center; color: #818da0; font-size: 17px; }
.nav-link:hover { background: var(--surface-soft); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-dark); }
.nav-link.active > span:first-child { color: var(--accent); }
.nav-count { margin-left: auto; color: #596b80; font-size: 12px; font-weight: 600; }
.sidebar-tools { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.sidebar-tools-label { margin: 0 10px 7px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.sidebar-footer { margin-top: auto; padding: 13px 5px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.sidebar-footer span { margin: 0 4px; color: var(--accent); }
main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 0 clamp(20px, 4vw, 56px); border-bottom: 1px solid var(--line); background: var(--surface); }
.breadcrumb { color: var(--muted); font-size: 12px; }
.breadcrumb .slash { margin: 0 9px; color: #c1c6ce; }
.breadcrumb strong { color: #273b54; font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; font-weight: 700; text-decoration: none; transition: background .15s, border-color .15s; }
.button-primary { background: var(--accent); color: #fff; box-shadow: 0 3px 8px rgb(36 97 139 / 15%); }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { border-color: var(--line); background: var(--surface); color: var(--accent-dark); }
.button-secondary:hover { background: var(--surface-soft); }
.page-content { width: min(100%, 1220px); margin: 0 auto; padding: 24px clamp(20px, 4vw, 56px) 22px; }
.welcome { position: relative; display: flex; min-height: 160px; align-items: center; overflow: hidden; padding: 22px 28px; border: 1px solid #dce5ed; border-radius: 12px; background: #edf3f8; }
.welcome-copy { position: relative; z-index: 1; }
.eyebrow { display: flex; align-items: center; gap: 7px; margin: 0 0 10px; color: #355f7d; font-size: 11px; font-weight: 800; letter-spacing: .11em; }
.eyebrow-dot { width: 6px; height: 6px; border-radius: 50%; background: #51a17d; }
.eyebrow-divider { color: #a4b7b4; }
h1 { margin: 0; color: #172f49; font-size: clamp(28px, 3.2vw, 36px); letter-spacing: -.055em; line-height: 1.12; }
h1 span { color: #24618b; }
.welcome-description { max-width: 500px; margin: 10px 0 0; color: #52677d; font-size: 14px; line-height: 1.5; }
.made-by { margin: 6px 0 0; color: #355f7d; font-size: 12px; font-weight: 700; }
.sop-data-message { margin: 14px 0; padding: 12px 14px; border: 1px solid #d3e2ed; border-radius: 8px; background: #eff5fa; color: #315d7c; font-size: 13px; line-height: 1.5; }
.sop-data-message[role="alert"] { border-color: #f0c7ca; background: #fff5f5; color: #a3212a; }
.welcome-graphic { position: absolute; top: 0; right: 7%; width: 220px; height: 220px; opacity: .25; }
.graphic-orbit { position: absolute; top: 31px; left: 30px; width: 155px; height: 155px; border: 1px solid #bfd2e1; border-radius: 50%; transform: rotate(-22deg) scaleY(.66); }
.orbit-two { top: 14px; left: 28px; transform: rotate(33deg) scaleY(.7); }
.graphic-core { position: absolute; top: 73px; left: 83px; display: grid; width: 52px; height: 52px; place-items: center; border: 1px solid #bfd2e1; border-radius: 16px; background: rgb(255 255 255 / 68%); color: var(--accent); font-size: 19px; font-weight: 750; transform: rotate(-8deg); box-shadow: 0 8px 18px rgb(35 76 112 / 9%); }
.graphic-star { position: absolute; color: #7d9eb7; }
.star-one { top: 36px; right: 23px; font-size: 25px; }
.star-two { bottom: 34px; left: 27px; color: #9ab3c7; font-size: 18px; }
.search-panel { margin: 16px 0 20px; }
.search-box { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; border: 1px solid #e0e5ea; border-radius: 9px; background: var(--surface); box-shadow: 0 4px 14px rgb(31 48 73 / 3%); }
.search-icon { color: #778699; font-size: 28px; line-height: 1; transform: rotate(-15deg); }
.search-box input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; }
.search-box input::placeholder { color: #9aa4b1; }
.search-box kbd { min-width: 22px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-family: inherit; font-size: 12px; text-align: center; }
.search-clear { display: grid; flex: 0 0 26px; width: 26px; height: 26px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: #edf2f1; color: #61716f; font-size: 17px; line-height: 1; }
.search-clear:hover { background: #dde7e5; color: #355c58; }
.search-clear[hidden] { display: none; }
.search-panel > p { display: none; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.section-heading h2 { margin: 0; color: #213851; font-size: 17px; letter-spacing: -.02em; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.category-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 11px; }
.category-card { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); text-align: left; transition: border-color .15s, box-shadow .15s; }
.category-card:hover { border-color: #c6d7d4; box-shadow: 0 4px 12px rgb(34 51 77 / 5%); }
.category-card.selected { border-color: #78a5c4; box-shadow: 0 0 0 2px rgb(36 97 139 / 10%); }
.category-icon { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border-radius: 8px; font-size: 15px; font-weight: 700; }
.category-info { display: grid; min-width: 0; gap: 4px; }
.category-name { overflow: hidden; color: #30455f; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.category-count { color: var(--muted); font-size: 11px; }
.links-section { margin-top: 22px; }
.links-heading { align-items: center; }
.text-button { padding: 7px 5px; border: 0; background: transparent; color: var(--accent-dark); font-size: 12px; font-weight: 700; }
.text-button:hover { text-decoration: underline; }
.link-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 11px; }
.link-card { display: flex; min-width: 0; min-height: 98px; flex-direction: column; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.link-card:hover { border-color: #cbd9d7; box-shadow: 0 4px 12px rgb(34 51 77 / 5%); }
.link-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-edit-actions { display: flex; align-items: center; gap: 2px; }
.delete-link { color: #a46a70; }
.delete-link:hover { background: #fff1f2; color: #a4232d; }
.link-heading { display: flex; min-width: 0; align-items: center; gap: 8px; }
.link-card .category-icon { flex-basis: 26px; width: 26px; height: 26px; font-size: 12px; }
.link-title { overflow: hidden; margin: 0; color: #233a55; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.link-note { display: -webkit-box; overflow: hidden; min-height: 30px; margin: 5px 0 6px; color: #596b80; font-size: 11px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.link-note.empty-note { color: #a1aab5; font-style: italic; }
.link-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin-top: auto; padding-top: 4px; border-top: 1px solid #f0f2f5; }
.link-meta { display: flex; min-width: 0; align-items: center; gap: 7px; }
.category-label { color: #596b80; font-size: 10px; }
.link-status { padding: 2px 6px; border-radius: 10px; background: #edf2f6; color: #4f657c; font-size: 10px; font-weight: 650; white-space: nowrap; }
.link-status.status-active { background: #e8f2ed; color: #276247; }
.link-status.status-under-review { background: #fff2df; color: #93601f; }
.link-status.status-archived { background: #eef0f3; color: #667085; }
.card-actions { display: flex; align-items: center; gap: 4px; }
.open-link { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-dark); font-size: 11px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.open-link:hover { text-decoration: underline; }
.icon-button { display: inline-grid; flex: 0 0 30px; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 6px; background: transparent; color: #8a95a4; font-size: 17px; }
.icon-button:hover { background: #f0f5f4; color: var(--accent-dark); }
.empty-state { margin-top: 14px; padding: 39px 18px; border: 1px dashed #dbe2e8; border-radius: 10px; background: rgb(255 255 255 / 42%); color: #7d899a; text-align: center; }
.empty-icon { display: inline-grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: var(--accent-soft); color: var(--accent); font-size: 21px; }
.empty-state h3 { margin: 12px 0 5px; color: #2a405a; font-size: 17px; }
.empty-state p { margin: 0 0 16px; font-size: 13px; }
.page-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 35px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.footer-dot { width: 6px; height: 6px; margin-right: 5px; vertical-align: 1px; }
.footer-separator { margin: 0 4px; color: #9aa8b7; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

dialog { width: min(460px, calc(100vw - 28px)); max-height: 92vh; padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgb(17 28 51 / 25%); }
dialog::backdrop { background: rgb(24 34 52 / 45%); backdrop-filter: blur(2px); }
dialog form { padding: 24px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dialog-heading .eyebrow { margin-bottom: 7px; font-size: 11px; }
.dialog-heading h2 { margin: 0; color: #233a55; font-size: 20px; letter-spacing: -.04em; }
.icon-button.close { font-size: 23px; }
.form-intro { margin: 8px 0 19px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.field { display: grid; gap: 6px; margin-top: 13px; color: #344a63; font-size: 13px; font-weight: 700; }
.field > span:first-of-type { color: #b34448; }
.field .optional { color: var(--muted); font-size: 12px; font-weight: 400; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 400; }
.field textarea { min-height: 72px; resize: vertical; line-height: 1.5; }
.field input::placeholder, .field textarea::placeholder { color: #a0a9b5; }
.form-error { min-height: 0; margin: 7px 0 0; color: #b4232d; font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--line); }
.toast { position: fixed; z-index: 5; right: 20px; bottom: 18px; max-width: min(370px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 8px; background: #20364e; color: #fff; font-size: 13px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .sidebar { flex-basis: 220px; width: 220px; }
  .category-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .link-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: static; display: block; width: 100%; height: auto; padding: 12px 16px 9px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 3px 11px; }
  .brand-mark { width: 36px; height: 36px; }
  .site-label, .sidebar-footer { display: none; }
  body.home-page .navigation { display: none; }
  .navigation { display: flex; gap: 4px; overflow: visible; }
  .nav-link { flex: 0 1 auto; min-height: 36px; padding: 0 9px; white-space: nowrap; }
  .nav-link > span:first-child { width: auto; }
  .sidebar-tools { display: flex; align-items: center; gap: 5px; margin-top: 8px; padding-top: 8px; overflow-x: auto; }
  .sidebar-tools-label { flex: 0 0 auto; margin: 0 4px 0 2px; }
  .sidebar-tools .nav-link { flex: 0 0 auto; }
  .topbar { min-height: 57px; padding: 0 17px; }
  .topbar-actions { gap: 6px; }
  .page-content { padding: 20px 17px; }
  .welcome { min-height: 164px; padding: 21px; }
  .welcome-graphic { right: -43px; opacity: .14; }
  .welcome-description { max-width: 350px; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .category-card { gap: 8px; padding: 10px 9px; }
  .category-name { font-size: 12px; }
}
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding-top: 9px; padding-bottom: 9px; }
  .topbar-actions { margin-left: auto; }
}
@media (max-width: 460px) {
  .eyebrow { font-size: 9px; letter-spacing: .06em; }
  .eyebrow-divider { display: none; }
  .welcome-graphic { display: none; }
  .welcome-description { max-width: 260px; }
  .link-grid { grid-template-columns: 1fr; }
  .page-footer { flex-direction: column; }
  .breadcrumb { font-size: 11px; }
  .button { min-height: 38px; padding: 0 10px; font-size: 12px; }
  dialog form { padding: 20px 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
