/* NF System screens. Uses only variables from tokens.css. */
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: var(--text-md); color: var(--text); background: var(--bg); line-height: 1.45; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
h1 { font-size: var(--text-xl); margin: 0; }
h2 { font-size: var(--text-lg); margin: 0 0 var(--space-3); }
h3 { font-size: var(--text-md); margin: 0 0 var(--space-2); }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.eyebrow { font-size: var(--text-xs); font-weight: 600; letter-spacing: .06em; color: var(--muted); }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; flex: 0 0 260px; background: var(--surface); border-right: 1px solid var(--border); padding: var(--space-5) var(--space-4); display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; flex-direction: column; margin-bottom: var(--space-4); }
.sidebar .title { font-size: var(--text-lg); font-weight: 700; }
.sidebar a { display: flex; justify-content: space-between; align-items: center; min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--radius); text-decoration: none; color: var(--text); font-weight: 500; }
.sidebar a:hover { background: var(--bg); color: var(--text); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.sidebar .count { font-weight: 700; font-size: var(--text-sm); }
.nav-group { margin-top: var(--space-4); padding: var(--space-2) var(--space-3) var(--space-1); font-size: var(--text-xs); font-weight: 600; color: var(--muted); }
.nav-soon { padding: var(--space-1) var(--space-3); font-size: var(--text-sm); color: var(--muted); }
.nav-foot { margin-top: auto; padding: var(--space-4) var(--space-3) 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); }
.main { flex: 1; min-width: 0; padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); outline: none; }

/* Building blocks */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--space-3); }
.crumbs { font-size: var(--text-sm); color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); }
.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stats { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { font-size: var(--text-sm); color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.list li { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
dl.facts { display: grid; grid-template-columns: 180px 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
dl.facts dt { color: var(--muted); font-size: var(--text-sm); }
dl.facts dd { margin: 0; white-space: pre-line; }
.prose { white-space: pre-line; }

/* Table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: var(--text-xs); color: var(--muted); font-weight: 600; background: var(--bg); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FAFAF8; }
td a.name { font-weight: 600; text-decoration: none; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.fit { font-weight: 700; }
.fit small { font-weight: 400; color: var(--muted); }

/* Forms and buttons */
.form { display: flex; flex-direction: column; gap: var(--space-3); }
.form-grid { display: grid; gap: var(--space-3) var(--space-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
label { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); font-weight: 600; }
label.check { flex-direction: row; align-items: center; font-weight: 500; }
input, select, textarea { font: inherit; font-weight: 400; padding: 10px 12px; min-height: var(--tap); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { font: inherit; font-weight: 600; min-height: var(--tap); padding: 0 var(--space-4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: var(--space-2); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 34px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-align: left; }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: end; }
.filters label { min-width: 160px; }
.error { color: var(--bad); font-size: var(--text-sm); margin: 0; }

/* Tabs */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs button { font: inherit; font-weight: 600; background: none; border: 0; border-bottom: 2px solid transparent; padding: var(--space-3) var(--space-3); color: var(--muted); cursor: pointer; min-height: var(--tap); }
.tabs button.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

/* Notices */
.notice { padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--info-soft); color: var(--info); font-size: var(--text-sm); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.empty { padding: var(--space-5); text-align: center; color: var(--muted); }
#toast { position: fixed; bottom: var(--space-5); right: var(--space-5); background: var(--text); color: #fff; padding: var(--space-3) var(--space-4); border-radius: var(--radius); font-size: var(--text-sm); opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 420px; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: var(--space-4); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); }
.login-card .brand { display: flex; flex-direction: column; gap: 2px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: var(--space-3); }
  .sidebar .brand, .nav-group, .nav-soon { display: none; }
  .nav-foot { margin: 0; border: 0; padding: 0 var(--space-3); flex-direction: row; align-items: center; gap: var(--space-3); }
  .main { padding: var(--space-4); }
  dl.facts { grid-template-columns: 1fr; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }


#nav-pillars details > summary { display: block; cursor: pointer; list-style: none; border-radius: var(--radius); }
#nav-pillars details > summary::-webkit-details-marker { display: none; }
#nav-pillars details > summary::marker { content: ''; }
#nav-pillars details > summary:hover { background: var(--bg); }
#nav-pillars .sum { display: grid; grid-template-columns: 14px auto 1fr; column-gap: 6px; align-items: baseline; padding: 8px var(--space-3); line-height: 1.3; }
#nav-pillars .chev { width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; align-self: start; margin: 5px 0 0 2px; }
#nav-pillars details[open] > summary .chev { transform: rotate(45deg); }
#nav-pillars .nav-dept { margin-top: var(--space-3); }
#nav-pillars .nav-dept > summary { font-weight: 700; color: var(--accent-strong); }
#nav-pillars .nav-dept > summary .sum { grid-template-columns: 14px 1fr; }
#nav-pillars .nav-dept > .nav-kids { display: flex; flex-direction: column; gap: 2px; }
#nav-pillars .nav-pillar > summary { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
#nav-pillars .nav-pillar[open] > summary { background: var(--bg); }
#nav-pillars .nav-code { font-weight: 600; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 26px; }
#nav-pillars .nav-pillar > summary .nav-code { color: var(--accent-strong); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; min-width: 0; }
#nav-pillars .nav-pillar > .nav-kids { margin: 4px 0 8px 22px; padding-left: 6px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 1px; }
#nav-pillars .nav-pillar a.nav-area { display: grid; grid-template-columns: 30px 1fr; align-items: baseline; padding: 6px var(--space-2); min-height: 0; font-size: var(--text-sm); font-weight: 400; line-height: 1.3; border-radius: var(--radius); }

#nav-pillars .nav-dept > .nav-kids > a.nav-area { margin-left: 22px; padding: 6px var(--space-2); min-height: 0; font-size: var(--text-sm); font-weight: 500; line-height: 1.3; border-left: 2px solid var(--border); border-radius: 0 var(--radius) var(--radius) 0; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: var(--text-sm); }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }

#upbox { position: fixed; right: 16px; bottom: 16px; width: min(340px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: 12px 14px; z-index: 1000; display: none; }
#upbox.show { display: block; }
#upbox .up-name { font-weight: 600; font-size: var(--text-sm); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#upbox .progress { height: 8px; }
#upbox .up-info { margin-top: 6px; color: var(--muted); }
#upbox.bad .progress span { background: var(--bad); } #upbox.bad .up-name { color: var(--bad); }

.btn.danger { color: var(--bad); border-color: var(--bad-soft); } .btn.danger:hover { background: var(--bad-soft); }
