/* ==========================================================================
   FC統合ポータル — portal-common.css
   全ページ共通デザインシステム。色・幅は :root / [data-theme="dark"] だけ直せば反映。
   ========================================================================== */

/* ----- Tokens ----- */
:root {
  --bg-color: #f4f7f9;
  --card-bg: #ffffff;
  --text-color: #333333;
  --text-sub: #666666;
  --sidebar-bg: #ffffff;
  --border-color: #e2e8f0;
  --primary-color: #0066cc;
  --primary-hover: #0052a3;
  --danger-color: #e74c3c;
  --success-color: #27ae60;
  --warning-color: #f59e0b;
  --btn-icon-color: #4a5568;
  --sidebar-width: 280px;
  --peek-width: 16px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  --rte-c-ink: var(--text-color);
  --rte-c-gray: #4b5563;
  --rte-c-red: #dc2626;
  --rte-c-orange: #c2410c;
  --rte-c-yellow: #a16207;
  --rte-c-green: #15803d;
  --rte-c-teal: #0f766e;
  --rte-c-blue: #1d4ed8;
  --rte-c-navy: #1e3a8a;
  --rte-c-purple: #6d28d9;
  --rte-c-pink: #be185d;
  --rte-c-brown: #9a3412;
  --rte-c-olive: #3f6212;
  --rte-c-sky: #0369a1;
  --rte-c-wine: #9f1239;
}

[data-theme="dark"] {
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --text-color: #e0e0e0;
  --text-sub: #a0a0a0;
  --sidebar-bg: #181818;
  --border-color: #333333;
  --primary-color: #3399ff;
  --primary-hover: #66b2ff;
  --btn-icon-color: #cbd5e1;
  --rte-c-ink: var(--text-color);
  --rte-c-gray: #9ca3af;
  --rte-c-red: #f87171;
  --rte-c-orange: #fb923c;
  --rte-c-yellow: #facc15;
  --rte-c-green: #4ade80;
  --rte-c-teal: #2dd4bf;
  --rte-c-blue: #60a5fa;
  --rte-c-navy: #93c5fd;
  --rte-c-purple: #c4b5fd;
  --rte-c-pink: #f9a8d4;
  --rte-c-brown: #fdba74;
  --rte-c-olive: #a3e635;
  --rte-c-sky: #7dd3fc;
  --rte-c-wine: #fb7185;
  color-scheme: dark;
}

/* ----- Reset / base ----- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; transition: background-color 0.3s, color 0.3s; }
html, body { min-height: 100%; }
html { overflow-x: clip; }
body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  display: flex;
  min-height: 100vh;
  overflow-x: visible;
}
img { max-width: 100%; }
button, input, select, textarea { font-family: inherit; }
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="color"]):not([type="range"]):not([type="file"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  color: var(--text-color);
  background-color: var(--bg-color);
}
[data-theme="dark"] select option {
  color: var(--text-color);
  background-color: var(--card-bg);
}

/* ----- Sidebar shell ----- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 60px 20px 20px 20px;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width) + var(--peek-width))); }
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.toggle-sidebar-btn {
  position: absolute;
  top: 15px; right: -18px;
  width: 36px; height: 36px;
  z-index: 1100;
  background: var(--sidebar-bg);
  color: var(--btn-icon-color);
  border: 2px solid var(--btn-icon-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  outline: none;
}
.toggle-sidebar-btn:hover { background: var(--border-color); }
.sidebar-section { margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--border-color); }
.company-title { font-size: 16px; font-weight: bold; color: var(--primary-color); margin-bottom: 4px; word-break: break-all; }
.user-name { font-size: 12px; color: var(--text-sub); margin-bottom: 12px; }

.sidebar-menu { list-style: none; }
.sidebar-menu li { margin-bottom: 8px; }
.sidebar-menu button,
.sidebar-menu a {
  width: 100%; text-align: left; background: none; border: none;
  color: var(--text-color); padding: 10px; font-size: 14px;
  border-radius: 6px; cursor: pointer; display: flex; align-items: center;
  gap: 10px; text-decoration: none;
}
.sidebar-menu button:hover,
.sidebar-menu a:hover {
  background: rgba(0, 102, 204, 0.08); color: var(--primary-color);
}
.btn-danger-link { color: var(--danger-color) !important; }
.btn-home {
  background: var(--primary-color) !important;
  color: #fff !important;
  font-weight: bold;
}
.btn-home:hover { background: var(--primary-hover) !important; color: #fff !important; }
.btn-theme {
  width: 100%; text-align: left; background: none; border: 1px solid var(--border-color);
  color: var(--text-color); padding: 10px; font-size: 14px;
  border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 10px;
}
.btn-theme:hover { background: rgba(0, 102, 204, 0.08); color: var(--primary-color); }

.nav-group { margin: 4px 0 10px; }
.nav-group-toggle {
  width: 100%; text-align: left; background: none; border: none;
  color: var(--text-color); padding: 10px; font-size: 14px; font-weight: 700;
  border-radius: 6px; cursor: pointer; display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
}
.nav-group-toggle:hover,
.nav-group.open > .nav-group-toggle {
  background: rgba(0, 102, 204, 0.08); color: var(--primary-color);
}
.nav-caret { transition: transform 0.2s; font-size: 12px; }
.nav-group.open .nav-caret { transform: rotate(180deg); }
.nav-sub {
  display: none; list-style: none; margin: 4px 0 0 8px;
  padding: 0 0 0 10px; border-left: 1px solid var(--border-color);
}
.nav-group.open > .nav-sub { display: block; }
.nav-sub li { margin-bottom: 4px; }
.nav-sub a {
  width: 100%; text-align: left; background: none; border: none;
  color: var(--text-color); padding: 9px 10px; font-size: 13px; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; gap: 8px; text-decoration: none;
}
.nav-sub a:hover { background: rgba(0, 102, 204, 0.08); color: var(--primary-color); }
.nav-sub a.active {
  background: var(--primary-color) !important; color: #fff !important; font-weight: bold;
}

/* ----- Main ----- */
.main-content { flex: 1; margin-left: var(--sidebar-width); padding: 30px 40px; transition: margin-left 0.3s ease; }
.main-content.expanded { margin-left: var(--peek-width); }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 16px; margin-bottom: 24px;
}
.page-header h1 { font-size: 24px; margin-bottom: 4px; }
.page-header p { font-size: 13px; color: var(--text-sub); }
.page-header a { color: var(--primary-color); font-size: 13px; font-weight: bold; text-decoration: none; }
.page-header a:hover { text-decoration: underline; }

/* ----- Toolbar / buttons / forms ----- */
.toolbar { position: relative; display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; margin-bottom: 20px; padding: 16px;
  background: var(--card-bg); border-radius: 10px; border: 1px solid var(--border-color);
  box-shadow: var(--shadow); overflow: visible;
}
.toolbar-left { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; flex: 1; min-width: 0; }
.toolbar-right { display: flex; gap: 10px; align-items: center; margin-left: auto; position: relative; }
.toolbar-left #btn-store-manage { flex-shrink: 0; white-space: nowrap; }
.store-select {
  padding: 10px 14px; border: 1px solid var(--border-color); border-radius: 8px;
  background: var(--bg-color); color: var(--text-color); font-size: 14px;
  min-width: 220px; cursor: pointer;
}
.store-select:focus { outline: none; border-color: var(--primary-color); }

.btn {
  padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: bold;
  cursor: pointer; border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 6px; transition: all 0.2s;
}
.btn-primary { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-secondary { background: var(--card-bg); color: var(--text-color); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }
.btn-danger { background: var(--danger-color); color: #fff; border-color: var(--danger-color); }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: var(--success-color); color: #fff; border-color: var(--success-color); }
.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: 5px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; margin-bottom: 4px; font-weight: bold; color: var(--text-sub); }
.form-group label .req { color: var(--danger-color); }
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
.form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-color);
  border-radius: 6px; background: var(--bg-color); color: var(--text-color); font-size: 14px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary-color);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11px; color: var(--text-sub); margin-top: 4px; }
.check-row {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px;
  width: auto; max-width: 100%; cursor: pointer; line-height: 1.3; margin: 0;
}
.check-row input[type="checkbox"],
.check-row input[type="radio"],
.form-group input[type="checkbox"],
.form-group input[type="radio"],
.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"],
.fb-kind input[type="checkbox"],
.fb-kind input[type="radio"] {
  width: 18px; height: 18px; min-width: 18px; max-width: 18px;
  padding: 0; margin: 0; flex-shrink: 0; accent-color: var(--primary-color);
  vertical-align: middle;
}
.checkbox-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-color);
}
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--danger-color); }
.search-wrap { padding: 12px 16px 8px; }
.search-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-color);
  border-radius: 8px; background: var(--bg-color); color: var(--text-color); font-size: 14px;
}
.search-input:focus { outline: none; border-color: var(--primary-color); }

/* ----- Tables / lists ----- */
.staff-list-area {
  background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border-color);
  overflow: hidden; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}
.staff-list-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border-color);
  font-size: 14px; font-weight: bold; display: flex; justify-content: space-between; align-items: center;
}
.staff-table-wrap { overflow-x: auto; }
table.staff-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.staff-table th, table.staff-table td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
table.staff-table th { background: var(--bg-color); font-weight: bold; color: var(--text-sub); font-size: 12px; }
table.staff-table tr:hover td { background: rgba(0, 102, 204, 0.04); }
table.staff-table td.actions-cell,
table.staff-table td.staff-name-cell { white-space: normal; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-sub); font-size: 14px; }
.muted { color: var(--text-sub); font-size: 12px; }
.ver-badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: bold; background: rgba(0, 102, 204, 0.1); color: var(--primary-color);
}

