:root {
  --bg: #f1f4fb;
  --panel: rgba(255, 255, 255, 0.78);
  --text: #1b2436;
  --muted: #5b667e;
  --primary: #1659ff;
  --danger: #d93025;
  --ok: #137333;
  --shadow-outer: 18px 18px 35px rgba(30, 51, 94, 0.12);
  --shadow-inner: inset 1px 1px 0 rgba(255, 255, 255, 0.65);
  --border: 1px solid rgba(255, 255, 255, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #fafdff, #ebf0f9 60%);
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.logo {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo:hover {
  color: var(--text);
  text-decoration: none;
}

.topnav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.topnav a {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow-outer), var(--shadow-inner);
  border: var(--border);
  color: var(--text);
  font-size: 14px;
}

.topnav-email {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: var(--border);
  font-size: 13px;
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-outer), var(--shadow-inner);
  backdrop-filter: blur(10px);
  padding: 20px;
}

.card + .card {
  margin-top: 16px;
}

h1 {
  margin: 0 0 12px;
  font-size: 28px;
}

h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.65;
}

ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

li + li {
  margin-top: 6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.account-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 16px;
  align-items: start;
}

.account-sidebar {
  position: sticky;
  top: 12px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-nav a {
  display: block;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid #dde6f6;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.side-nav a:hover {
  background: #f3f7ff;
}

.account-content {
  min-width: 0;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d9e0ef;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.95);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #bfd1ff;
  border-color: #adc4ff;
}

.row {
  margin-bottom: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: #5b667e;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid #cfd8ea;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  text-decoration: none;
  background: var(--primary);
  color: #fff;
}

.btn-link:hover {
  text-decoration: none;
  opacity: 0.95;
}

.btn-link.secondary {
  background: #5b667e;
}

.btn-link.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid #cfd8ea;
}

.inline-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.status {
  margin-top: 10px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  display: none;
}

.status.ok {
  display: block;
  background: #ebf7ee;
  color: var(--ok);
}

.status.error {
  display: block;
  background: #fdeceb;
  color: var(--danger);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.summary-item {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #e1e8f8;
}

.summary-label {
  font-size: 12px;
  color: var(--muted);
}

.summary-value {
  margin-top: 5px;
  font-weight: 700;
}

.warning {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff2e0;
  color: #8a4300;
  font-size: 14px;
}

.footer-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid #dbe4f4;
  background: rgba(255, 255, 255, 0.82);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid #e5ecfa;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f7f9ff;
  color: #34425f;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.small-note {
  font-size: 12px;
  color: var(--muted);
}

.mono {
  font-family: "Consolas", "Menlo", monospace;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill.free {
  background: #eef4ff;
  color: #1f4ecf;
}

.pill.premium {
  background: #fff4d9;
  color: #946200;
}

.pill.admin {
  background: #ebf8ff;
  color: #0f6c9f;
}

.pill.disabled {
  background: #f6e9ea;
  color: #9e2626;
}

.actions-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.actions-compact button {
  padding: 6px 8px;
  font-size: 12px;
}

.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.analytics-controls {
  align-items: flex-end;
  margin-bottom: 12px;
}

.analytics-control {
  min-width: 140px;
}

.analytics-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.chart-box {
  height: 260px;
}

.code-block {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: #f3f6fc;
  border: 1px solid #dde6f6;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Consolas", "Menlo", monospace;
  font-size: 12px;
  color: #20314f;
}

.admin-master-detail {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

.admin-master {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 30px);
  overflow: hidden;
}

.admin-master .actions input {
  min-width: 180px;
}

.master-list {
  position: relative;
  flex: 1 1 auto;
  min-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.master-list.loading {
  pointer-events: none;
}

.master-item {
  border: 1px solid #dce5f5;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
  min-height: 148px;
}

.master-item:hover {
  border-color: #aec3ef;
  background: #f5f8ff;
}

.master-item.active {
  border-color: #4e78df;
  background: #edf3ff;
  box-shadow: inset 0 0 0 1px rgba(57, 98, 201, 0.2);
}

.master-item:focus-visible {
  outline: 2px solid #3e6ed8;
  outline-offset: 2px;
}

.master-item-email {
  font-weight: 700;
  font-size: 14px;
  color: #1f2c48;
  margin-bottom: 3px;
}

.master-item-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.master-skeleton {
  height: 84px;
  border-radius: 12px;
  border: 1px solid #dce5f5;
  background: linear-gradient(90deg, #eef3fd 25%, #f8fbff 37%, #eef3fd 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.empty-state {
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed #cad7ee;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.6;
}

.master-spacer {
  width: 1px;
  opacity: 0;
  pointer-events: none;
}

.admin-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 12px;
}

.detail-field {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #e1e8f8;
  background: rgba(255, 255, 255, 0.78);
}

.detail-field button {
  margin-top: 8px;
}

.admin-help-panel {
  margin-top: 6px;
  border: 1px solid #dce5f5;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  padding: 10px 12px;
}

.admin-help-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: #2d3f62;
}

.admin-help-list {
  margin: 10px 0 0;
  padding-left: 18px;
}

.admin-help-list li {
  color: #324564;
  font-size: 13px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 7px;
  border: 1px solid #cfd8ea;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 0 rgba(34, 51, 84, 0.08);
  font-family: "Consolas", "Menlo", monospace;
  font-size: 11px;
  color: #243757;
}

.status button {
  margin-left: 8px;
  padding: 6px 10px;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.otp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 39, 0.42);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.otp-modal {
  width: min(100%, 420px);
  background: var(--panel);
  border: var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-outer), var(--shadow-inner);
  padding: 16px;
}

.otp-modal h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

body[data-page="admin"] .page {
  max-width: 1360px;
}

@media (max-width: 640px) {
  h1 {
    font-size: 24px;
  }

  .page {
    padding-top: 16px;
  }

  .account-layout {
    grid-template-columns: 1fr;
  }

  .account-sidebar {
    position: static;
  }

  .admin-master-detail {
    grid-template-columns: 1fr;
  }

  .admin-master {
    position: static;
    max-height: none;
  }
}
