:root {
  --bg: #f4f9fd;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --text: #16324f;
  --muted: #657086;
  --border: #d9e9f6;
  --primary: #0075c2;
  --primary2: #33a6e8;
  --primaryText: #ffffff;
  --success: #0c7c43;
  --danger: #c62828;
  --shadow: 0 18px 50px rgba(20, 32, 56, .12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: linear-gradient(135deg, #f7f9ff 0%, #eef5ff 45%, #f8fbff 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 16px;
}
button, input, textarea { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: .25rem 0; }
.error { color: var(--danger); font-weight: 700; min-height: 1.25em; }
.result { color: var(--success); font-weight: 700; min-height: 1.25em; }
.pre { white-space: pre-wrap; word-break: break-word; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); background: rgba(255,255,255,.94); border: 1px solid var(--border); border-radius: 28px; padding: 30px; box-shadow: var(--shadow); }
.login-logo { width: 92px; height: 92px; object-fit: contain; display: block; margin: 0 auto 16px; }
.login-card h1 { text-align: center; }
.login-card > .muted { text-align: center; margin-bottom: 20px; }

.form-stack { display: grid; gap: 14px; }
label { font-weight: 700; color: #25304a; }
input, textarea {
  width: 100%; margin-top: 7px; border: 1px solid var(--border); border-radius: 14px;
  background: #fff; padding: 13px 14px; font-size: 16px; color: var(--text); outline: none;
}
textarea { resize: vertical; min-height: 170px; line-height: 1.7; }
input:focus, textarea:focus { border-color: rgba(0,117,194,.68); box-shadow: 0 0 0 4px rgba(0,117,194,.12); }

.btn { border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 14px; padding: 13px 16px; font-weight: 800; cursor: pointer; transition: .15s transform, .15s opacity, .15s background; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary2)); color: var(--primaryText); border: none; }
.btn.danger { background: var(--danger); color: #fff; border: none; }
.btn.danger-outline { color: var(--danger); border-color: #f0b8b8; background: #fff8f8; }
.btn.ghost { background: rgba(255,255,255,.92); }
.btn.small { font-size: 13px; padding: 8px 11px; border-radius: 10px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 268px 1fr; }
.sidebar { background: linear-gradient(180deg, #0075c2 0%, #005f9d 100%); color: #fff; padding: 20px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.18); }
.brand-logo { width: 58px; height: 58px; object-fit: contain; background: #fff; border-radius: 16px; padding: 5px; }
.sidebar-user { display: block; font-size: 13px; color: #d7e9f8; margin-top: 4px; overflow-wrap: anywhere; }
.nav { display: grid; gap: 8px; }
.nav-btn { text-align: left; border: none; border-radius: 14px; padding: 13px 14px; background: transparent; color: #dcebf7; font-weight: 800; cursor: pointer; }
.nav-btn:hover, .nav-btn.active { background: rgba(255,255,255,.16); color: #fff; }
.sidebar-logout { margin-top: auto; }

.main { padding: 24px 28px 50px; max-width: 1280px; width: 100%; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
h1 { font-size: 30px; margin: 0 0 4px; }
h2 { font-size: 20px; margin: 0 0 14px; }
.status-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 9px 13px; font-weight: 900; border: 1px solid var(--border); background: #fff; }
.status-badge.green { background: #eaf7ef; color: #0b6b2f; border-color: #bfe8cb; }
.status-badge.red { background: #fff0f0; color: #b42318; border-color: #ffd0d0; }
.status-badge.gray { background: #eef2f8; color: #4b5563; }
.panel { display: none; }
.panel.active { display: block; }
.card { background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: 0 10px 28px rgba(16,24,40,.06); margin-bottom: 18px; }
.availability-card { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.big-text { font-size: 22px; font-weight: 900; margin: 6px 0; }
.metric-row { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border); border-radius: 15px; padding: 14px; background: var(--surface2); }
.metric-row strong { font-size: 24px; }
.counter { display: block; text-align: right; color: var(--muted); font-weight: 800; margin-top: 6px; }
.section-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f3f6fb; color: #475569; font-size: 13px; white-space: nowrap; }
td { font-size: 14px; }
.actions-cell { display: flex; gap: 7px; white-space: nowrap; }
.state-pill { display: inline-block; padding: 4px 9px; border-radius: 999px; font-weight: 800; font-size: 12px; }
.state-pill.enabled { color: #0b6b2f; background: #eaf7ef; }
.state-pill.disabled { color: #b42318; background: #fff0f0; }
.checkbox { display: flex; align-items: flex-start; gap: 10px; }
.checkbox input { width: auto; margin: 4px 0 0; flex: 0 0 auto; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.58); display: none; align-items: center; justify-content: center; padding: 18px; z-index: 20; }
.modal.show { display: flex; }
.modal-panel { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 24px; padding: 22px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.compact-modal { width: min(560px, 100%); }
.confirm-box { display: grid; gap: 12px; border: 1px solid var(--border); border-radius: 18px; padding: 14px; background: #f8fafc; }
.confirm-box span { display: block; color: var(--muted); font-weight: 900; margin-bottom: 3px; }
.emergency-box { border: 2px solid #dc2626; background: #fff5f5; border-radius: 18px; padding: 16px; margin-top: 16px; display: grid; gap: 14px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; min-width: 260px; max-width: 460px; background: #111827; color: #fff; border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); display: none; }
.toast.show { display: block; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: relative; }
  .nav { grid-template-columns: repeat(3, 1fr); }
  .main { padding: 18px; }
  .topbar, .availability-card { flex-direction: column; }
  .modal-actions { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body:not(.is-admin) .sidebar { display: flex; }
  .sidebar { padding: 14px; gap: 12px; }
  .sidebar-brand { display: none; }
  .nav { grid-template-columns: 1fr 1fr; }
  .nav-btn { text-align: center; padding: 11px 8px; }
  .sidebar-logout { margin-top: 0; }
  .main { padding: 12px; }
  h1 { font-size: 25px; }
  .card { padding: 16px; }
  .section-header { align-items: flex-start; }
}


/* カテゴリ選択 */
.category-fieldset {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface2);
}
.category-fieldset legend {
  padding: 0 8px;
  font-weight: 900;
  color: var(--text);
}
.required-label {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff0f0;
  color: var(--danger);
  font-size: 12px;
}
.category-description { margin-bottom: 12px; }
.category-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}
.category-option:hover {
  border-color: rgba(0,117,194,.55);
  background: #f7fbff;
}
.category-option:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,117,194,.12);
  background: #eef8ff;
}
.category-option input {
  width: auto;
  margin: 3px 0 0;
  flex: 0 0 auto;
}
.category-option span {
  line-height: 1.55;
}

select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  outline: none;
}

select:focus {
  border-color:
    rgba(0,117,194,.68);

  box-shadow:
    0 0 0 4px
    rgba(0,117,194,.12);
}

.category-card {

  background: rgba(43, 148, 217, 0.68);

  border: 1px solid
          #d9e9f6;

  border-radius: 16px;

  padding: 20px;

  margin-bottom: 20px;
}

.category-title {

  font-size: 18px;

  font-weight: 700;

  margin-bottom: 12px;

  color: #ffffff;
}

.category-select {

  width: 100%;

  height: 52px;

  font-size: 16px;

  font-weight: 600;

  border: 1px solid
          #c7dff4;

  border-radius: 12px;

  padding: 0 14px;

  background: #fff;
}

.availability-warning {

  margin-bottom: 24px;

  padding: 28px;

  border-radius: 20px;

  border: 3px solid #dc2626;

  background: #fff1f2;

  color: #991b1b;

  box-shadow:
    0 8px 24px
    rgba(220,38,38,.18);
}

.warning-title {

  font-size: 32px;

  font-weight: 900;

  margin-bottom: 14px;

  color: #b91c1c;
}

.warning-message {

  font-size: 20px;

  line-height: 1.8;

  margin-bottom: 18px;
}

.warning-time {

  font-size: 24px;

  font-weight: 900;

  color: #dc2626;
}

.warning-box {

  margin-bottom: 18px;

  padding: 18px;

  border-radius: 14px;

  background: #ffffff;

  border: 1px solid #fecaca;
}

.warning-box-title {

  font-size: 15px;

  font-weight: 700;

  margin-bottom: 8px;
}

.warning-box-time {

  font-size: 28px;

  font-weight: 900;

  color: #dc2626;
}

.warning-contact {

  font-size: 18px;

  font-weight: 700;
}

.warning-hours {

  margin-top: 20px;

  padding: 18px;

  border-radius: 14px;

  background: rgba(
    255,
    255,
    255,
    0.8
  );
}

.warning-hours-title {

  font-size: 16px;

  font-weight: 700;

  margin-bottom: 10px;
}

.warning-hours-main {

  font-size: 28px;

  font-weight: 900;

  color: #dc2626;

  letter-spacing: 1px;

  line-height: 1.2;
}