:root {
  --purple: #6b3fa0;
  --purple-dark: #4e2d78;
  --bg: #f5f4f8;
  --panel: #ffffff;
  --border: #e2dfec;
  --text: #22202a;
  --muted: #77738a;
  --danger: #c0392b;
  --ok: #2e8b57;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: linear-gradient(90deg, var(--purple-dark), var(--purple));
  color: #fff;
  padding: 0 24px;
  height: 56px;
}
.brand { font-size: 20px; letter-spacing: .5px; }
.brand strong { font-weight: 800; }
.nav { display: flex; gap: 4px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-right .who { color: #fff; font-size: 14px; }
.tenant-select {
  padding: 6px 10px; border-radius: 8px; border: 0;
  background: #ffffff22; color: #fff; font-size: 13px; cursor: pointer;
}
.tenant-select option { color: var(--text); }
.nav a {
  color: #ffffffcc;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.nav a:hover { background: #ffffff22; color: #fff; }
.nav a.active { background: #ffffff33; color: #fff; font-weight: 600; }

.app { max-width: 1100px; margin: 24px auto; padding: 0 24px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.page-head h1 { font-size: 22px; margin: 0; }

.btn {
  border: 0;
  background: var(--purple);
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--purple-dark); }
.btn.secondary { background: #eceaf3; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
th { background: #faf9fc; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #faf9fc; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: #eceaf3; color: var(--purple-dark); }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }

/* Modal form */
.modal-backdrop {
  position: fixed; inset: 0; background: #0007;
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; border-radius: 12px; width: 480px; max-width: 92vw;
  max-height: 90vh; overflow: auto; padding: 24px;
}
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
}
.field textarea { min-height: 64px; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 100; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

/* 認証画面 */
.auth-wrap {
  min-height: 70vh; display: flex; align-items: center; justify-content: center;
}
.auth-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: 380px; max-width: 92vw;
  box-shadow: 0 10px 30px rgba(78,45,120,.08);
}
.auth-brand {
  font-size: 26px; color: var(--purple-dark); margin-bottom: 4px;
}
.auth-brand strong { font-weight: 800; }
