:root {
  color-scheme: light;
  --page: #f3f5f6;
  --ink: #17202a;
  --muted: #64717e;
  --line: #d8e0e6;
  --panel: #ffffff;
  --panel-subtle: #f8fafb;
  --nav: #18242e;
  --nav-line: #263541;
  --nav-text: #dce5ea;
  --accent: #0f766e;
  --accent-ink: #075b55;
  --accent-soft: #dff3ef;
  --amber: #a15c06;
  --amber-soft: #fff4db;
  --red: #b42318;
  --red-soft: #ffebe7;
  --shadow: 0 14px 32px rgba(26, 39, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
  min-width: 0;
}

select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--nav);
  border-right: 1px solid var(--nav-line);
  color: var(--nav-text);
  padding: 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 4px 8px 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
}

.brand-sub {
  margin-top: 2px;
  color: #9fadb7;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding-right: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c7d2da;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.nav-count {
  color: #a9b6c0;
  font-size: 12px;
  white-space: nowrap;
}

.main {
  min-width: 0;
  width: 100%;
  overflow-x: hidden;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
}

.topbar p,
.panel-meta,
.metric-label,
.queue-status,
.notice,
.module-description,
.detail-copy,
.form-error {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.text-button,
.primary-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 36px;
  font-size: 18px;
}

.text-button,
.primary-button {
  padding: 0 14px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
}

.status-pill.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.panel,
.module-panel,
.detail-panel,
.login-panel,
.guard-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 100px;
  padding: 15px;
}

.metric-card.unavailable {
  background: var(--panel-subtle);
}

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
}

.metric-number {
  font-size: 28px;
  font-weight: 800;
}

.metric-unit {
  color: var(--muted);
  font-size: 13px;
}

.customer-feature-panel {
  margin-bottom: 14px;
}

.customer-feature-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
  min-height: 420px;
}

.customer-list {
  display: grid;
  align-content: start;
  max-height: 640px;
  overflow: auto;
  border-right: 1px solid var(--line);
}

.customer-row {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.customer-row:hover,
.customer-row.active {
  background: #f3fbf9;
}

.customer-row.active {
  border-left: 4px solid var(--accent);
  padding-left: 10px;
}

.customer-name {
  font-weight: 800;
}

.customer-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.feature-editor {
  min-width: 0;
  padding: 14px;
}

.feature-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.feature-group-list {
  display: grid;
  gap: 10px;
}

.feature-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-subtle);
}

.feature-group h3 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-size: 14px;
}

.feature-check {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.feature-check:last-child {
  border-bottom: 0;
}

.feature-check strong,
.feature-check small {
  display: block;
}

.feature-check small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.feature-source {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  padding: 4px 8px;
  white-space: nowrap;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.8fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.module-card {
  display: grid;
  gap: 10px;
  min-height: 152px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-subtle);
  cursor: pointer;
  text-align: left;
}

.module-card.active,
.module-card:hover {
  border-color: var(--accent);
  background: #f3fbf9;
}

.module-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.module-label {
  font-weight: 800;
}

.module-count {
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.operation-row,
.queue-row,
.notice {
  border-bottom: 1px solid var(--line);
  padding: 12px 15px;
}

.operation-row:last-child,
.queue-row:last-child,
.notice:last-child {
  border-bottom: 0;
}

.operation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.operation-label {
  font-weight: 700;
}

.method-pill {
  align-self: start;
  border-radius: 999px;
  background: var(--panel-subtle);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 8px;
}

.method-pill.pending {
  background: var(--amber-soft);
  color: var(--amber);
}

.method-pill.danger {
  background: var(--red-soft);
  color: var(--red);
}

.detail-body {
  min-height: 360px;
}

.detail-section {
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
}

.route-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.route-chip {
  max-width: 100%;
  overflow-wrap: anywhere;
  border-radius: 999px;
  background: var(--panel-subtle);
  color: var(--muted);
  font-size: 12px;
  padding: 5px 8px;
}

.route-chip.feature-gate {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.section-header-row,
.data-section-head,
.action-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.section-header-row {
  margin-bottom: 12px;
}

.data-section,
.action-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-subtle);
  overflow: hidden;
}

.data-section {
  margin-top: 10px;
}

.data-section.unavailable {
  border-color: #ead5a8;
  background: var(--amber-soft);
}

.data-section-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.data-section-actions,
.table-actions,
.record-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-section-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.data-section-head h3,
.action-card h3 {
  margin: 0;
  font-size: 14px;
}

.data-table-wrap {
  width: 100%;
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  max-width: 280px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
  text-align: left;
  vertical-align: top;
}

.data-table td.table-actions {
  display: table-cell;
  width: 1%;
  max-width: none;
  white-space: nowrap;
  vertical-align: middle;
  text-align: left;
}

.data-table td.table-actions > .text-button,
.data-table td.table-actions > a.text-button {
  display: inline-block;
  margin-right: 6px;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table td.table-actions > .text-button:last-child,
.data-table td.table-actions > a.text-button:last-child {
  margin-right: 0;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-card {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.action-card.danger {
  border-color: #f0b8af;
  background: #fff8f6;
}

.small-button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.danger-button {
  border-color: #f0b8af;
  color: var(--red);
}

.record-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.record-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.record-editor-head h3 {
  margin: 0;
  font-size: 14px;
}

.record-json-editor {
  width: 100%;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--panel-subtle);
  color: var(--ink);
  font-family: "Menlo", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 14px;
}

.queue-list,
.notice-list {
  display: grid;
}

.queue-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 700;
}

.queue-count {
  min-width: 52px;
  color: var(--accent);
  text-align: right;
}

.notice.info {
  border-left: 4px solid var(--accent);
}

.notice.warning {
  border-left: 4px solid var(--amber);
  background: var(--amber-soft);
}

.login-panel,
.guard-panel {
  margin-bottom: 14px;
  padding: 18px;
}

.login-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  align-items: end;
  gap: 12px;
  min-width: 0;
}

.login-form h2 {
  grid-column: 1 / -1;
}

.login-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.login-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--ink);
}

.form-error {
  grid-column: 1 / -1;
  color: var(--red);
}

.guard-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--amber-soft);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-grid,
  .customer-feature-layout,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .customer-list {
    max-height: 280px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
  }

  .nav-list {
    max-height: none;
  }

  .metric-grid,
  .module-grid,
  .action-grid,
  .login-form {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .text-button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 14px;
  }

  .topbar,
  .guard-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .feature-editor-head,
  .feature-check {
    align-items: flex-start;
  }

  .feature-editor-head {
    flex-direction: column;
  }

  .feature-check {
    grid-template-columns: 1fr;
  }

  .operation-row {
    grid-template-columns: 1fr;
  }

  .method-pill {
    justify-self: start;
  }

  .section-header-row,
  .data-section-head,
  .action-card-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
