:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --sidebar: #ffffff;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-break: strict;
}

a { color: inherit; text-decoration: none; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 1.1rem .9rem;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}

.brand {
  display: flex; gap: .75rem; align-items: center;
  margin: .25rem .4rem 1.4rem;
}
.brand-mark {
  width: 2rem; height: 2rem; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent); color: white; font-weight: 800;
}
.brand strong { display: block; font-size: 1rem; color: var(--text); }
.brand small { color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.nav-link {
  display: block; padding: .7rem .85rem; border-radius: 10px;
  color: #475569; border: 1px solid transparent;
  white-space: nowrap; word-break: keep-all;
}
.nav-link:hover { background: #f1f5f9; color: var(--text); }
.nav-link.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  font-weight: 600;
}

.nav-group { margin-top: .15rem; }
.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: .65rem .85rem; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: #475569; font: inherit; font-weight: 600;
  cursor: pointer; text-align: left;
  white-space: nowrap; word-break: keep-all;
}
.nav-group-toggle:hover { background: #f1f5f9; color: var(--text); }
.nav-group.active > .nav-group-toggle {
  color: #1d4ed8;
}
.nav-chevron {
  width: .45rem; height: .45rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform .15s ease; margin-top: -.15rem;
}
.nav-group.open .nav-chevron,
.nav-group[open] .nav-chevron { transform: rotate(-135deg); margin-top: .15rem; }

.nav-sub {
  display: flex; flex-direction: column; gap: .15rem;
  margin: .2rem 0 .35rem; padding-left: .65rem;
  border-left: 2px solid #e2e8f0;
}
.nav-sublink {
  padding: .5rem .75rem; font-size: .92rem; font-weight: 500;
}

.nav-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
.nav-user { padding: .35rem .85rem .5rem; color: var(--muted); font-size: .82rem; }
.nav-perm { padding-top: 0; font-size: .75rem; color: #94a3b8; }
.nav-btn {
  width: 100%; text-align: left; background: transparent; cursor: pointer; font: inherit;
}

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: var(--bg); }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .85rem 1.25rem; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.env-pill {
  display: inline-block; margin-right: .5rem;
  padding: .15rem .55rem; border-radius: 999px;
  background: #ecfdf5; color: #047857; font-size: .75rem;
  border: 1px solid #a7f3d0;
}
.top-muted { color: var(--muted); font-size: .85rem; }
.store-pill {
  display: inline-block; margin-left: .5rem;
  padding: .15rem .55rem; border-radius: 999px;
  background: #eff6ff; color: #1d4ed8; font-size: .75rem;
  border: 1px solid #bfdbfe;
}
.content { padding: 1.25rem 1.35rem 2rem; min-width: 0; overflow-x: auto; }
.filters > label {
  display: flex; flex-direction: column; align-items: flex-start; gap: .3rem;
  font-size: .8125rem; font-weight: 600; color: #64748b;
  white-space: nowrap; word-break: keep-all;
}
.filters > label input, .filters > label select { font-weight: 400; color: var(--text); }
.table th, .data-table th { white-space: nowrap; word-break: keep-all; }

.page-subtitle { margin: .25rem 0 0; color: var(--muted); font-size: .875rem; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-header h1 { margin: 0; font-size: 1.5rem; }
.page-header-action {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .6rem 1.1rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}
.page-header-action:hover { background: #1d4ed8; color: #fff; }
.content .btn.primary {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: .55rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.content .btn.primary:hover { background: #1d4ed8; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
}
