*,
*::before,
*::after {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

:root{
  --bg0: #0b1220;
  --bg1: #0f1a33;
  --panel: rgba(255,255,255,0.92);
  --panel-border: rgba(15, 23, 42, 0.10);
  --text: #0f172a;
  --muted: rgba(15, 23, 42, 0.65);
  --primary: #2563eb;
  --primary-weak: rgba(37, 99, 235, 0.10);
  --danger: #dc2626;

  --radius: 14px;
  --radius-sm: 10px;

  --shadow: 0 12px 30px rgba(2, 6, 23, 0.12);
  --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.7);
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, Arial, sans-serif;
  color: var(--text);
  background-color: #f8fafc;
  background-image:
    radial-gradient(1200px 700px at 15% 10%, rgba(37, 99, 235, 0.28), transparent 60%),
    radial-gradient(900px 600px at 90% 0%, rgba(168, 85, 247, 0.18), transparent 55%),
    linear-gradient(180deg, #f8fafc, #eef2ff 35%, #f8fafc);
  background-repeat: no-repeat;
  background-size: auto 600px;
}

.material-symbols-outlined {
  font-size: 1.35em;
  vertical-align: -0.28em;
  margin-right: 8px;
  opacity: 0.9;
}

header {
  height: 6px;
  background: linear-gradient(90deg, rgba(37,99,235,0.95), rgba(168,85,247,0.85));
}

/* =========================
   Loading overlay
========================= */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(248, 250, 252, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#loading.hidden {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 4px solid rgba(15, 23, 42, 0.12);
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================
   Layout
========================= */
#layout {
  display: flex;
  gap: 14px;
  max-width: 1100px;
  margin: 18px auto;
  padding: 0 14px 24px;
}

/* Nav / Side */
nav#nav {
  flex: 0 0 260px;
  padding: 14px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow), var(--shadow-inset);
  overflow: hidden;
}

nav#nav h1 {
  margin: 0;
  padding: 10px 10px 6px;
  text-align: left;
}

nav#nav p {
  margin: 8px 10px 14px;
  color: var(--muted);
  line-height: 1.35;
}

#navUserRole {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.35em 0.6em;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.30);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

#navUserRole.roleAdmin {
  background: rgba(220, 38, 38, 0.12);
  color: #991b1b;
  border: 1px solid rgba(220, 38, 38, 0.30);
}

#navUserName {
  font-weight: 700;
  color: var(--text);
}

#navUserMail {
  font-size: 0.9em;
  opacity: 0.85;
}

/* Main */
main {
  flex: 1;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow), var(--shadow-inset);
}

h2 {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.14), rgba(168, 85, 247, 0.10));
  border: 1px solid rgba(37, 99, 235, 0.15);
  color: var(--text);
  font-size: 0.98rem;
}

/* =========================
   Form controls
========================= */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
  width: min(420px, 100%);
  padding: 10px 12px;
  margin: 0 10px 10px 0;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  background: rgba(255,255,255,0.9);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
  color: rgba(15, 23, 42, 0.45);
}

td input[type="text"],
td input[type="email"],
td input[type="password"],
td input[type="number"],
td textarea {
  margin: 0;
  width: 100%;
}

textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.45;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 10px 0;
  padding: 10px 12px;
  width: min(420px, 100%);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.65);
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.radio-option input[type="radio"] {
  margin: 0;
  accent-color: var(--primary);
}

/* =========================
   Buttons
========================= */
button {
  appearance: none;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.10);
  color: rgba(37, 99, 235, 0.95);
  font-weight: 700;
  font-size: 0.98rem;
  padding: 4px 12px;
  border-radius: 12px;
  cursor: pointer;
  margin: 0;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

button:hover {
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.12);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.20);
}

button.nav {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;

  border: 1px solid transparent;
  background: transparent;
  color: rgba(15, 23, 42, 0.86);

  margin: 0;
  padding: 10px 10px;
  border-radius: 12px;
}

button.nav:hover {
  background: rgba(15, 23, 42, 0.05);
  box-shadow: none;
}

button.nav.is-active,
button.nav.is-active:hover {
  box-shadow: rgba(37, 99, 235, 0.14) 0px 0px 0px 4px;
}

#openSmart {
  width: 100%;
  margin: 10px 0 12px;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.95), rgba(168, 85, 247, 0.85));
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
}

#openSmart:hover {
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

/* =========================
   Table
========================= */
.table-wrapper {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255,255,255,0.65);
  margin: 0 0 10px 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 600px;
}

th, td {
  border: 1px solid rgba(15, 23, 42, 0.10);
  padding: 10px 12px;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: rgba(248, 250, 252, 0.95);
  color: rgba(15, 23, 42, 0.78);
  font-size: 0.92rem;
  white-space: nowrap;
}

td input {
  margin: 0;
  width: min(320px, 100%);
}

/* 外周だけ消す */
tbody tr:first-child > * { border-top: none; }
tbody tr:last-child  > * { border-bottom: none; }
tbody tr > *:first-child { border-left: none; }
tbody tr > *:last-child  { border-right: none; }

/* =========================
   Footer
========================= */
footer {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(15, 23, 42, 0.55);
  padding: 10px 14px 18px;
  margin: 0;
}

/* =========================
   Modal
========================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-panel {
  width: min(640px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 48px rgba(2, 6, 23, 0.22);
}

.modal-panel .table-wrapper {
  margin-bottom: 14px;
}

.modal-panel .radio-group {
  width: 100%;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-cancel {
  border-color: rgba(15, 23, 42, 0.18);
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted);
}

.btn-cancel:hover {
  background: rgba(15, 23, 42, 0.10);
  border-color: rgba(15, 23, 42, 0.25);
  box-shadow: none;
}

.btn-edit-icon {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  margin: 0;
  line-height: 1;
  color: var(--primary);
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.btn-edit-icon:hover {
  opacity: 1;
  background: transparent;
  box-shadow: none;
  border: none;
}

.btn-delete-icon {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  margin: 0;
  line-height: 1;
  color: var(--danger);
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.btn-delete-icon:hover {
  opacity: 1;
  background: transparent;
  box-shadow: none;
  border: none;
}

/* =========================
   Responsive
========================= */
@media (max-width: 860px) {
  #layout {
    flex-direction: column;
  }

  nav#nav {
    flex: 1 1 auto;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea {
    width: 100%;
    margin-right: 0;
  }
}