/* shell.css — modern console chrome (sidebar + topbar + dashboard) around the
 * faithful AS/400 screens. The メニュー体系 is preserved; only navigation/observability
 * are added. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --nav-bg: #0f172a;
  --nav-bg2: #1e293b;
  --nav-ink: #cbd5e1;
  --nav-ink-dim: #7c8aa0;
  --nav-active: #2563eb;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-weak: #e8f0fe;
  --ok: #16a34a;
  --warn: #d97706;
  --sidebar-w: 290px;
}
html, body { height: 100%; }
body {
  font-family: "Noto Sans JP", -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "brand topbar" "sidebar main";
  height: 100vh;
  overflow: hidden;
}
body.nav-collapsed { --sidebar-w: 0px; }

/* ── brand corner ───────────────────────────────────────────── */
.brand {
  grid-area: brand;
  background: var(--nav-bg);
  color: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-right: 1px solid var(--nav-bg2);
  overflow: hidden; white-space: nowrap;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 7px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none;
}
.brand .name { font-weight: 700; font-size: 15px; }
.brand .sub { font-size: 10px; color: var(--nav-ink-dim); }

/* ── topbar ─────────────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
}
.icon-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 16px;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg); }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.crumbs .sep { color: #cbd5e1; }
.crumbs .grp { color: var(--muted); }
.crumbs .cur { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .pid {
  font: 11px ui-monospace, monospace; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px;
}
.topbar .spacer { flex: 1; }
.status { display: flex; align-items: center; gap: 16px; font-size: 12.5px; color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; margin-right: 5px; box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.status .dot.bad { background: var(--warn); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }
.status b { color: var(--ink); font-weight: 600; }
.status .clock { font-variant-numeric: tabular-nums; }
.status a { color: var(--accent); text-decoration: none; }

/* ── sidebar ────────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--nav-bg);
  color: var(--nav-ink);
  overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid var(--nav-bg2);
}
body.nav-collapsed .sidebar, body.nav-collapsed .brand { display: none; }
body.nav-collapsed { grid-template-columns: 0 1fr; }
.nav-search { padding: 12px; position: sticky; top: 0; background: var(--nav-bg); z-index: 2; }
.nav-search input {
  width: 100%; background: var(--nav-bg2); border: 1px solid #334155; color: #e2e8f0;
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px;
}
.nav-search input::placeholder { color: var(--nav-ink-dim); }
.nav-group { border-bottom: 1px solid rgba(148,163,184,.08); }
.nav-group > .ghead {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: #e2e8f0; user-select: none;
}
.nav-group > .ghead:hover { background: var(--nav-bg2); }
.nav-group > .ghead .gi { width: 18px; text-align: center; opacity: .8; }
.nav-group > .ghead .caret { margin-left: auto; transition: transform .15s; color: var(--nav-ink-dim); font-size: 11px; }
.nav-group.collapsed > .ghead .caret { transform: rotate(-90deg); }
.nav-group.collapsed > .gbody { display: none; }
.gbody { padding: 2px 0 8px; }
.nav-item {
  display: flex; align-items: baseline; gap: 8px; cursor: pointer;
  padding: 5px 14px 5px 42px; font-size: 13px; color: var(--nav-ink);
  border-left: 3px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item:hover { background: var(--nav-bg2); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(37,99,235,.25), transparent); color: #fff; border-left-color: var(--nav-active); }
.nav-item.deferred { color: var(--nav-ink-dim); cursor: default; }
.nav-item.deferred:hover { background: none; }
.nav-item .no { font: 11px ui-monospace, monospace; color: var(--nav-ink-dim); min-width: 20px; }
.nav-item .badge { margin-left: auto; font-size: 9px; color: var(--nav-ink-dim); border: 1px solid #334155; border-radius: 4px; padding: 0 4px; }
.menu-label { padding: 6px 14px 2px; font-size: 11px; letter-spacing: .04em; color: var(--nav-ink-dim); text-transform: none; }

/* ── main / content ─────────────────────────────────────────── */
.main { grid-area: main; position: relative; overflow: hidden; }
#screen-frame { width: 100%; height: 100%; border: 0; background: var(--panel); display: none; }
.main.mode-screen #screen-frame { display: block; }
.main.mode-dash #dash, .main.mode-menu #menu-view { display: block; }
#dash, #menu-view { display: none; height: 100%; overflow-y: auto; padding: 26px 30px; }

/* dashboard */
.dash-h { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.dash-sub { color: var(--muted); margin-bottom: 22px; font-size: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.stat .v { font-size: 26px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.section-h { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 8px 0 12px; }

/* subsystem I/O diagram */
.io-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 22px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.io-role { font-size: 13.5px; color: var(--ink); line-height: 1.7; margin-bottom: 16px; }
.io-flow { display: grid; grid-template-columns: 1fr auto 1.2fr auto 1fr; align-items: stretch; gap: 0; }
.io-col { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fbfcfe; }
.io-col h4 { font-size: 12px; margin: 0 0 8px; letter-spacing: .03em; }
.io-col ul { list-style: none; margin: 0; padding: 0; }
.io-col li { font-size: 12.5px; color: var(--ink); padding: 3px 0 3px 16px; position: relative; line-height: 1.5; }
.io-col li::before { content: ""; position: absolute; left: 3px; top: 10px; width: 5px; height: 5px; border-radius: 50%; }
.io-in   { background: #eff6ff; border-color: #cfe0fb; }
.io-in h4 { color: #1d4ed8; } .io-in li::before { background: #3b82f6; }
.io-proc { background: #f5f3ff; border-color: #ddd6fe; }
.io-proc h4 { color: #6d28d9; } .io-proc li::before { background: #8b5cf6; }
.io-out  { background: #ecfdf5; border-color: #bbf7d0; }
.io-out h4 { color: #047857; } .io-out li::before { background: #10b981; }
.io-arrow { display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 22px; padding: 0 10px; }
.io-data { margin-top: 14px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.io-data .io-chip { font-family: ui-monospace, monospace; font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 2px 8px; color: var(--ink); }
@media (max-width: 900px) {
  .io-flow { grid-template-columns: 1fr; gap: 6px; }
  .io-arrow { transform: rotate(90deg); padding: 2px 0; }
}

/* menu (option-card) view */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.opt-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer; text-decoration: none; color: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.opt-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(37,99,235,.10); }
.opt-card.deferred { opacity: .55; cursor: default; }
.opt-card.deferred:hover { border-color: var(--line); box-shadow: none; }
.opt-card .num {
  font: 13px ui-monospace, monospace; color: var(--accent); background: var(--accent-weak);
  border-radius: 7px; min-width: 30px; height: 30px; display: grid; place-items: center; flex: none; font-weight: 700;
}
.opt-card .ttl { font-size: 14px; font-weight: 600; }
.opt-card .meta { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: ui-monospace, monospace; }
.opt-card .tag { font-size: 10px; color: var(--warn); border: 1px solid #fcd9a8; background: #fff7ed; border-radius: 5px; padding: 1px 6px; margin-left: auto; align-self: center; }