/* ----- Badges / alerts ----- */
.alert-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: bold;
  background: #fef3c7; color: #b45309; margin-left: 6px;
}
[data-theme="dark"] .alert-badge { background: #3b2f0a; color: #fbbf24; }
.expired-badge { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .expired-badge { background: #3b1212; color: #f87171; }
.pending-notice {
  background: #fff8e6; border: 1px solid #f0d78c; color: #8a6d00;
  padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 20px; display: none;
}
[data-theme="dark"] .pending-notice { background: #2a2410; border-color: #5c4b1a; color: #e0c56e; }
.alert-banners { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.alert-tag {
  display: none; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; font-weight: bold; cursor: pointer; border: 1px solid transparent; line-height: 1.45;
}
.alert-tag.visible { display: inline-flex; }
.alert-tag.warn { background: #fef3c7; color: #92400e; border-color: #f0d78c; }
.alert-tag.danger { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
[data-theme="dark"] .alert-tag.warn { background: #3b2f0a; color: #fbbf24; border-color: #5c4b1a; }
[data-theme="dark"] .alert-tag.danger { background: #3b1212; color: #f87171; border-color: #5c1a1a; }
.stale-notice {
  background: #fff8e6; border: 1px solid #f0d78c; color: #8a6d00;
  padding: 12px 14px; border-radius: 8px; font-size: 12px; line-height: 1.7; margin-bottom: 12px;
}
[data-theme="dark"] .stale-notice { background: #2a2410; border-color: #5c4b1a; color: #e0c56e; }
.unreg-alert, .import-ok {
  display: none; padding: 12px 16px; border-radius: 8px; font-size: 13px; line-height: 1.6; margin-bottom: 16px;
}
.unreg-alert.visible, .import-ok.visible { display: block; }
.unreg-alert { background: #fff8e6; border: 1px solid #f0d78c; color: #8a6d00; }
.import-ok { background: #ecfdf3; border: 1px solid #86efac; color: #166534; }
[data-theme="dark"] .unreg-alert { background: #2a2410; border-color: #5c4b1a; color: #e0c56e; }
[data-theme="dark"] .import-ok { background: #102a1a; border-color: #1b5c32; color: #86efac; }

/* ----- Modal ----- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: flex; justify-content: center; align-items: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 4000; padding: 20px;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
  background: var(--card-bg); padding: 28px; border-radius: 12px;
  width: 100%; max-width: 640px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  max-height: 90vh; overflow-y: auto;
}
.modal-content.wide { max-width: 780px; }
.modal-content h3 { margin-bottom: 18px; font-size: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.btn-cancel { flex: 1; padding: 11px; background: var(--border-color); border: none; border-radius: 6px; cursor: pointer; color: var(--text-color); font-weight: bold; }
.btn-save { flex: 1; padding: 11px; background: var(--primary-color); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; }
.btn-delete-confirm { flex: 1; padding: 11px; background: var(--danger-color); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; }

.modal-content.preview-modal {
  max-width: min(980px, 96vw); width: 100%; max-height: 96vh; height: 96vh;
  display: flex; flex-direction: column; text-align: center; padding: 16px 20px 14px;
}
.preview-body {
  flex: 1 1 auto; min-height: 0; margin: 10px 0; overflow: auto;
  display: flex; align-items: stretch; justify-content: center;
  background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 8px;
}
.preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; }
.preview-body iframe { width: 100%; height: 100%; min-height: 78vh; border: none; background: #fff; }
.preview-body .preview-fallback { margin: auto; padding: 28px 20px; font-size: 13px; color: var(--text-sub); line-height: 1.7; }

/* ----- Files / tags / settings ----- */
.file-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px dashed var(--border-color);
}
.file-row:last-child { border-bottom: none; }
.file-label { font-size: 12px; font-weight: bold; min-width: 140px; }
.file-status { font-size: 11px; color: var(--text-sub); }
.file-actions { display: flex; gap: 6px; margin-left: auto; }
.file-error { flex: 1 0 100%; color: var(--danger-color); font-size: 11px; }
.file-type-hint { font-size: 13px; color: var(--text-sub); line-height: 1.6; margin-bottom: 12px; }
.upload-legal-notice { flex: 1 0 100%; font-size: 10px; color: var(--text-sub); line-height: 1.55; margin-top: 4px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; position: relative; }
.btn-row-more {
  display: none; min-width: 36px; min-height: 36px; justify-content: center;
  font-size: 16px; font-weight: bold; letter-spacing: 1px;
}
.row-actions-btns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-list { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: bold;
  background: rgba(0, 102, 204, 0.08); color: var(--primary-color);
  border: 1px solid rgba(0, 102, 204, 0.18);
}
.tag-chip .lv { background: var(--primary-color); color: #fff; border-radius: 8px; padding: 0 5px; font-size: 9px; line-height: 16px; }

.settings-block { margin-bottom: 22px; padding-bottom: 8px; }
.form-settings-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px;
  border-bottom: 1px solid var(--border-color);
}
.form-settings-item .item-label {
  flex: 1; font-size: 13px; font-weight: bold; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.mini-badge { font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 4px; background: rgba(0, 102, 204, 0.1); color: var(--primary-color); }
.toggle { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; cursor: pointer; transition: 0.2s;
}
.toggle-slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.toggle input:checked + .toggle-slider { background: var(--primary-color); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle input:disabled + .toggle-slider { opacity: 0.5; cursor: not-allowed; }
.add-item-row { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.add-item-row input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 6px;
  background: var(--bg-color); color: var(--text-color); font-size: 14px;
}
.tag-edit-row {
  display: grid; grid-template-columns: 28px 1fr 120px auto; gap: 8px; margin-bottom: 8px;
  align-items: center; padding: 8px; border: 1px solid var(--border-color); border-radius: 8px;
  background: var(--bg-color); cursor: grab;
}
.tag-edit-row.dragging { opacity: 0.45; }
.tag-handle { font-size: 16px; color: var(--text-sub); text-align: center; user-select: none; letter-spacing: -2px; }
.tag-level-select {
  padding: 8px 6px; border: 1px solid var(--border-color); border-radius: 6px;
  background: var(--card-bg); color: var(--text-color); font-size: 12px;
}
.section-title {
  font-size: 13px; font-weight: bold; color: var(--primary-color);
  margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border-color);
}
.foreign-only { display: none; }
.foreign-only.show { display: block; }
.filter-bar {
  display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 16px; background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 10px; margin-bottom: 16px;
}
.filter-bar select, .filter-bar input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-color);
  border-radius: 8px; background: var(--bg-color); color: var(--text-color); font-size: 13px;
}

/* ----- Signature / agreement ----- */
.signature-pad-wrap { border: 1px solid var(--border-color); border-radius: 8px; background: #fff; margin-top: 8px; }
[data-theme="dark"] .signature-pad-wrap { background: #2a2a2a; }
#signature-canvas { display: block; width: 100%; height: 160px; cursor: crosshair; touch-action: none; }
.sig-actions { display: flex; gap: 8px; margin-top: 8px; }
.sig-preview-wrap {
  margin-top: 10px; padding: 10px; border: 1px dashed var(--border-color);
  border-radius: 8px; background: var(--bg-color); text-align: center;
}
.sig-preview-wrap img { max-width: 100%; max-height: 140px; background: #fff; border-radius: 6px; }
.agreement-preview {
  background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 8px;
  padding: 16px; max-height: 240px; overflow-y: auto; font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; margin-bottom: 12px;
}

/* ----- Store list / edit mode ----- */
.store-list-item { display: block; padding: 0; border-bottom: 1px solid var(--border-color); }
.store-list-item:last-child { border-bottom: none; }
.store-list-item.expanded { border-bottom: none; }
.store-edit-mode-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: rgba(0, 102, 204, 0.06); border: 1px solid rgba(0, 102, 204, 0.18);
  border-radius: 8px; font-size: 13px;
}
.store-add-btn-row { margin-top: 4px; padding-top: 12px; }
.store-add-btn-row .btn { width: 100%; justify-content: center; }

/* ----- Float menus ----- */
.is-hidden { display: none !important; }
.float-menu {
  display: none; position: fixed; z-index: 3200; min-width: 180px;
  max-width: min(320px, calc(100vw - 24px)); padding: 8px;
  background: var(--card-bg); color: var(--text-color);
  border: 1px solid var(--border-color); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.float-menu:not(.is-hidden) { display: block; }
.float-menu .btn { width: 100%; justify-content: flex-start; margin: 2px 0; }
.tag-float-menu { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }
.tag-float-menu:not(.is-hidden) { display: flex; }

/* ----- E-card ----- */
.e-card-enable-copy { flex: 1; min-width: 180px; }
.e-card-enable-copy .ttl { font-size: 13px; font-weight: bold; }
.e-card-visual {
  container-type: inline-size;
  width: min(100%, 91mm);
  aspect-ratio: 91 / 55;
  margin: 8px auto 0;
  background: #fff; color: #1a2332;
  border-radius: 1.6mm; border: 1px solid var(--border-color);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  position: relative; overflow: hidden;
  padding: 4.2cqw 4.8cqw 5.6cqw 7.2cqw;
  display: flex; flex-direction: column; text-align: left; justify-content: flex-start;
}
@media (min-width: 768px) {
  .e-card-visual { width: min(100%, 620px); }
}
.e-card-visual::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2.4cqw; background: var(--primary-color);
}
.e-card-visual::after {
  content: ""; position: absolute; left: 2.4cqw; top: 0; right: 0; height: 1.4cqw; background: var(--primary-color);
}
.e-card-visual.is-off { opacity: 0.55; filter: grayscale(0.25); }
.e-card-head { flex: 0 0 auto; max-width: 74%; text-align: left; }
.e-card-kicker { display: none; }
.e-card-company { font-size: 4.6cqw; font-weight: 800; line-height: 1.2; word-break: break-all; }
.e-card-store { margin-top: 0.5cqw; font-size: 3.1cqw; color: #5b6b7c; word-break: break-all; }
.e-card-no { margin-top: 0.45cqw; font-size: 2.8cqw; color: #64748b; letter-spacing: 0.02em; }
.e-card-divider { display: none; }
.e-card-mid {
  flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center;
  align-items: flex-start; min-height: 0; min-width: 0; width: 100%; padding: 1cqw 0 2.4cqw;
}
.e-card-name {
  font-size: 11.6cqw; font-weight: 800; line-height: 1.08; letter-spacing: 0.05em;
  white-space: nowrap; max-width: 100%; overflow: hidden;
}
.e-card-tags { margin-top: 1.6cqw; display: flex; flex-wrap: wrap; gap: 0.8cqw; padding-top: 0; }
.e-card-chip {
  display: inline-flex; align-items: center; padding: 0.5cqw 1.7cqw; border-radius: 999px;
  font-size: 2.7cqw; font-weight: bold; background: rgba(0, 102, 204, 0.10);
  color: var(--primary-color); border: 1px solid rgba(0, 102, 204, 0.22);
}
.e-card-no-tag { font-size: 2.7cqw; color: #94a3b8; }
.e-card-foot { position: absolute; right: 4.4cqw; bottom: 3.2cqw; text-align: right; max-width: 48%; line-height: 1.25; }
.e-card-email { font-size: 2.7cqw; color: #334155; word-break: break-all; letter-spacing: 0.01em; }
.e-card-time { margin-top: 0.35cqw; font-size: 2.4cqw; color: #94a3b8; }
.e-card-size-note { text-align: center; font-size: 11px; color: var(--text-sub); margin-top: 6px; }
.e-card-link-area { display: none; margin-top: 14px; }
.e-card-link-area.show { display: block; }
.e-card-link-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.e-card-link-row a.btn { text-decoration: none; color: var(--text-color); }
.e-card-link-row input {
  flex: 1; min-width: 180px; padding: 10px 12px; border: 1px solid var(--border-color);
  border-radius: 6px; background: var(--bg-color); color: var(--text-color); font-size: 12px;
}

/* ----- P/L page ----- */
.card-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card .lbl { font-size: 12px; color: var(--text-sub); font-weight: bold; }
.stat-card .val { font-size: 22px; font-weight: 800; margin: 6px 0 4px; letter-spacing: 0.02em; }
.stat-card .sub { font-size: 11px; color: var(--text-sub); }
.stat-card.up .val { color: var(--success-color); }
.stat-card.down .val { color: var(--danger-color); }
.panel {
  background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 16px; margin-bottom: 4px; }
.panel-hint { font-size: 12px; color: var(--text-sub); margin-bottom: 14px; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; min-height: 280px; }
.chart-wrap { position: relative; min-height: 260px; }
table.pl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.pl-table th, table.pl-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-color); text-align: left;
}
table.pl-table th { background: var(--bg-color); color: var(--text-sub); font-size: 12px; }
table.pl-table td.num, table.pl-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.pl-table tr.sec td { font-weight: bold; background: rgba(0, 102, 204, 0.04); }
table.pl-table tr.total td { font-weight: bold; }
table.pl-table td.indent { padding-left: 28px; color: var(--text-sub); }
table.pl-table td.neg { color: var(--danger-color); }
.drop-zone {
  width: 100%; padding: 28px 16px; border: 2px dashed var(--border-color); border-radius: 10px;
  background: var(--bg-color); color: var(--text-sub); cursor: pointer; text-align: center; line-height: 1.7;
}
.drop-zone.drag { border-color: var(--primary-color); background: rgba(0, 102, 204, 0.06); color: var(--primary-color); }

/* ----- Demo banner ----- */
.demo-banner {
  display: none; background: #fff8e6; border: 1px solid #f0d78c; color: #8a6d00;
  padding: 8px 12px; border-radius: 8px; font-size: 12px; margin-bottom: 12px;
}

/* ----- Responsive ----- */
@media (max-width: 1100px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
  .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 1500px) {
  .btn-toolbar-more { display: inline-flex; }
  .toolbar-actions {
    display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
    flex-direction: column; align-items: stretch; min-width: 240px; padding: 10px;
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  }
  .toolbar-actions.open { display: flex; }
  .toolbar-actions .btn { width: 100%; justify-content: flex-start; }
  .btn-row-more { display: inline-flex; }
  .row-actions:has(.btn-row-more) .row-actions-btns { display: none; }
  table.staff-table th:last-child,
  table.staff-table td.actions-cell {
    position: sticky; right: 0; z-index: 2; background: var(--card-bg);
    box-shadow: -6px 0 10px rgba(0, 0, 0, 0.06);
  }
  table.staff-table th:last-child { background: var(--bg-color); }
}
@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; max-height: 80vh; transform: translateY(0); padding: 50px 16px 16px; }
  .sidebar.collapsed { transform: translateY(calc(-100% + 12px)); }
  .toggle-sidebar-btn { top: auto; bottom: -18px; right: 50%; transform: translateX(50%); }
  .main-content { margin-left: 0 !important; padding: 24px 16px; margin-top: 20px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .toolbar:not(.kintai-toolbar):not(.forms-toolbar):not(.toolbox-toolbar):not(.fb-toolbar) {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }
  .toolbar-left {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    flex-wrap: nowrap;
  }
  .toolbar-right {
    flex: 0 0 auto;
    width: auto;
    margin-left: 0;
  }
  .store-select { min-width: 0; flex: 1; width: 100%; }
  .filter-bar { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ----- Complements extracted from employees / documents / retirees ----- */
.arrow-icon { line-height: 1; font-size: 16px; }
.demo-banner {
  background: #e8f1fb; border: 1px solid #b6d4f0; color: #0c4a6e;
  padding: 10px 14px; border-radius: 8px; font-size: 12px; line-height: 1.6; margin-bottom: 16px;
}
[data-theme="dark"] .demo-banner { background: #0c2a40; border-color: #1e4976; color: #7dd3fc; }
.store-list-item-header {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 8px; cursor: pointer; border-radius: 8px;
}
.store-list-item-header:hover { background: rgba(0, 102, 204, 0.05); }
.store-list-item.expanded .store-list-item-header { background: rgba(0, 102, 204, 0.08); }
.store-list-item-tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.store-chevron { font-size: 11px; color: var(--text-sub); padding: 0 4px; }
.store-edit-panel { display: none; padding: 12px; border-top: 1px dashed var(--border-color); }
.store-list-item.expanded .store-edit-panel { display: block; }
.btn-toolbar-more { display: none; }
.toolbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tag-more {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 20px; padding: 0 7px; border-radius: 999px;
  border: 1px solid rgba(0, 102, 204, 0.25); background: var(--card-bg);
  color: var(--primary-color); font-size: 10px; font-weight: bold; cursor: pointer;
}
.tag-more:hover { background: rgba(0, 102, 204, 0.08); }
.e-card-enable-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px; border: 1px solid var(--border-color); border-radius: 8px;
  background: var(--bg-color); margin-bottom: 10px;
}

/* ----- Index / home ----- */
.plan-badge {
  display: inline-block; padding: 4px 10px;
  background: #eef5ff; color: var(--primary-color);
  border-radius: 20px; font-size: 12px; font-weight: bold; margin-bottom: 10px;
}
[data-theme="dark"] .plan-badge { background: #1e293b; }
.btn-upgrade {
  width: 100%; padding: 8px;
  background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
  color: #333; border: none; border-radius: 6px;
  font-size: 13px; font-weight: bold; cursor: pointer; margin-bottom: 10px;
}
.main-header { margin-bottom: 30px; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.menu-card {
  background: var(--card-bg); border-radius: 12px; padding: 28px;
  text-decoration: none; color: inherit; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  border: 2px solid transparent; transition: all 0.2s ease; display: block;
}
.menu-card:hover { transform: translateY(-4px); border-color: var(--primary-color); }
.menu-card .icon { font-size: 36px; margin-bottom: 16px; display: block; }
.menu-card.disabled {
  opacity: 0.45; filter: grayscale(0.8); pointer-events: none;
  cursor: not-allowed; transform: none !important; border-color: transparent !important;
}
.nav-sub a.nav-disabled,
a.nav-disabled {
  opacity: 0.4; pointer-events: none; cursor: not-allowed;
}

/* 2FA / account manage */
.mfa-box { background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 8px; padding: 15px; margin-top: 15px; }
.mfa-status { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; margin-left: 6px; }
.mfa-status.active { background: #eafaf1; color: #27ae60; }
.mfa-status.disabled { background: #fde8e8; color: #e74c3c; }
.step-box { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px dashed var(--border-color); }
.step-box:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.step-number {
  display: inline-block; width: 22px; height: 22px; background: var(--primary-color); color: #fff;
  border-radius: 50%; font-size: 12px; font-weight: bold; text-align: center; line-height: 22px; margin-right: 6px;
}
.step-title { font-size: 13px; font-weight: bold; margin-bottom: 8px; display: flex; align-items: center; }
.app-download-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.app-download-btns a {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px;
  font-size: 13px; font-weight: bold; color: var(--text-color); text-decoration: none;
}
.app-download-btns a:hover { border-color: var(--primary-color); color: var(--primary-color); background: rgba(0,102,204,0.05); }
.emp-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border-color);
}
.emp-info { font-size: 13px; }
.emp-info .role-tag { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--border-color); margin-left: 6px; }
.emp-info .role-tag.admin { background: var(--primary-color); color: #fff; }
.emp-info .role-tag.subadmin { background: #8b5cf6; color: #fff; }
.emp-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn-sm-action { padding: 4px 8px; font-size: 11px; border-radius: 4px; border: 1px solid var(--border-color); cursor: pointer; background: var(--card-bg); color: var(--text-color); }
.btn-sm-action:hover { background: var(--border-color); }
.btn-sm-danger { border-color: var(--danger-color); color: var(--danger-color); }
.btn-sm-danger:hover { background: var(--danger-color); color: #fff; }
.btn-sm-approve { border-color: #27ae60; color: #27ae60; }
.btn-sm-approve:hover { background: #27ae60; color: #fff; }
.btn-sm-yellow { background: #fef3c7; border-color: #f59e0b; color: #b45309; font-weight: bold; }
.btn-sm-yellow:hover { background: #f59e0b; color: #fff; }
.btn-sm-purple { background: #f3e8ff; border-color: #8b5cf6; color: #6d28d9; font-weight: bold; }
.btn-sm-purple:hover { background: #8b5cf6; color: #fff; }
.perm-panel {
  padding: 12px 10px 16px 14px; background: var(--bg-color);
  border-bottom: 1px solid var(--border-color); border-radius: 0 0 6px 6px; margin-bottom: 4px;
}
.perm-panel label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; cursor: pointer; }
.perm-panel input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary-color); }
.role-action-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border-color); }
.company-info-block {
  margin-top: 8px; padding: 14px; border: 1px solid var(--border-color);
  border-radius: 8px; background: var(--bg-color);
}
.company-info-block h4 { font-size: 13px; margin-bottom: 10px; color: var(--primary-color); }
.field-readonly { opacity: 0.85; cursor: default; }



/* 旧版 lock の取り消し（白画面防止） */
html.portal-locked body {
  display: flex !important;
  visibility: visible !important;
}
html.portal-locked { visibility: visible !important; }


#portal-gate {
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  background: var(--bg-color, #f4f7f9);
}
html.portal-checking body { overflow: hidden; }
.nav-sub a.nav-disabled,
a.nav-disabled,
.menu-card.disabled {
  opacity: 0.4 !important;
  filter: grayscale(0.7);
  pointer-events: none !important;
  cursor: not-allowed !important;
}

/* ----- Mobile top bar / hamburger ----- */
.portal-mobile-bar {
  display: none;
}

@media (max-width: 768px) {
  .portal-mobile-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 1200;
    padding: 8px 12px;
    min-height: 52px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }
  .portal-hamburger {
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .portal-mobile-title {
    font-size: 15px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .btn,
  .sidebar-menu button,
  .sidebar-menu a,
  .nav-group-toggle,
  .nav-sub a,
  .toggle-sidebar-btn,
  .btn-cancel,
  .btn-save,
  .btn-delete-confirm {
    min-height: 44px;
  }
  .toggle-sidebar-btn {
    min-width: 44px;
  }
  .btn-sm,
  .btn-sm-action {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 12px;
  }
  .row-actions-btns .btn {
    min-height: 40px;
  }

  /* Tables → card view (labels filled by PortalNav.enhanceResponsiveTables) */
  .staff-table-wrap,
  .panel [style*="overflow"] {
    overflow: visible;
  }
  table.staff-table thead,
  table.pl-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  table.staff-table,
  table.pl-table,
  table.staff-table tbody,
  table.pl-table tbody {
    display: block;
    width: 100%;
  }
  table.staff-table tr,
  table.pl-table tr {
    display: block;
    width: 100%;
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    white-space: normal;
  }
  table.staff-table th,
  table.staff-table td,
  table.pl-table th,
  table.pl-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
    white-space: normal;
    text-align: right;
    position: static;
    box-shadow: none;
    background: transparent;
  }
  table.staff-table td:last-child,
  table.pl-table td:last-child {
    border-bottom: none;
  }
  table.staff-table td::before,
  table.pl-table td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 11px;
    color: var(--text-sub);
    text-align: left;
    flex: 0 0 38%;
    max-width: 42%;
  }
  table.staff-table td.actions-cell,
  table.staff-table td.staff-name-cell {
    flex-wrap: wrap;
  }
  table.staff-table td.actions-cell {
    flex-wrap: nowrap;
    align-items: center;
  }
  table.staff-table td.actions-cell::before {
    flex: 1 1 auto;
    max-width: none;
    margin-bottom: 0;
  }
  table.staff-table td.actions-cell .row-actions {
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
  table.staff-table td.actions-cell:has(.btn-row-more) .row-actions-btns {
    display: none !important;
  }
  table.staff-table td.actions-cell:not(:has(.btn-row-more)) .row-actions-btns {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    justify-content: flex-end;
  }
  table.staff-table td.actions-cell .btn-row-more {
    display: inline-flex !important;
    min-width: 44px;
    min-height: 44px;
  }

  .modal-content {
    padding: 20px 16px;
    max-height: 92vh;
  }
  .modal-actions {
    flex-direction: column;
  }
  .modal-actions .btn-cancel,
  .modal-actions .btn-save,
  .modal-actions .btn-delete-confirm,
  .modal-actions a.btn {
    width: 100%;
    justify-content: center;
  }
  .charts-row,
  .card-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .main-content { padding: 24px 20px; }
  .card-grid { grid-template-columns: 1fr 1fr; }
}

/* ==========================================================================
   Narrow toolbar + row actions
   Earlier .btn-toolbar-more { display:none } / .toolbar-actions { display:flex }
   would override the 1500px rules, so collapse rules stay at the end of the file.
   iPad / Surface など 16:9 以外の画面でも操作ボタンを折りたたむ。
   ========================================================================== */
@media (max-width: 1500px) {
  .toolbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    overflow: visible;
  }
  .toolbar-left {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 8px;
  }
  /* 店舗管理ボタンは操作メニューへ。左カラムに残っても出さない */
  .toolbar-left > .btn:not(#btn-public-link):not(.toolbar-keep),
  .toolbar-left #btn-store-manage {
    display: none !important;
  }
  .toolbar-right {
    position: relative;
    flex: 0 0 auto;
    width: auto;
    margin-left: 0;
    gap: 0;
  }
  .btn-toolbar-more {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 10px 14px;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .toolbar-actions {
    display: none !important;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    z-index: 2800;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 240px;
    width: max-content;
    max-width: min(320px, calc(100vw - 32px));
    padding: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  }
  .toolbar-actions.open {
    display: flex !important;
  }
  .toolbar-actions .btn {
    width: 100%;
    justify-content: flex-start;
    min-height: 44px;
  }

  /* スタッフ行の操作：⋯ だけ表示 */
  .btn-row-more {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }
  .row-actions:has(.btn-row-more) .row-actions-btns {
    display: none !important;
  }
  table.staff-table th:last-child,
  table.staff-table td.actions-cell {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--card-bg);
    box-shadow: -6px 0 10px rgba(0, 0, 0, 0.06);
  }
  table.staff-table th:last-child { background: var(--bg-color); }
}

@media (max-width: 768px) {
  .toolbar:not(.kintai-toolbar):not(.forms-toolbar):not(.toolbox-toolbar):not(.fb-toolbar) {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
  }
  .toolbar-left,
  .toolbar-right {
    width: auto;
  }
  .store-select {
    min-width: 0;
    width: 100%;
    flex: 1;
  }
  table.staff-table th:last-child,
  table.staff-table td.actions-cell {
    position: static;
    box-shadow: none;
    background: transparent;
  }
  table.staff-table td.actions-cell {
    flex-wrap: nowrap;
    align-items: center;
  }
  table.staff-table td.actions-cell::before {
    flex: 1 1 auto;
    max-width: none;
    margin-bottom: 0;
  }
  table.staff-table td.actions-cell:has(.btn-row-more) .row-actions-btns {
    display: none !important;
  }
  table.staff-table td.actions-cell:not(:has(.btn-row-more)) .row-actions-btns {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    justify-content: flex-end;
  }
  table.staff-table td.actions-cell .btn-row-more {
    display: inline-flex !important;
  }
}




/* ----- Attendance / toolbox ----- */
.kintai-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.kintai-stat {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.kintai-stat .lbl { font-size: 11px; color: var(--text-sub); font-weight: bold; }
.kintai-stat .val { font-size: 20px; font-weight: 800; margin-top: 4px; letter-spacing: 0.02em; }
.kintai-stat .sub { font-size: 11px; color: var(--text-sub); margin-top: 2px; }
.kintai-warn-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.kintai-warn {
  padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.55;
  border: 1px solid transparent;
}
.kintai-warn.danger { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.kintai-warn.warn { background: #fef3c7; color: #92400e; border-color: #f0d78c; }
.kintai-warn.info { background: #e8f1fb; color: #0c4a6e; border-color: #b6d4f0; }
[data-theme="dark"] .kintai-warn.danger { background: #3b1212; color: #f87171; border-color: #5c1a1a; }
[data-theme="dark"] .kintai-warn.warn { background: #3b2f0a; color: #fbbf24; border-color: #5c4b1a; }
[data-theme="dark"] .kintai-warn.info { background: #0c2a40; color: #7dd3fc; border-color: #1e4976; }
table.staff-table tbody tr.kintai-over-28 td {
  background: #fee2e2;
}
table.staff-table tbody tr.kintai-over-28:hover td {
  background: #fecaca;
}
table.staff-table tbody tr.kintai-over-28 {
  background: #fee2e2;
  border-color: #f5b5b5;
}
[data-theme="dark"] table.staff-table tbody tr.kintai-over-28 td {
  background: #3b1212;
}
[data-theme="dark"] table.staff-table tbody tr.kintai-over-28:hover td {
  background: #4a1818;
}
[data-theme="dark"] table.staff-table tbody tr.kintai-over-28 {
  background: #3b1212;
  border-color: #5c1a1a;
}
.kintai-over-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  background: #b91c1c;
  color: #fff;
  vertical-align: middle;
  white-space: nowrap;
}
.kintai-over-note {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #b91c1c;
  margin-top: 2px;
  white-space: normal;
  line-height: 1.4;
}
[data-theme="dark"] .kintai-over-note { color: #f87171; }
.kintai-stat.is-over {
  border-color: #fecaca;
  background: #fff5f5;
}
.kintai-stat.is-over .val { color: var(--danger-color); }
[data-theme="dark"] .kintai-stat.is-over {
  border-color: #5c1a1a;
  background: #2a1010;
}
.leave-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: bold;
}
.leave-chip.public { background: rgba(0,102,204,.1); color: var(--primary-color); }
.leave-chip.paid { background: #ecfdf3; color: #166534; }
.leave-chip.absence { background: #fee2e2; color: #b91c1c; }
.leave-chip.other { background: #f3e8ff; color: #6d28d9; }
.icon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.icon-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 108px; padding: 16px 10px;
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 14px; text-decoration: none; color: var(--text-color);
  box-shadow: var(--shadow); cursor: pointer;
}
.icon-tile:hover { border-color: var(--primary-color); transform: translateY(-2px); }
.icon-tile .ico { font-size: 32px; line-height: 1; }
.icon-tile .ttl { font-size: 12px; font-weight: 800; text-align: center; line-height: 1.4; }
.staff-open-shell {
  max-width: 520px; margin: 0 auto; padding: 24px 16px 48px;
}
.staff-open-card {
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 16px; padding: 22px 18px; box-shadow: var(--shadow);
}
.punch-types {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0;
}
.punch-types label {
  display: flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 10px;
  background: var(--bg-color); cursor: pointer; font-size: 13px; font-weight: bold;
}
.punch-types input { accent-color: var(--primary-color); width: 18px; height: 18px; }
.punch-log { font-size: 13px; line-height: 1.7; color: var(--text-sub); }
.tb-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px; border: 1px solid var(--border-color); border-radius: 10px;
  background: var(--bg-color); margin-bottom: 8px;
}
.icon-pick { display: none; flex-wrap: wrap; gap: 6px; flex: 1 0 100%; }
.icon-pick.is-open { display: flex; }
.icon-pick button {
  min-width: 40px; min-height: 40px; border: 1px solid var(--border-color);
  background: var(--card-bg); border-radius: 8px; cursor: pointer; font-size: 18px;
}
.icon-pick button.active { border-color: var(--primary-color); background: rgba(0,102,204,.08); }
.qr-box { text-align: center; padding: 12px; }
.qr-box img { width: 220px; height: 220px; background: #fff; border-radius: 8px; padding: 8px; }
.sig-pad {
  width: 100%; height: 160px; border: 1px solid var(--border-color);
  border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair;
}
[data-theme="dark"] .sig-pad { background: #2a2a2a; }
.range-toggle { display: flex; gap: 8px; margin-bottom: 10px; }
.range-toggle button { flex: 1; }

.kintai-period-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.kintai-month {
  min-width: 148px !important;
  width: auto !important;
  flex: 0 0 auto;
}
.btn-icon-cal {
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  padding: 10px 12px;
  flex-shrink: 0;
}
.filter-bar.kintai-filter {
  grid-template-columns: 1fr minmax(180px, 280px);
  align-items: center;
}
.punch-types label:has(input:checked) {
  border-color: var(--primary-color);
  background: rgba(0, 102, 204, 0.08);
  color: var(--primary-color);
}
.kintai-stat .val { font-variant-numeric: tabular-nums; }
.icon-tile:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
@media (max-width: 1100px) {
  .kintai-summary { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1500px) {
  .kintai-period-tools {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .kintai-month {
    min-width: 0 !important;
    width: 132px !important;
    padding: 10px 8px;
  }
  .filter-bar.kintai-filter {
    grid-template-columns: 1fr;
  }
  .kintai-period-tools .toolbar-actions {
    display: none !important;
  }
  .kintai-period-tools .toolbar-actions.open {
    display: flex !important;
  }
  .kintai-period-tools .btn-toolbar-more {
    display: inline-flex !important;
  }
}
@media (max-width: 768px) {
  .kintai-summary { grid-template-columns: 1fr 1fr; }
  .icon-grid { gap: 10px; }
  .icon-tile { min-height: 96px; }
}

/* iPad / Surface 向け：JS が html.portal-compact を付与 */
html.portal-compact .btn-toolbar-more {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}
html.portal-compact .toolbar-actions {
  display: none !important;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: auto;
  z-index: 2800;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 240px;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  padding: 8px;
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
html.portal-compact .toolbar-actions.open {
  display: flex !important;
}
html.portal-compact .toolbar-actions .btn {
  width: 100%;
  justify-content: flex-start;
  min-height: 44px;
}
html.portal-compact .toolbar-left > .btn:not(#btn-public-link):not(.toolbar-keep),
html.portal-compact .toolbar-left #btn-store-manage {
  display: none !important;
}
html.portal-compact .btn-row-more {
  display: inline-flex !important;
  min-width: 44px;
  min-height: 44px;
}
html.portal-compact .row-actions:has(.btn-row-more) .row-actions-btns {
  display: none !important;
}

.store-tag-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.store-tag-row input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 14px;
}
.tb-preset {
  min-width: 180px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 13px;
}
.tag-source {
  font-size: 10px;
  color: var(--text-sub);
  margin-left: 4px;
}
@media (max-width: 768px) {
  .store-tag-row { grid-template-columns: 1fr; }
}

/* ----- Notifications ----- */
.main-header-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.notify-mount { flex-shrink: 0; }
.notify-wrap { position: relative; }
.notify-bell {
  position: relative; min-width: 44px; min-height: 44px;
  border: 1px solid var(--border-color); background: var(--card-bg);
  border-radius: 10px; cursor: pointer; font-size: 18px; color: var(--text-color);
}
.notify-bell:hover { border-color: var(--primary-color); }
.notify-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--danger-color); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
}
.notify-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  width: min(360px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.12);
}
.notify-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border-color); gap: 8px;
}
.notify-list { list-style: none; }
.notify-item a {
  display: block; padding: 12px 14px; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border-color);
}
.notify-item a strong { display: block; font-size: 13px; margin-bottom: 4px; }
.notify-item a span { display: block; font-size: 12px; color: var(--text-sub); line-height: 1.5; }
.notify-item.is-read { opacity: .55; }
.notify-item.lv-danger a strong { color: var(--danger-color); }
.notify-item.lv-warn a strong { color: #b45309; }
.notify-empty { padding: 24px 14px; text-align: center; color: var(--text-sub); font-size: 13px; }

/* ----- Forms list / builder ----- */
.form-row-done td { color: var(--text-sub); background: var(--bg-color); }
.form-row-done { opacity: .72; }
tr.form-row-pending td { font-weight: 600; }
.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800;
}
.status-pill.pending { background: #fef3c7; color: #92400e; }
.status-pill.approved { background: #ecfdf3; color: #166534; }
.status-pill.rejected { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .status-pill.pending { background: #3b2f0a; color: #fbbf24; }
[data-theme="dark"] .status-pill.approved { background: #0f2a1a; color: #86efac; }
[data-theme="dark"] .status-pill.rejected { background: #3b1212; color: #f87171; }
.new-drop { position: relative; display: inline-block; }
.new-drop-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px;
  background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1); padding: 6px; display: none;
}
.new-drop.open .new-drop-menu { display: block; }
.new-drop-menu button, .new-drop-menu a {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
  color: var(--text-color); text-decoration: none;
}
.new-drop-menu button:hover, .new-drop-menu a:hover { background: var(--bg-color); }

.rte-dock {
  position: relative;
  z-index: 6;
  background: transparent;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
}
.rte-toolbar {
  position: relative; top: auto; z-index: 1;
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 8px 10px; margin: 0;
  background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,.06);
}
.rte-a-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px;
}
.rte-a-btn {
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; align-self: flex-start;
  font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 800;
  line-height: 1;
}
.rte-collapsed-label {
  display: none; flex: 1; font-size: 13px; font-weight: 700; color: var(--text-sub);
  line-height: 1.4; text-align: left;
}
.rte-toolbar.is-collapsed .rte-collapsed-label { display: block; }
.rte-toolbar.is-collapsed .rte-a-row { cursor: pointer; }
.rte-tools {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: 100%;
}
.rte-tools[hidden] { display: none !important; }
.rte-toolbar.is-collapsed .rte-tools { display: none !important; }
.rte-toolbar button {
  min-height: 36px; min-width: 36px; padding: 6px 10px; border: 1px solid var(--border-color);
  background: var(--bg-color); border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 700;
  color: var(--text-color); line-height: 1; text-align: left;
}
.rte-toolbar button:hover { border-color: var(--primary-color); color: var(--primary-color); }
.rte-toolbar .rte-tools > button,
.rte-toolbar .rte-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}
.rte-ico { font-weight: 800; line-height: 1; }
.rte-lbl { font-weight: 700; }
.rte-toolbar .rte-b { font-weight: 800; font-family: Georgia, "Times New Roman", serif; }
.rte-toolbar .rte-i { font-style: italic; font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
.rte-toolbar .rte-u { text-decoration: underline; text-underline-offset: 2px; }
.rte-sep {
  width: 1px; height: 22px; background: var(--border-color); margin: 0 4px; flex-shrink: 0;
}
.rte-menu { position: relative; display: block; width: 100%; }
.rte-menu-btn { font-size: 12px !important; width: 100%; }
.rte-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
  min-width: 140px; padding: 6px;
  background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.rte-pop[hidden], .rte-pop-colors[hidden] { display: none !important; }
.rte-pop button {
  display: block; width: 100%; text-align: left; min-height: 36px;
  margin: 0 0 4px; padding: 6px 10px;
}
.rte-pop button:last-child { margin-bottom: 0; }
.rte-pop-colors {
  display: flex; flex-direction: column; gap: 2px; padding: 6px; min-width: 148px;
  max-height: 280px; overflow: auto;
}
.rte-color-row {
  display: flex !important; align-items: center; gap: 8px; width: 100% !important;
  justify-content: flex-start; margin: 0 !important;
}
.rte-color-name { font-size: 12px; font-weight: 700; color: var(--text-color); }
.rte-swatch,
.rte-pop-colors .rte-swatch,
.rte-color-row .rte-swatch {
  width: 22px !important; height: 22px !important; min-width: 22px !important; min-height: 22px !important;
  padding: 0 !important; margin: 0; display: inline-block;
  border-radius: 6px; border: 1px solid var(--border-color); flex-shrink: 0;
}
.rte-toolbar .rte-swatch-ink, .rte-swatch-ink { background: #111111 !important; }
.rte-toolbar .rte-swatch-paper, .rte-swatch-paper { background: #ffffff !important; }
.rte-toolbar .rte-swatch-gray, .rte-swatch-gray { background: #6b7280 !important; }
.rte-toolbar .rte-swatch-red, .rte-swatch-red { background: #dc2626 !important; }
.rte-toolbar .rte-swatch-orange, .rte-swatch-orange { background: #ea580c !important; }
.rte-toolbar .rte-swatch-yellow, .rte-swatch-yellow { background: #ca8a04 !important; }
.rte-toolbar .rte-swatch-green, .rte-swatch-green { background: #16a34a !important; }
.rte-toolbar .rte-swatch-teal, .rte-swatch-teal { background: #0d9488 !important; }
.rte-toolbar .rte-swatch-blue, .rte-swatch-blue { background: #2563eb !important; }
.rte-toolbar .rte-swatch-navy, .rte-swatch-navy { background: #1e3a8a !important; }
.rte-toolbar .rte-swatch-purple, .rte-swatch-purple { background: #7c3aed !important; }
.rte-toolbar .rte-swatch-pink, .rte-swatch-pink { background: #db2777 !important; }
.rte-toolbar .rte-swatch-brown, .rte-swatch-brown { background: #92400e !important; }
.rte-toolbar .rte-swatch-olive, .rte-swatch-olive { background: #4d7c0f !important; }
.rte-toolbar .rte-swatch-sky, .rte-swatch-sky { background: #0284c7 !important; }
.rte-toolbar .rte-swatch-wine, .rte-swatch-wine { background: #9f1239 !important; }
.rte-editor .rte-c-ink, .rte-view .rte-c-ink { color: var(--rte-c-ink); }
.rte-editor .rte-c-paper, .rte-view .rte-c-paper {
  color: #ffffff; background-color: #1e293b; border-radius: 2px; padding: 0 0.18em;
}
[data-theme="dark"] .rte-editor .rte-c-paper,
[data-theme="dark"] .rte-view .rte-c-paper {
  color: #0f172a; background-color: #e2e8f0;
}
.rte-editor .rte-c-gray, .rte-view .rte-c-gray { color: var(--rte-c-gray); }
.rte-editor .rte-c-red, .rte-view .rte-c-red { color: var(--rte-c-red); }
.rte-editor .rte-c-orange, .rte-view .rte-c-orange { color: var(--rte-c-orange); }
.rte-editor .rte-c-yellow, .rte-view .rte-c-yellow { color: var(--rte-c-yellow); }
.rte-editor .rte-c-green, .rte-view .rte-c-green { color: var(--rte-c-green); }
.rte-editor .rte-c-teal, .rte-view .rte-c-teal { color: var(--rte-c-teal); }
.rte-editor .rte-c-blue, .rte-view .rte-c-blue { color: var(--rte-c-blue); }
.rte-editor .rte-c-navy, .rte-view .rte-c-navy { color: var(--rte-c-navy); }
.rte-editor .rte-c-purple, .rte-view .rte-c-purple { color: var(--rte-c-purple); }
.rte-editor .rte-c-pink, .rte-view .rte-c-pink { color: var(--rte-c-pink); }
.rte-editor .rte-c-brown, .rte-view .rte-c-brown { color: var(--rte-c-brown); }
.rte-editor .rte-c-olive, .rte-view .rte-c-olive { color: var(--rte-c-olive); }
.rte-editor .rte-c-sky, .rte-view .rte-c-sky { color: var(--rte-c-sky); }
.rte-editor .rte-c-wine, .rte-view .rte-c-wine { color: var(--rte-c-wine); }
.rte-editor .rte-s-sm, .rte-view .rte-s-sm { font-size: 12px; }
.rte-editor .rte-s-md, .rte-view .rte-s-md { font-size: 14px; }
.rte-editor .rte-s-lg, .rte-view .rte-s-lg { font-size: 18px; }
.rte-editor .rte-s-xl, .rte-view .rte-s-xl { font-size: 24px; }
.rte-editor i, .rte-editor em, .rte-view i, .rte-view em {
  font-style: italic;
  font-synthesis: style;
}
.rte-editor {
  min-height: 88px; max-width: 100%; padding: 10px 12px; border: 1px solid var(--border-color);
  border-radius: 8px; background: var(--card-bg); color: var(--text-color);
  font-size: 14px; line-height: 1.6; outline: none;
  overflow-x: hidden; overflow-y: auto; word-break: break-word; overflow-wrap: anywhere;
}
.rte-editor:focus { border-color: var(--primary-color); }
.rte-editor ul, .rte-editor ol {
  display: block; width: auto; max-width: 100%;
  margin: 6px 0; padding: 0 0 0 1.6em;
  list-style-position: outside;
}
.rte-editor ul { list-style-type: disc; }
.rte-editor ol { list-style-type: decimal; }
.rte-editor li {
  display: list-item; margin: 2px 0;
  overflow-wrap: anywhere; word-break: break-word;
}
.rte-view { font-size: 14px; line-height: 1.7; margin: 8px 0 12px; overflow-wrap: anywhere; }
.rte-view a { color: var(--primary-color); }
.rte-view ul, .rte-view ol { margin: 6px 0; padding-left: 1.6em; }
.rte-embed { position: relative; padding-top: 56.25%; margin: 10px 0; background: #000; border-radius: 8px; overflow: hidden; }
.rte-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.rte-view img, .rte-editor img { max-width: 100%; border-radius: 8px; }

.fb-work { min-width: 0; }
.fb-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 252px; gap: 16px; align-items: start;
}
.fb-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}
.fb-pane-index { flex: 1 1 auto; }
.fb-rail {
  position: sticky; top: 8px; z-index: 6;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 16px); min-width: 0; overflow: visible;
}
.fb-index {
  position: relative; top: auto; z-index: 5;
  flex: 1 1 auto; min-height: 0; overflow: auto;
  background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
  padding: 12px; box-shadow: var(--shadow);
}
.fb-index-title { font-size: 12px; font-weight: 800; color: var(--text-sub); margin-bottom: 8px; letter-spacing: .04em; }
.fb-index a, .fb-index button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--text-color);
  font-size: 12px; text-decoration: none; line-height: 1.4;
}
.fb-index a:hover, .fb-index button:hover { background: var(--bg-color); color: var(--primary-color); }
.fb-index .idx-sec { font-weight: 800; margin-top: 8px; }
.fb-index .idx-q { padding-left: 16px; color: var(--text-sub); }

.fb-kind {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px;
}
.fb-kind label {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 8px 14px; border: 1px solid var(--border-color); border-radius: 10px; cursor: pointer;
  background: var(--bg-color); font-weight: 700; font-size: 13px;
}
.fb-kind label:has(input:checked) { border-color: var(--primary-color); background: rgba(0,102,204,.08); color: var(--primary-color); }

.fb-section {
  border: 1px solid var(--border-color); border-radius: 16px; padding: 20px 18px 16px;
  background: var(--card-bg); margin-bottom: 20px; box-shadow: var(--shadow);
  scroll-margin-top: 72px;
}
.fb-q {
  border: 1px solid var(--border-color); border-radius: 12px; padding: 14px;
  background: var(--bg-color); margin-bottom: 12px; scroll-margin-top: 72px;
}
.fb-sec-head, .fb-q-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px;
}
.fb-sec-label { font-size: 22px; font-weight: 800; letter-spacing: .02em; line-height: 1.2; }
.fb-q-foot {
  display: flex; justify-content: flex-end; align-items: center; margin-top: 8px;
}
.req-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 800; cursor: pointer; min-height: 36px; color: var(--text-color);
}
.req-toggle input[type="checkbox"] {
  width: 18px !important; height: 18px !important; min-width: 18px !important; max-width: 18px !important;
  padding: 0 !important; margin: 0;
}

.opt-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.opt-row {
  display: flex; align-items: center; gap: 8px;
}
.opt-num {
  flex: 0 0 28px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: var(--text-sub);
}
.opt-row .q-opt { flex: 1; min-width: 0; }
.opt-row .btn-del-opt { flex-shrink: 0; }
.q-check-mode, .q-dir-filter {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 8px 0 4px;
}
.q-check-mode[hidden], .q-dir-filter[hidden], .q-opts[hidden], .q-max-wrap[hidden] {
  display: none !important;
}
.q-max-wrap {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--text-sub);
}
.q-max-wrap input {
  width: 72px !important; min-width: 72px; padding: 8px 10px;
}
.tag-chip-pick { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.tag-chip-pick .check-row {
  padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 999px; background: var(--card-bg);
}

.fill-form h2 { font-size: 20px; margin-bottom: 8px; }
.fill-form h3 { font-size: 16px; margin: 16px 0 8px; }
.fill-form h4 { font-size: 14px; margin: 12px 0 6px; }
.fill-sec { margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px dashed var(--border-color); }
.fill-q { margin-bottom: 14px; }
.fill-q .check-row { display: flex; margin: 6px 0; }
.fill-input, .fill-q select, .fill-q textarea, .fill-q input[type=number] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-color);
  border-radius: 8px; background: var(--card-bg); color: var(--text-color); font-size: 14px;
}
.fill-tag-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.fill-tag-filter button {
  min-height: 32px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-color);
  background: var(--bg-color); color: var(--text-color); cursor: pointer; font-size: 11px; font-weight: 700;
}
.fill-tag-filter button.on { border-color: var(--primary-color); background: rgba(0,102,204,.08); color: var(--primary-color); }
.sig-preview { max-width: 280px; border: 1px solid var(--border-color); border-radius: 8px; background: #fff; }

.survey-expired { opacity: .65; }
.progress-bar {
  height: 8px; background: var(--border-color); border-radius: 99px; overflow: hidden; min-width: 80px;
}
.progress-bar > span { display: block; height: 100%; background: var(--primary-color); }
.store-progress { margin: 8px 0; }
.store-progress summary {
  cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-color);
  min-height: 44px; align-items: center; font-size: 13px; font-weight: 700;
}
.staff-progress { padding: 8px 4px 4px; }
.staff-progress li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px;
  border-bottom: 1px solid var(--border-color); flex-wrap: wrap;
}
.kind-tag {
  display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
  background: rgba(0,102,204,.1); color: var(--primary-color);
}
.staff-switch {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.staff-switch .store-select { min-width: 180px; flex: 1; }
.staff-switch .btn { min-width: 44px; min-height: 44px; justify-content: center; padding: 8px 12px; }
.fill-file-wrap { margin-top: 6px; }
.fill-file-picked, .fill-file-existing { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; }
.fill-file-existing li, .fill-file-picked li {
  display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap;
}
.fill-file-thumb {
  width: 56px; height: 56px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border-color); flex-shrink: 0; background: var(--bg-color);
}
.fill-daterange {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.fill-daterange label, .fill-timerange label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--text-color);
}
.fill-timerange {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.fill-datetime {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.fill-time {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.fill-time select {
  min-height: 44px; min-width: 68px; padding: 8px 10px;
  border: 1px solid var(--border-color); border-radius: 8px;
  background: var(--bg-color); color: var(--text-color); font-size: 16px;
}
.fill-time-unit { font-size: 13px; font-weight: 700; }
.fill-duration {
  margin: 8px 0 0; font-size: 14px; font-weight: 800; color: var(--primary-color);
}
.fill-duration.is-empty { color: var(--text-sub); font-weight: 700; }
.q-num-range { align-items: end; }
.staff-progress .btn-del-ans { min-height: 44px; }
.fb-audience {
  margin: 8px 0 4px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-color);
}
.fb-audience .store-select { min-width: 180px; max-width: 100%; }
.fb-audience .tag-chip-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-audience .check-row { min-height: 44px; }
.staff-ans-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.staff-progress .btn-view-ans { min-height: 44px; margin-left: 0; }

@media (max-width: 768px) {
  .main-header-row { flex-wrap: wrap; }
  .notify-panel { right: auto; left: 0; }
  .staff-switch { width: 100%; }
  .staff-switch .store-select { min-width: 0; }
  .fill-daterange, .fill-timerange { grid-template-columns: 1fr; }
}


/* ----- Narrow toolbar stacks + form-builder bookmark rail ----- */
.kintai-toolbar,
.forms-toolbar,
.toolbox-toolbar,
.fb-toolbar {
  align-items: center;
}
.kintai-store,
.kintai-staff,
.forms-filters,
.forms-search,
.toolbox-link,
.fb-tpl {
  display: contents;
}
.kintai-ops,
.forms-new,
.toolbox-edit,
.fb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.fb-rail-tab { display: none; }
.fb-rail-backdrop { display: none; }
.fb-rail-head { display: none; }
.fb-rail-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
}

.form-row-actions {
  display: flex !important;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

@media (max-width: 900px) {
  .kintai-toolbar,
  .forms-toolbar,
  .toolbox-toolbar,
  .fb-toolbar {
    flex-direction: column !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    gap: 10px !important;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    overflow: visible;
  }
  .kintai-toolbar .toolbar-block,
  .forms-toolbar .toolbar-block,
  .toolbox-toolbar .toolbar-block,
  .fb-toolbar .toolbar-block {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    box-shadow: var(--shadow);
  }
  .kintai-store .store-select,
  .kintai-staff .store-select,
  .forms-filters .store-select,
  .forms-search .search-input,
  .fb-tpl .store-select {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }
  .forms-filters .store-select { flex: 1 1 calc(50% - 4px); }
  .kintai-ops {
    justify-content: flex-start;
    position: relative;
    margin-left: 0;
  }
  .kintai-ops .btn,
  .kintai-ops .kintai-month {
    min-height: 44px;
  }
  .kintai-ops .kintai-month {
    flex: 1 1 140px;
    min-width: 0 !important;
    width: auto !important;
  }
  .kintai-ops #btn-staff-prev,
  .kintai-ops #btn-staff-next {
    min-width: 44px;
    flex: 0 0 44px;
    justify-content: center;
    padding: 8px;
  }
  .kintai-ops .btn-toolbar-more {
    flex: 0 0 auto;
  }
  .forms-new,
  .toolbox-link,
  .toolbox-edit,
  .fb-actions {
    margin-left: 0;
  }
  .forms-new .new-drop,
  .forms-new .btn,
  .toolbox-link .btn,
  .toolbox-toolbar .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    display: inline-flex !important;
  }
  .forms-new .new-drop-menu {
    left: 0;
    right: 0;
    min-width: 0;
    width: 100%;
  }
  .toolbox-edit .btn { flex: 1 1 calc(50% - 4px); width: auto; }
  .fb-actions .btn {
    flex: 1 1 calc(33% - 6px);
    min-height: 44px;
    justify-content: center;
  }
  html.portal-compact .toolbox-toolbar .btn,
  html.portal-compact #btn-public-link,
  html.portal-compact .toolbar-keep,
  html.portal-compact .fb-toolbar .btn {
    display: inline-flex !important;
  }
  html.portal-compact .kintai-toolbar .toolbar-block .btn {
    display: inline-flex !important;
  }

  .page-form-builder .fb-layout {
    grid-template-columns: 1fr;
  }
  .fb-rail-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 0;
    z-index: 3510;
    width: 36px;
    min-width: 36px;
    min-height: 108px;
    padding: 14px 0;
    border: 1px solid var(--border-color);
    border-right: 0;
    border-radius: 14px 0 0 14px;
    background: var(--primary-color);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.22em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    cursor: pointer;
    box-shadow: -4px 6px 18px rgba(0, 0, 0, 0.18);
    transition: right 0.22s ease;
  }
  .fb-tab-format { top: 16vh; }
  .fb-tab-index {
    top: calc(16vh + 124px);
    background: #0b4f8a;
  }
  .fb-rail-tab:hover,
  .fb-rail-tab:focus-visible {
    filter: brightness(1.06);
    outline: none;
  }
  body.fb-format-open .fb-rail-tab { right: 80px; }
  body.fb-index-open .fb-rail-tab { right: min(280px, 82vw); }
  .fb-rail {
    position: fixed !important;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(280px, 82vw);
    z-index: 3500;
    order: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 16px 12px 20px;
    background: var(--bg-color);
    border: 0;
    border-left: 1px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
    overflow: auto;
    transform: translateX(100%);
    transition: transform 0.22s ease, width 0.22s ease;
    max-height: none;
    pointer-events: none;
  }
  .fb-rail.is-open-format,
  .fb-rail.is-open-index {
    transform: translateX(0);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
  }
  .fb-rail.is-open-format {
    width: 80px;
    padding: 12px 8px 16px;
    overflow: visible;
  }
  .fb-rail.is-open-index {
    width: min(280px, 82vw);
    overflow: auto;
  }
  .fb-rail.is-open-format .fb-pane-index,
  .fb-rail.is-open-index .fb-pane-format {
    display: none;
  }
  .fb-rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
  }
  .fb-rail.is-open-format .fb-rail-head { display: none; }
  .fb-rail-head strong {
    font-size: 14px;
    letter-spacing: 0.04em;
  }
  .fb-rail.is-open-index .fb-index {
    flex: 1 1 auto;
    max-height: none;
    box-shadow: none;
  }
  .fb-rail-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 3490;
    background: rgba(0, 0, 0, 0.35);
  }
  .fb-rail-backdrop[hidden] { display: none !important; }
  body.fb-rail-open { overflow: hidden; }
  body.fb-format-open { overflow: auto; }

  .fb-rail.is-open-format .rte-a-row { display: none !important; }
  .fb-rail.is-open-format .rte-toolbar {
    padding: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    gap: 0;
  }
  .fb-rail.is-open-format .rte-toolbar.is-collapsed .rte-tools,
  .fb-rail.is-open-format .rte-tools[hidden],
  .fb-rail.is-open-format .rte-tools {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
  }
  .fb-rail.is-open-format .rte-menu { width: auto; position: relative; }
  .fb-rail.is-open-format .rte-tools > button,
  .fb-rail.is-open-format .rte-tools > .rte-menu > .rte-menu-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 16px !important;
    gap: 0;
  }
  .fb-rail.is-open-format .rte-lbl { display: none; }
  .fb-rail.is-open-format .rte-ico { margin: 0; font-size: 16px !important; }
  .fb-rail.is-open-format .rte-pop {
    right: calc(100% + 8px);
    left: auto;
    top: 0;
    min-width: 148px;
  }
  .fb-rail.is-open-format .rte-pop button {
    width: 100%;
    height: auto;
    min-height: 36px;
    min-width: 0;
    padding: 6px 10px;
    justify-content: flex-start;
    font-size: 13px;
  }

  td.actions-cell:not(:has(.btn-row-more)) {
    flex-direction: column;
    align-items: stretch;
  }
  td.actions-cell:not(:has(.btn-row-more)) .row-actions-btns {
    width: 100%;
  }
  td.actions-cell:not(:has(.btn-row-more)) .row-actions-btns .btn {
    min-height: 44px;
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* ----- Form fill cards / section jump / end messages (v21) ----- */
.fill-form .fill-intro {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border-color);
}
.fill-form .fill-sec {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}
.fill-form .fill-sec-head {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: rgba(0, 102, 204, 0.06);
  border: 1px solid rgba(0, 102, 204, 0.18);
  border-radius: 12px;
}
.fill-form .fill-sec-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--primary-color);
  margin-bottom: 4px;
}
.fill-form .fill-q {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px 16px 14px;
  margin: 0 0 18px;
  box-shadow: var(--shadow);
}
.fill-form .fill-q-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 4px 16px;
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.fill-form .fill-q-rule::before,
.fill-form .fill-q-rule::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--border-color);
  border-radius: 99px;
}
.fill-form .fill-q-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 8px;
  margin-bottom: 8px;
  border-radius: 999px;
  background: rgba(0, 102, 204, 0.1);
  color: var(--primary-color);
  font-size: 11px;
  font-weight: 800;
}
.fill-form .fill-q-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
  line-height: 1.4;
}
.fill-end {
  padding: 22px 18px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--bg-color);
  text-align: left;
}
.fill-end h3 {
  font-size: 20px;
  margin-bottom: 10px;
}
.fill-nav {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.fill-nav .btn {
  min-height: 44px;
  flex: 1 1 140px;
  justify-content: center;
}
.fill-progress-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.fb-sec-jump {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  background: var(--bg-color);
}
.fb-sec-jump label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.fb-sec-jump select,
.opt-row .q-opt-goto {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 13px;
  font-weight: 700;
}
.opt-row {
  flex-wrap: wrap;
}
.opt-row .q-opt-goto {
  flex: 1 1 180px;
  min-width: 160px;
  width: auto;
}
.q-branch-row {
  margin: 8px 0 4px;
}
.fb-end {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px 18px 16px;
  background: var(--card-bg);
  margin: 12px 0 16px;
  box-shadow: var(--shadow);
}
.fb-end-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.fb-end-label {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary-color);
}

.btn-new-plus { font-size: 16px; line-height: 1; }
.btn-new-full { white-space: nowrap; }

@media (max-width: 900px) {
  .forms-new #btn-new .btn-new-full,
  .forms-new .btn-new-full {
    display: none !important;
  }
  .forms-new #btn-new,
  .forms-new .btn-new-compact {
    min-width: 44px !important;
    width: 44px !important;
    flex: 0 0 44px !important;
    padding: 8px !important;
    justify-content: center !important;
    margin-left: auto;
  }
  .forms-new .new-drop {
    width: auto !important;
    display: flex;
    justify-content: flex-end;
  }
  .forms-new {
    justify-content: flex-end !important;
  }
}

.preview-hub {
  display: flex;
  min-height: 100vh;
  width: 100%;
}
.preview-hub .main-content { width: 100%; }
.demo-note {
  font-size: 12px;
  background: #e8f1fb;
  border: 1px solid #b6d4f0;
  color: #0c4a6e;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  line-height: 1.6;
}
[data-theme="dark"] .demo-note {
  background: #0c2a40;
  border-color: #1e4976;
  color: #7dd3fc;
}
.rte-plain {
  width: 100%;
  min-height: 88px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}
.fill-req {
  color: var(--danger-color);
  font-size: 12px;
  margin-left: 4px;
}

/* App-builder shell extras */
body.portal-preview {
  display: flex;
  min-height: 100vh;
}
.nav-sub a.active-link {
  background: var(--primary-color) !important;
  color: #fff !important;
  font-weight: bold;
}
.fill-file-name { font-size: 13px; color: var(--text-sub); }
.fill-check-list { display: flex; flex-direction: column; gap: 6px; }
.opt-row input.q-opt {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 14px;
}
.fb-index .idx-end { color: var(--primary-color); font-weight: 800; margin-top: 10px; }

/* ----- Notification settings / page-level permissions (v13) ----- */
.notify-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  text-align: right;
}
.notify-foot a {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-color);
  text-decoration: none;
}
.notify-panel.is-open { display: block; }
.notify-bell { position: relative; }
.notify-bell .notify-toggle {
  min-width: 44px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--border-color); background: var(--card-bg);
  border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 800;
  color: var(--text-color);
}
.notify-bell .badge {
  display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 6px;
  border-radius: 9px; background: var(--danger-color); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center;
}
.notify-bell .notify-panel {
  display: none; position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  width: min(360px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.12);
}
.perm-group {
  margin: 10px 0 14px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg);
}
.perm-group-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-color);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.perm-group-title button {
  font-size: 11px;
  padding: 6px 10px;
  min-height: 32px;
}
.perm-page {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  min-height: 32px;
}
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.channel-card, .ns-panel {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px 18px 16px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}
.channel-card h3, .ns-panel h2 {
  font-size: 16px;
  margin-bottom: 6px;
}
.channel-note {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  color: var(--primary-color);
  background: rgba(0,102,204,.08);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 10px;
}
.channel-card p, .ns-lead {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.65;
  margin-bottom: 12px;
}
.ns-lead { max-width: 72ch; }
.code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
  white-space: pre;
  margin: 8px 0 12px;
}
.guide-ol {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.7;
  padding-left: 1.2em;
  margin: 0 0 12px;
}
.ns-event {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg-color);
}
.ns-event h4 { font-size: 14px; margin-bottom: 4px; }
.ns-event .hint { font-size: 12px; color: var(--text-sub); margin-bottom: 10px; }
.ns-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 10px;
}
.ns-checks label, .check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 13px;
}
.ns-log {
  font-size: 12px;
  max-height: 280px;
  overflow: auto;
}
.ns-log-item {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-color);
}
.ns-log-item strong { display: block; margin-bottom: 2px; }
.ns-ok { color: var(--success-color); }
.ns-ng { color: var(--danger-color); }
.space-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: end;
}
.preview-banner {
  background: #e8f1fb;
  border: 1px solid #b6d4f0;
  color: #0c4a6e;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 16px;
}
[data-theme="dark"] .preview-banner {
  background: #0c2a40;
  border-color: #1e4976;
  color: #7dd3fc;
}
.portal-hamburger {
  min-width: 44px; min-height: 44px;
  border: 1px solid var(--border-color);
  background: var(--card-bg); color: var(--text-color);
  border-radius: 8px; font-weight: 800; cursor: pointer;
}
.portal-mobile-bar {
  display: none;
  position: sticky; top: 0; z-index: 1200;
  align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}
@media (max-width: 768px) {
  .portal-mobile-bar { display: flex; }
  .space-row { grid-template-columns: 1fr; }
  .channel-grid { grid-template-columns: 1fr; }
  .menu-grid { grid-template-columns: 1fr; gap: 12px; }
  .menu-card { padding: 20px; }
}
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.switch-row strong { font-size: 13px; }

/* ----- 契約書/同意書 A4・電子書籍・書類期限 ----- */
.file-expiry {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-sub);
}
.file-expiry label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  min-height: 44px;
  font-weight: 600;
}
.file-expiry select,
.file-expiry input[type="date"],
.file-expiry input[type="number"] {
  min-height: 40px;
  min-width: 88px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-color);
}
.file-expiry input[type="number"] { width: 72px; }
.expiry-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.expiry-pill.is-expired { background: #fde8e8; color: #b91c1c; }
.expiry-pill.is-soon { background: #fef3c7; color: #92400e; }
.expiry-pill.is-ok { background: #ecfdf3; color: #166534; }
[data-theme="dark"] .expiry-pill.is-expired { background: #3b1515; color: #fca5a5; }
[data-theme="dark"] .expiry-pill.is-soon { background: #3b2f0a; color: #fbbf24; }
[data-theme="dark"] .expiry-pill.is-ok { background: #14301f; color: #86efac; }
.staff-link-list { display: grid; gap: 10px; }
.staff-link-row {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-color);
}
.staff-link-row label { margin: 0; font-size: 12px; font-weight: 700; }
.agree-doc-list { display: grid; gap: 10px; }
.agree-doc-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  background: var(--bg-color);
}
.agree-doc-card .ttl { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.agree-doc-card .meta { font-size: 12px; color: var(--text-sub); margin-bottom: 10px; }
.agree-doc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.agree-doc-actions .btn { min-height: 44px; }

.a4-print-host { background: #fff; }
.a4-sheet {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  max-width: 100%;
  margin: 0 auto 18px;
  background: #fff;
  color: #111;
  box-shadow: 0 10px 28px rgb(15 23 42 / 0.14);
  border: 1px solid #e5e7eb;
  overflow: hidden;
}
.a4-body {
  min-height: 297mm;
  padding: 16mm 16mm 22mm;
  font-size: 13px;
  line-height: 1.75;
  outline: none;
}
.a4-body p { margin: 0 0 0.7em; }
.a4-overlays { position: absolute; inset: 0; pointer-events: none; }
.a4-field {
  position: absolute;
  pointer-events: auto;
  box-sizing: border-box;
  border: 1px dashed #93c5fd;
  background: rgb(219 234 254 / 0.35);
  border-radius: 6px;
  padding: 4px;
}
.a4-field.is-build { cursor: move; touch-action: none; }
.a4-field.is-active { border-color: #0066cc; box-shadow: 0 0 0 2px rgb(0 102 204 / 0.25); }
.a4-field-del {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: #e74c3c;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  z-index: 2;
}
.a4-field-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  background: #0066cc;
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
  cursor: nwse-resize;
}
.a4-check-lab {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  min-height: 32px;
}
.a4-check-lab input { width: 18px; height: 18px; margin-top: 2px; accent-color: #0066cc; }
.a4-check-box {
  width: 16px; height: 16px; flex: 0 0 16px;
  border: 2px solid #111;
  margin-top: 2px;
  background: #fff;
}
.a4-check-box.is-on {
  background: #111;
  box-shadow: inset 0 0 0 2px #fff;
}
.a4-sig-empty, .a4-sig-hit, .a4-stamp-ph {
  width: 100%;
  height: calc(100% - 18px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}
.a4-sig-hit {
  min-height: 44px;
  cursor: pointer;
  border: 2px dashed #0066cc;
  color: #0066cc;
  background: #f8fbff;
}
.a4-sig-filled {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.a4-sig-filled img, .a4-stamp-img {
  display: block;
  width: 100%;
  height: calc(100% - 18px);
  object-fit: contain;
  background: #fff;
}
.a4-sig-date {
  font-size: 10px;
  font-weight: 800;
  text-align: right;
  color: #111;
  line-height: 16px;
  padding: 0 2px;
}
.a4-sig-date-ph { color: #94a3b8; font-weight: 600; }

.ab-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 252px;
  gap: 16px;
  align-items: start;
}
.page-agreement-builder .page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-agreement-builder .fb-pane-index .fb-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 4px;
  padding: 2px 2px 0;
}
.page-agreement-builder .fb-pane-format .fb-rail-head { display: none; }
.ab-list-tools { display: flex; gap: 6px; }
.ab-icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.ab-icon-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.ab-icon-btn.is-danger:hover { border-color: var(--danger-color); color: var(--danger-color); }
.ab-toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4200;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgb(15 23 42 / 0.28);
  max-width: min(92vw, 520px);
  text-align: center;
  pointer-events: none;
}
.ab-toast.is-error { background: #b91c1c; }
.ab-doc {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-color);
  color: var(--text-color);
  text-align: left;
  cursor: pointer;
}
.ab-doc.is-on { border-color: var(--primary-color); background: #e8f1fb; }
[data-theme="dark"] .ab-doc.is-on { background: #0c2a40; }
.ab-canvas {
  overflow: auto;
  padding: 12px 8px 40px;
  background: #e8eef4;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}
[data-theme="dark"] .ab-canvas { background: #0f172a; }
.ab-page-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.ab-page-tabs .btn { min-height: 44px; min-width: 44px; }
.a4-field-label {
  display: block;
  min-height: 22px;
  outline: none;
  cursor: text;
  width: 100%;
  line-height: 1.4;
}
.a4-field.is-build .a4-field-label:focus {
  background: #fff;
  box-shadow: 0 0 0 2px rgb(0 102 204 / 0.28);
  border-radius: 4px;
}

.ebook-shell { max-width: 1100px; margin: 0 auto; }
.ebook-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin: 0 0 14px;
  flex-wrap: wrap;
}
.ebook-toolbar .btn { min-width: 120px; min-height: 44px; }
.ebook-pos { font-weight: 800; min-width: 88px; text-align: center; }
.ebook-spread {
  display: flex;
  justify-content: center;
  gap: 0;
  align-items: stretch;
}
.ebook-spread .a4-sheet {
  margin: 0;
  transform-origin: top center;
}
.ebook-spread.is-dual .a4-sheet { width: min(48vw, 420px); min-height: 0; aspect-ratio: 210 / 297; }
.ebook-spread.is-dual .a4-sheet .a4-body { min-height: 100%; padding: 8%; font-size: 11px; }
.ebook-spread.is-single .a4-sheet { width: min(100%, 520px); min-height: 0; aspect-ratio: 210 / 297; }
.ebook-spread.is-single .a4-body { min-height: 100%; padding: 8%; }
.ag-sign-pad-card { max-width: 520px; }
.ag-pad-wrap {
  border: 2px solid var(--border-color);
  border-radius: 10px;
  background: #fff;
  touch-action: none;
}
#ag-sign-pad-canvas { display: block; width: 100%; height: 180px; cursor: crosshair; touch-action: none; }
@media (max-width: 900px) {
  .ab-layout { grid-template-columns: 1fr; }
  .page-agreement-builder .fb-pane-index .fb-rail-head { display: flex; }
  .a4-sheet { width: min(100%, 210mm); min-height: 0; aspect-ratio: 210 / 297; }
  .a4-body { min-height: 100%; padding: 7%; font-size: 12px; }
  .ebook-spread.is-dual { flex-direction: column; align-items: center; gap: 12px; }
}
@media print {
  .sidebar, .page-header, .toolbar, .ebook-toolbar, .ab-side, .modal-overlay { display: none !important; }
  .a4-sheet { box-shadow: none; border: 0; page-break-after: always; break-after: page; }
}

