:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --text: #17212b;
  --muted: #65717d;
  --line: #dfe4e8;
  --line-strong: #cbd3d9;
  --accent: #2457d6;
  --accent-soft: #eaf0ff;
  --accent-dark: #183f9f;
  --good: #14835f;
  --good-soft: #e8f6f1;
  --warn: #a96713;
  --warn-soft: #fff3df;
  --danger: #c3414b;
  --danger-soft: #fff0f1;
  --shadow: 0 12px 32px rgba(20, 32, 44, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  font-family: "Inter", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  height: 27px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.container {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.2;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.lead {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.layout-main {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 32, 44, 0.02);
}

.card-pad {
  padding: 22px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.card-header h2,
.card-header h3,
.card-header p {
  margin-bottom: 0;
}

.card-body {
  padding: 20px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 720;
  transition: 150ms ease;
}

.btn:hover:not(:disabled) {
  border-color: #aeb8c0;
  transform: translateY(-1px);
}

.btn-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.btn-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.icon-btn {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.select,
.input,
.textarea {
  width: 100%;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  transition: 150ms ease;
}

.select,
.input {
  height: 42px;
  padding: 0 12px;
}

.textarea {
  min-height: 110px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

.select:focus,
.input:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: #e9edf0;
  border-radius: 11px;
}

.segmented button {
  min-height: 34px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 720;
}

.segmented button.is-active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 4px rgba(20, 32, 44, 0.12);
}

.pill,
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 720;
  white-space: nowrap;
}

.pill {
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.status-good {
  color: var(--good);
  background: var(--good-soft);
}

.status-warn {
  color: var(--warn);
  background: var(--warn-soft);
}

.status-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-info {
  color: var(--accent);
  background: var(--accent-soft);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  padding: 17px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 780;
  letter-spacing: -0.035em;
}

.stat-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.table-wrap {
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  padding: 10px 12px;
  color: var(--muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.mono {
  font-variant-numeric: tabular-nums;
}

.list-clean {
  padding: 0;
  margin: 0;
  list-style: none;
}

.divider {
  height: 1px;
  margin: 18px 0;
  background: var(--line);
}

.progress {
  height: 7px;
  overflow: hidden;
  background: #e8ecef;
  border-radius: 999px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 450ms ease;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.btn:not(.btn-primary) .spinner {
  border-color: rgba(23, 33, 43, 0.2);
  border-top-color: currentColor;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  padding: 11px 16px;
  color: #fff;
  background: #18222c;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeUp 300ms ease both;
}

@media (max-width: 920px) {
  .layout-main,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 60px;
    padding: 0 16px;
  }

  .container {
    width: min(100% - 24px, 1240px);
    padding-top: 22px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .top-actions .demo-badge {
    display: none;
  }
}
