/* ========== Global Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ========== PIN認証画面 (index.php) ========== */
body.pin-auth-index { font-family: 'Outfit', 'Noto Sans JP', sans-serif; background: linear-gradient(145deg, #1e1b4b, #312e81); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card-pin-auth { background: #fff; border-radius: 20px; padding: 44px 36px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); text-align: center; }
.icon-pin { font-size: 52px; margin-bottom: 14px; }
.pin-form h1 { font-size: 22px; font-weight: 800; color: #312e81; margin-bottom: 6px; }
.pin-form .sub { font-size: 13px; color: #64748b; margin-bottom: 28px; }
.pin-form label { display: block; text-align: left; font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.pin-form input[type="password"] { width: 100%; height: 52px; border: 1.5px solid #e2e8f0; border-radius: 12px; font-size: 22px; text-align: center; letter-spacing: .4em; padding: 0 16px; outline: none; transition: border-color .2s; background: #f8fafc; }
.pin-form input[type="password"]:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
.pin-form .err { background: #fee2e2; border: 1px solid #fca5a5; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #dc2626; margin-bottom: 16px; }
.pin-form button { width: 100%; height: 52px; border: none; border-radius: 14px; margin-top: 16px; background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; font-size: 16px; font-weight: 800; font-family: 'Outfit', sans-serif; cursor: pointer; box-shadow: 0 4px 16px rgba(99, 102, 241, .45); transition: opacity .2s; }
.pin-form button:hover { opacity: .88; }

/* ========== ダッシュボード (index.php) ========== */
:root { --primary: #6366f1; --sidebar-w: 240px; --bg: #f3f4f6; }
body.dashboard { font-family: 'Outfit', 'Noto Sans JP', sans-serif; background: var(--bg); display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: var(--sidebar-w); background: #1e1b4b; color: white; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.sidebar-logo { font-size: 22px; font-weight: 800; color: #818cf8; letter-spacing: .02em; }
.sidebar-sub { font-size: 11px; color: #6366f1; margin-top: 2px; }
.nav { flex: 1; padding: 16px 0; }
.nav-item { padding: 11px 20px; color: #a5b4fc; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: background .15s, color .15s; font-size: 14px; font-weight: 600; border-left: 3px solid transparent; user-select: none; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; border-left-color: #a5b4fc; }
.nav-section { font-size: 10px; font-weight: 700; color: #4f46e5; letter-spacing: .08em; text-transform: uppercase; padding: 14px 20px 6px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.btn-reset { display: block; width: 100%; padding: 8px; background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: #f87171; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: 'Outfit', sans-serif; text-align: center; transition: background .15s; }
.btn-reset:hover { background: rgba(239, 68, 68, 0.28); }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.header { height: 60px; background: #fff; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; padding: 0 28px; justify-content: space-between; flex-shrink: 0; }
.header-title { font-weight: 800; color: #1e293b; font-size: 16px; }
.header-link { font-size: 13px; color: var(--primary); text-decoration: none; font-weight: 600; }
.header-link:hover { text-decoration: underline; }
.content { flex: 1; overflow-y: auto; padding: 24px 28px; }
.stats-section-title { font-size: 13px; font-weight: 800; color: #475569; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card { background: #fff; border-radius: 14px; padding: 20px 22px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07); border: 1px solid transparent; transition: border-color 0.2s; }
.stat-card:hover { border-color: #cbd5e1; }
.stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-val { font-size: 2rem; font-weight: 800; color: #1e293b; line-height: 1; }
.stat-label { font-size: 12px; color: #64748b; margin-top: 4px; }
.badge-prod { background: #e0e7ff; color: #4338ca; padding: 2px 8px; border-radius: 4px; font-size: 10px; }
.badge-test { background: #e0f2fe; color: #0369a1; padding: 2px 8px; border-radius: 4px; font-size: 10px; }
.table-card { background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07); }
.table-header { padding: 16px 22px; border-bottom: 1px solid #f1f5f9; font-weight: 700; color: #334155; font-size: 14px; }
table { width: 100%; border-collapse: collapse; }
th { background: #f8fafc; text-align: left; padding: 10px 22px; font-size: 12px; color: #64748b; font-weight: 700; }
td { padding: 12px 22px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
tr:last-child td { border-bottom: none; }
.empty-row { text-align: center; color: #94a3b8; padding: 30px; }
#modalOverlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 9999; }
#modalContainer { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 94vw; height: 92vh; background: #fff; border-radius: 18px; box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; overflow: hidden; }
#modalFrame { flex: 1; border: none; width: 100%; height: 100%; }
.close-btn { position: absolute; top: 16px; right: 16px; z-index: 10; width: 34px; height: 34px; border-radius: 50%; background: #fee2e2; color: #ef4444; border: none; font-size: 18px; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.close-btn:hover { background: #fecaca; }

/* ========== PIN認証画面 (userent.php, setting.php) ========== */
body.pin-auth-alt { font-family: 'Noto Sans JP', sans-serif; background: linear-gradient(145deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card-pin-auth-alt { background: #fff; border-radius: 20px; padding: 40px 32px; width: 100%; max-width: 360px; box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35); text-align: center; }
.icon-pin-alt { font-size: 48px; margin-bottom: 12px; }
.pin-form-alt h1 { font-size: 20px; font-weight: 900; color: #312e81; margin-bottom: 6px; }
.pin-form-alt .sub { font-size: 12px; color: #64748b; margin-bottom: 28px; }
.pin-form-alt label { display: block; text-align: left; font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.pin-form-alt input[type="password"] { width: 100%; height: 48px; border: 1.5px solid #e2e8f0; border-radius: 10px; font-size: 20px; text-align: center; letter-spacing: .3em; padding: 0 16px; outline: none; transition: border-color .2s; background: #f8fafc; }
.pin-form-alt input[type="password"]:focus { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124, 58, 237, .12); }
.pin-form-alt .err { background: #fee2e2; border: 1px solid #fca5a5; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #dc2626; margin-bottom: 16px; }
.pin-form-alt button { width: 100%; height: 50px; border: none; border-radius: 12px; margin-top: 16px; background: linear-gradient(135deg, #7c3aed, #4f46e5); color: #fff; font-size: 16px; font-weight: 700; font-family: 'Noto Sans JP', sans-serif; cursor: pointer; box-shadow: 0 4px 16px rgba(124, 58, 237, .4); transition: opacity .2s; }
.pin-form-alt button:hover { opacity: .9; }

/* ========== ユーザー管理画面 (userent.php) ========== */
body.user-management { font-family: 'Noto Sans JP', sans-serif; background: linear-gradient(145deg, #4f46e5 0%, #7c3aed 50%, #8b5cf6 100%); min-height: 100vh; padding: 30px 20px 60px; color: #1e293b; }
.page-header { text-align: center; margin-bottom: 28px; display: flex; align-items: center; justify-content: center; gap: 14px; }
.page-header h1 { font-size: 1.5rem; font-weight: 900; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.admin-logout { background: rgba(255, 255, 255, .15); border: 1px solid rgba(255, 255, 255, .3); color: #fff; padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: 'Noto Sans JP', sans-serif; transition: background .2s; }
.admin-logout:hover { background: rgba(255, 255, 255, .25); }
.toast { max-width: 1000px; margin: 0 auto 20px; padding: 13px 20px; border-radius: 10px; font-size: .88rem; font-weight: 700; text-align: center; }
.toast.ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.toast.error { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.layout { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: 360px 1fr; gap: 20px; }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } }
.card { background: #fff; border-radius: 16px; padding: 24px 26px; box-shadow: 0 4px 24px rgba(0, 0, 0, .12); }
.card-title { font-size: 1rem; font-weight: 700; color: #7c3aed; margin-bottom: 18px; border-bottom: 2px solid #f1f5f9; padding-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.field-label { font-size: .8rem; font-weight: 700; color: #64748b; margin-bottom: 5px; margin-top: 14px; }
.field-label:first-child { margin-top: 0; }
input[type="text"], input[type="email"] { width: 100%; height: 44px; border: 1.5px solid #e2e8f0; border-radius: 8px; padding: 0 14px; font-size: .95rem; font-family: 'Noto Sans JP', sans-serif; color: #1e293b; background: #f8fafc; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); background: #fff; }
.btn-add { display: block; width: 100%; height: 48px; margin-top: 18px; border: none; border-radius: 10px; background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; font-size: 1rem; font-weight: 700; font-family: 'Noto Sans JP', sans-serif; cursor: pointer; transition: opacity .2s; box-shadow: 0 4px 14px rgba(79, 70, 229, .35); }
.btn-add:hover { opacity: .9; }
.user-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.user-table th { background: #f8fafc; color: #64748b; font-size: .75rem; text-align: left; padding: 8px 12px; border-bottom: 2px solid #e2e8f0; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.user-table td { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
.user-table tr:last-child td { border-bottom: none; }
.user-table tr:hover td { background: #f8fafc; }
.badge-active { display: inline-block; background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; border-radius: 6px; padding: 2px 8px; font-size: .72rem; font-weight: 700; }
.badge-inactive { display: inline-block; background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; border-radius: 6px; padding: 2px 8px; font-size: .72rem; font-weight: 700; }
.exid-tag { font-family: 'Outfit', monospace; font-size: .82rem; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px; padding: 2px 8px; color: #4f46e5; font-weight: 700; }
.otp-tag { font-family: 'Outfit', monospace; font-size: .85rem; font-weight: 700; color: #7c3aed; letter-spacing: .1em; }
.otp-none { color: #94a3b8; font-size: .75rem; }
.btn-sm { border: none; border-radius: 6px; padding: 5px 10px; font-size: .75rem; font-weight: 700; cursor: pointer; font-family: 'Noto Sans JP', sans-serif; transition: opacity .15s; }
.btn-sm:hover { opacity: .85; }
.btn-otp { background: #ede9fe; color: #7c3aed; }
.btn-enable { background: #dcfce7; color: #15803d; }
.btn-disable { background: #fef3c7; color: #b45309; }
.btn-delete { background: #fee2e2; color: #dc2626; }
.btn-group-cell { display: flex; gap: 5px; flex-wrap: wrap; }
.empty { text-align: center; padding: 40px; color: #64748b; font-size: .9rem; }
.card-count { font-family: 'Outfit', monospace; font-size: .8rem; color: #64748b; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: #c8d0d8; border-radius: 2px; }

/* ========== システム設定画面 (setting.php) ========== */
body.system-settings { font-family: 'Noto Sans JP', sans-serif; background: linear-gradient(145deg, #4f46e5 0%, #7c3aed 50%, #8b5cf6 100%); min-height: 100vh; padding: 30px 20px 60px; color: #1e293b; }
.page-header { text-align: center; margin-bottom: 28px; }
.page-header h1 { font-size: 1.5rem; font-weight: 900; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.toast.ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.layout-settings { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.card-settings { background: #fff; border-radius: 16px; padding: 24px 26px; box-shadow: 0 4px 24px rgba(0, 0, 0, .12); }
.card-title-settings { font-size: 1.1rem; font-weight: 700; color: #7c3aed; margin-bottom: 18px; border-bottom: 2px solid #f1f5f9; padding-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.field-label-settings { font-size: .85rem; font-weight: 700; color: #64748b; margin-bottom: 5px; margin-top: 16px; }
.field-label-settings:first-child { margin-top: 0; }
input[type="text"].settings, input[type="email"].settings, input[type="number"].settings { width: 100%; height: 44px; border: 1.5px solid #e2e8f0; border-radius: 8px; padding: 0 14px; font-size: .95rem; font-family: 'Noto Sans JP', sans-serif; color: #1e293b; background: #f8fafc; outline: none; transition: border-color .15s, box-shadow .15s; }
input.settings:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); background: #fff; }
.checkbox-label { display: flex; align-items: center; gap: 10px; font-size: .95rem; font-weight: 700; color: #1e293b; cursor: pointer; padding: 10px 0; }
.checkbox-label input { width: 20px; height: 20px; cursor: pointer; }
.btn-save { display: block; width: 100%; height: 54px; margin-top: 30px; border: none; border-radius: 12px; background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; font-size: 1.1rem; font-weight: 700; font-family: 'Noto Sans JP', sans-serif; cursor: pointer; transition: opacity .2s; box-shadow: 0 4px 14px rgba(79, 70, 229, .35); }
.btn-save:hover { opacity: .9; }
.help-text { font-size: .75rem; color: #94a3b8; margin-top: 4px; }

/* ========== アイテム管理画面 (exitem.php) ========== */
body.item-management { font-family: 'Noto Sans JP', sans-serif; background: #f3f4f6; min-height: 100vh; color: #1e293b; }
.mode-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; gap: 40px; padding: 6px 12px; font-size: 11px; font-weight: 900; background: #ff9800; color: #000; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); text-transform: uppercase; letter-spacing: 0.1em; font-family: 'Outfit', sans-serif; }
.container { max-width: 1100px; margin: 0 auto; padding: 60px 24px; }
.page-header-exitem { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.page-header-exitem h1 { font-size: 1.6rem; font-weight: 800; color: #1e3a8a; }
.db-switcher { display: flex; background: #e2e8f0; padding: 4px; border-radius: 12px; gap: 4px; }
.db-switcher a { padding: 8px 16px; border-radius: 10px; text-decoration: none; font-size: 13px; font-weight: 700; color: #64748b; transition: all 0.2s; }
.db-switcher a.active { background: #fff; color: #1e3a8a; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); }
.db-label { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 6px; margin-left: 8px; }
.db-label-prod { background: #e0e7ff; color: #4338ca; }
.db-label-test { background: #ffedd5; color: #9a3412; }
.toast-exitem { padding: 12px 20px; border-radius: 10px; font-size: .88rem; font-weight: 700; text-align: center; margin-bottom: 20px; }
.toast-exitem.ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.toast-exitem.error { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.layout-wrap { display: grid; grid-template-columns: 380px 1fr; gap: 24px; }
@media (max-width: 900px) { .layout-wrap { grid-template-columns: 1fr; } }
.card-exitem { background: #fff; border-radius: 16px; padding: 24px; box-shadow: 0 4px 20px rgba(0, 0, 0, .05); border: 1px solid #e2e8f0; }
.card-label-exitem { font-size: 1.05rem; font-weight: 800; color: #1e3a8a; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.field-label-exitem { font-size: .85rem; font-weight: 700; color: #64748b; margin-bottom: 6px; margin-top: 14px; }
select, input[type="text"].exitem, textarea { width: 100%; padding: 12px 14px; border: 1.5px solid #e2e8f0; border-radius: 10px; font-size: .95rem; font-family: 'Noto Sans JP', sans-serif; color: #1e293b; background: #f8fafc; outline: none; transition: all .2s; }
select:focus, input.exitem:focus, textarea:focus { border-color: #3b82f6; background: #fff; box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); }
textarea { resize: vertical; min-height: 100px; }
.btn-add-exitem { display: block; width: 100%; padding: 14px; margin-top: 20px; border: none; border-radius: 12px; background: #1e3a8a; color: #fff; font-size: 1rem; font-weight: 700; cursor: pointer; transition: all .2s; }
.btn-add-exitem:hover { background: #1e40af; transform: translateY(-1px); }
.filter-bar { margin-bottom: 16px; display: flex; gap: 10px; align-items: center; }
.item-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.item-row { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; display: flex; justify-content: space-between; align-items: center; transition: all 0.2s; }
.item-row:hover { border-color: #cbd5e1; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03); }
.item-info h3 { font-size: 1rem; color: #1e293b; font-weight: 700; }
.item-info p { font-size: .85rem; color: #64748b; margin-top: 4px; line-height: 1.5; }
.exid-badge { display: inline-block; font-family: 'Outfit', monospace; font-size: .75rem; background: #eff6ff; color: #1e40af; border-radius: 6px; padding: 2px 8px; margin-bottom: 6px; font-weight: 800; }
.btn-delete-exitem { background: #fff; color: #ef4444; border: 1px solid #fee2e2; padding: 8px 14px; border-radius: 8px; font-size: .8rem; font-weight: 700; cursor: pointer; transition: all .2s; }
.btn-delete-exitem:hover { background: #fef2f2; border-color: #fecaca; }
.empty-exitem { text-align: center; color: #94a3b8; padding: 60px 20px; font-size: .95rem; border: 2px dashed #e2e8f0; border-radius: 16px; }

/* ========== DBセットアップ画面 (dbsetting.php) ========== */
body.db-setup { font-family: 'Outfit', 'Noto Sans JP', sans-serif; background: #f3f4f6; color: #1e293b; padding: 40px 20px; }
.container-setup { max-width: 850px; margin: 0 auto; background: #fff; padding: 36px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); }
.container-setup h1 { font-size: 24px; font-weight: 800; color: #312e81; margin-bottom: 30px; display: flex; align-items: center; gap: 12px; }
.setup-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.btn-setup { padding: 16px; border-radius: 14px; border: none; font-weight: 800; font-size: 14px; cursor: pointer; transition: all 0.2s; text-align: center; text-decoration: none; display: block; }
.btn-prod { background: #6366f1; color: #fff; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.btn-test { background: #0ea5e9; color: #fff; box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3); }
.btn-all { background: #10b981; color: #fff; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.btn-setup:hover { opacity: 0.9; transform: translateY(-2px); }
.log-box { background: #111827; color: #e5e7eb; padding: 24px; border-radius: 12px; font-family: 'Consolas', 'Monaco', monospace; font-size: 13px; line-height: 1.7; max-height: 400px; overflow-y: auto; border: 1px solid #374151; }
.status-ok { color: #34d399; }
.status-err { color: #fb7185; font-weight: 700; }
.log-header { color: #94a3b8; border-bottom: 1px solid #374151; padding-bottom: 8px; margin-bottom: 12px; font-size: 11px; text-transform: uppercase; }

/* ========== DEBUG/TEST モード表示 ========== */
.debug-mode-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 4px 12px; font-family: monospace; font-size: 11px; font-weight: 700; pointer-events: none; background: #f59e0b; color: #000; }
.test-mode-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 4px 12px; font-family: monospace; font-size: 11px; font-weight: 700; pointer-events: none; background: #0ea5e9; color: #fff; }
.mode-banner-offset { margin-top: 25px; height: calc(100vh - 25px); }
