/* ===== LiveKaiko - TikTokライバー会計ソフト CSS ===== */
/* フォーマルかつ柔らかい印象のデザイン */

:root {
  --primary: #6C63FF;
  --primary-light: #8B85FF;
  --primary-dark: #5347E0;
  --secondary: #FF6B9D;
  --secondary-light: #FF8FB3;
  --accent: #00D4AA;
  --accent-light: #00F0C0;
  --warning: #FFB347;
  --danger: #FF6B6B;
  --success: #51CF66;
  --info: #74C0FC;
  --bg-main: #F8F7FF;
  --bg-card: #FFFFFF;
  --bg-sidebar: #1E1B4B;
  --bg-sidebar-hover: #2D2A6E;
  --text-primary: #2D3748;
  --text-secondary: #718096;
  --text-light: #A0AEC0;
  --text-white: #FFFFFF;
  --border: #E2E8F0;
  --border-light: #EDF2F7;
  --shadow-sm: 0 2px 8px rgba(108,99,255,0.08);
  --shadow-md: 0 4px 20px rgba(108,99,255,0.12);
  --shadow-lg: 0 8px 40px rgba(108,99,255,0.18);
  --shadow-xl: 0 20px 60px rgba(108,99,255,0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== LOGIN PAGE ===== */
#loginPage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1E1B4B 0%, #312E81 40%, #6C63FF 100%);
  position: relative;
  overflow: hidden;
}

#loginPage::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255,107,157,0.15) 0%, transparent 70%);
  border-radius: 50%;
  animation: floatBubble 8s ease-in-out infinite;
}

#loginPage::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(0,212,170,0.12) 0%, transparent 70%);
  border-radius: 50%;
  animation: floatBubble 10s ease-in-out infinite reverse;
}

@keyframes floatBubble {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

.login-card {
  background: rgba(255,255,255,0.98);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 10;
  animation: slideUpFade 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px;
  color: white;
  box-shadow: 0 8px 24px rgba(108,99,255,0.4);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(108,99,255,0.4); }
  50% { box-shadow: 0 8px 32px rgba(108,99,255,0.6), 0 0 0 8px rgba(108,99,255,0.1); }
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* ===== FORM ELEMENTS ===== */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  transition: var(--transition-fast);
}

.form-input {
  width: 100%;
  padding: 13px 16px 13px 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-main);
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(108,99,255,0.1);
}

.form-input::placeholder {
  color: var(--text-light);
}

.form-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 16px;
  transition: var(--transition-fast);
  pointer-events: none;
}

.form-group:focus-within .form-input-icon {
  color: var(--primary);
}

.form-input-icon-right {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.form-input-icon-right:hover { color: var(--primary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s, opacity 0.4s;
  opacity: 0;
}

.btn:active::after {
  width: 200px;
  height: 200px;
  opacity: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: 0 4px 16px rgba(108,99,255,0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(108,99,255,0.45);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #40C057);
  color: white;
  box-shadow: 0 4px 16px rgba(81,207,102,0.35);
}

.btn-success:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(81,207,102,0.45); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #FA5252);
  color: white;
  box-shadow: 0 4px 16px rgba(255,107,107,0.3);
}

.btn-danger:hover { transform: translateY(-2px); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 2px solid var(--border);
}

.btn-ghost:hover { background: var(--bg-main); color: var(--text-primary); border-color: var(--primary); }

.btn-sm { padding: 8px 16px; font-size: 12px; }
.btn-lg { padding: 16px 32px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; width: 40px; height: 40px; }
.btn-icon-sm { padding: 6px; width: 32px; height: 32px; }

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== MAIN LAYOUT ===== */
#mainApp {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  box-shadow: 4px 0 24px rgba(0,0,0,0.2);
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  flex-shrink: 0;
}

.sidebar-logo .logo-text h2 {
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.sidebar-logo .logo-text span {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 8px 10px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
  transform: translateX(4px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(108,99,255,0.5), rgba(255,107,157,0.3));
  color: white;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(108,99,255,0.3);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: linear-gradient(to bottom, var(--primary-light), var(--secondary));
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: var(--transition);
}

.nav-item.active .nav-icon {
  background: rgba(255,255,255,0.2);
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--secondary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.06);
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-details .user-name {
  font-size: 13px;
  font-weight: 500;
  color: white;
}

.user-details .user-email {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248,247,255,0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  padding: 0 32px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== PAGE CONTENT ===== */
.page-content {
  flex: 1;
  padding: 32px;
  animation: fadeInPage 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInPage {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .card-title-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: default;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 0 var(--radius-lg) 0 100%;
  opacity: 0.12;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::before { width: 100%; height: 100%; border-radius: var(--radius-lg); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
  line-height: 1.2;
}

.stat-change {
  font-size: 12px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== GRID LAYOUT ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* ===== TABLE ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table th {
  background: var(--bg-main);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table td {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-fast);
  vertical-align: middle;
}

.table tbody tr {
  transition: var(--transition-fast);
}

.table tbody tr:hover td {
  background: rgba(108,99,255,0.03);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-primary { background: rgba(108,99,255,0.1); color: var(--primary); }
.badge-success { background: rgba(81,207,102,0.12); color: var(--success); }
.badge-warning { background: rgba(255,179,71,0.12); color: var(--warning); }
.badge-danger { background: rgba(255,107,107,0.12); color: var(--danger); }
.badge-info { background: rgba(116,192,252,0.12); color: var(--info); }
.badge-secondary { background: rgba(255,107,157,0.1); color: var(--secondary); }
.badge-accent { background: rgba(0,212,170,0.1); color: var(--accent); }

/* ===== TOGGLE SWITCH ===== */
.toggle-group {
  display: flex;
  background: var(--bg-main);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 0;
  border: 1px solid var(--border);
}

.toggle-option {
  flex: 1;
  padding: 10px 16px;
  border-radius: calc(var(--radius-md) - 2px);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-align: center;
}

.toggle-option.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(108,99,255,0.15);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,27,75,0.5);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalOverlayIn 0.2s ease;
}

@keyframes modalOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-overlay.closing {
  animation: modalOverlayOut 0.2s ease forwards;
}

@keyframes modalOverlayOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modalIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-xl);
}

.modal-lg { max-width: 760px; }
.modal-sm { max-width: 400px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.88) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-overlay.closing .modal {
  animation: modalOut 0.2s ease forwards;
}

@keyframes modalOut {
  from { opacity: 1; transform: scale(1) translateY(0); }
  to { opacity: 0; transform: scale(0.92) translateY(12px); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-main);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  font-size: 16px;
}

.modal-close:hover { background: var(--danger); color: white; transform: rotate(90deg); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: white;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-left: 4px solid transparent;
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: var(--transition);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); max-height: 100px; }
  to { opacity: 0; transform: translateX(100%) scale(0.9); max-height: 0; padding: 0; margin: 0; }
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--primary); }

.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--primary); }

.toast-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.toast-message { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ===== SELECT / DROPDOWN ===== */
.form-select {
  width: 100%;
  padding: 13px 40px 13px 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-main) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23718096'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 12px center/20px;
  transition: var(--transition);
  outline: none;
  appearance: none;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--primary);
  background-color: white;
  box-shadow: 0 0 0 4px rgba(108,99,255,0.1);
}

/* ===== INPUT NUMBER ===== */
.input-number-wrapper {
  position: relative;
}

.input-addon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
}

.input-addon-left { left: 14px; }
.input-addon-right { right: 14px; }

.form-input.with-addon-right { padding-right: 48px; }

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: 20px 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-light);
  font-size: 13px;
  margin: 20px 0;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 24px;
  gap: 4px;
}

.tab-item {
  padding: 12px 20px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
}

.tab-item::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  border-radius: 2px 2px 0 0;
  transition: var(--transition-fast);
}

.tab-item.active {
  color: var(--primary);
  background: rgba(108,99,255,0.06);
}

.tab-item.active::after {
  background: var(--primary);
}

.tab-item:hover:not(.active) {
  background: var(--bg-main);
  color: var(--text-primary);
}

/* ===== CHART CONTAINER ===== */
.chart-container {
  position: relative;
  height: 300px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* ===== LOADING ===== */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(108,99,255,0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
}

/* ===== PROGRESS BAR ===== */
.progress {
  height: 8px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

/* ===== ALERT ===== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-success { background: rgba(81,207,102,0.1); border: 1px solid rgba(81,207,102,0.3); color: #1a7a2e; }
.alert-warning { background: rgba(255,179,71,0.1); border: 1px solid rgba(255,179,71,0.3); color: #8a5200; }
.alert-danger { background: rgba(255,107,107,0.1); border: 1px solid rgba(255,107,107,0.3); color: #9b1c1c; }
.alert-info { background: rgba(108,99,255,0.08); border: 1px solid rgba(108,99,255,0.2); color: var(--primary-dark); }

.alert-icon { font-size: 16px; margin-top: 1px; flex-shrink: 0; }

/* ===== CONFIRM DIALOG ===== */
.confirm-modal .confirm-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 20px;
}

.confirm-modal.danger-confirm .confirm-icon { background: rgba(255,107,107,0.12); color: var(--danger); }
.confirm-modal.warning-confirm .confirm-icon { background: rgba(255,179,71,0.12); color: var(--warning); }

.confirm-modal .confirm-text {
  text-align: center;
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.confirm-modal .confirm-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* ===== TOOLTIP ===== */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-sidebar);
  color: white;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}

[data-tooltip]:hover::before { opacity: 1; }

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  background: white;
}

.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(108,99,255,0.08); }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 14px;
}

/* ===== RECEIPT UPLOAD ===== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  background: var(--bg-main);
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary);
  background: rgba(108,99,255,0.04);
}

.upload-area .upload-icon { font-size: 32px; color: var(--primary); opacity: 0.6; margin-bottom: 8px; }
.upload-area p { font-size: 13px; color: var(--text-secondary); }

/* ===== TERMS PAGE ===== */
.terms-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

.terms-page h1 {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 32px;
}

.terms-page h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 28px 0 12px;
}

.terms-page p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 12px;
}

.terms-page ol, .terms-page ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.terms-page li {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 6px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page-content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .modal { padding: 24px 20px; }
}

/* ===== SPECIAL EFFECTS ===== */
.shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.number-update {
  animation: numberPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes numberPop {
  0% { transform: scale(0.85); color: var(--primary); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ===== COIN RATE BADGE ===== */
.coin-rate-display {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: white;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ===== AUDIT LOG ===== */
.audit-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.audit-item:last-child { border-bottom: none; }

.audit-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.audit-dot.success { background: var(--success); }
.audit-dot.warning { background: var(--warning); }
.audit-dot.info { background: var(--info); }
.audit-dot.danger { background: var(--danger); }

.audit-content .audit-action {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.audit-content .audit-time {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ===== MONTH SELECTOR ===== */
.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-nav button {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  font-size: 14px;
  color: var(--text-secondary);
}

.month-nav button:hover { border-color: var(--primary); color: var(--primary); }

.month-display {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 120px;
  text-align: center;
}

/* ===== FEE TABLE ===== */
.fee-table-compact th, .fee-table-compact td { padding: 8px 12px; font-size: 12px; }

/* ===== COLOR DOTS ===== */
.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ===== SECTION DIVIDER ===== */
.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--border), transparent);
  margin-left: 12px;
}

/* ===== STEPPER ===== */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
}

.step-item {
  display: flex;
  align-items: center;
  flex: 1;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  background: var(--border);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: var(--transition);
}

.step-item.active .step-circle { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(108,99,255,0.4); }
.step-item.completed .step-circle { background: var(--success); color: white; }

.step-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 8px;
  white-space: nowrap;
}

.step-item.active .step-label { color: var(--primary); }
.step-item.completed .step-label { color: var(--success); }

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  transition: var(--transition);
}

.step-connector.completed { background: var(--success); }

/* ===== FISCAL SUMMARY ===== */
.fiscal-box {
  background: linear-gradient(135deg, rgba(108,99,255,0.05), rgba(255,107,157,0.05));
  border: 1px solid rgba(108,99,255,0.15);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.fiscal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(108,99,255,0.1);
}

.fiscal-row:last-child { border-bottom: none; }

.fiscal-row.total {
  background: linear-gradient(135deg, rgba(108,99,255,0.08), rgba(255,107,157,0.05));
  margin: 8px -24px -24px;
  padding: 16px 24px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border-bottom: none;
}

.fiscal-label { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.fiscal-value { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.fiscal-row.total .fiscal-label { font-size: 15px; color: var(--primary); font-weight: 600; }
.fiscal-row.total .fiscal-value { font-size: 22px; color: var(--primary); }

/* ===== CHART LEGEND ===== */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn 0.4s ease; }
.slide-up { animation: slideUpFade 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.bounce-in { animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bounceIn {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== SETTINGS PAGE ===== */
.settings-section {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.settings-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.settings-row:last-child { border-bottom: none; }

.settings-row-label { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.settings-row-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ===== TOGGLE SWITCH SMALL ===== */
.switch {
  position: relative;
  width: 48px;
  height: 26px;
  cursor: pointer;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 13px;
  transition: var(--transition);
}

.switch input:checked + .switch-track { background: var(--primary); }

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  transition: var(--transition);
}

.switch input:checked ~ .switch-thumb { transform: translateX(22px); }

/* mobile menu button */
.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

@media (max-width: 960px) {
  .mobile-menu-btn { display: flex; }
}

/* sidebar overlay on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30,27,75,0.5);
  z-index: 99;
  backdrop-filter: blur(4px);
}

.sidebar-overlay.show { display: block; }

/* ===== 会計LV 新スタイル ===== */

/* freee風収支切り替えトグル */
.transaction-mode-switcher {
  display: flex;
  gap: 0;
  background: var(--bg-main);
  border-radius: 14px;
  padding: 4px;
  border: 2px solid var(--border);
  margin-bottom: 24px;
  max-width: 360px;
}

.mode-btn {
  flex: 1;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.mode-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(108,99,255,0.18);
}

.mode-btn.income-btn.active {
  color: var(--success);
}

.mode-btn.expense-btn.active {
  color: var(--danger);
}

.mode-btn:hover:not(.active) {
  background: rgba(108,99,255,0.06);
  color: var(--text-primary);
}

/* 2カラムフォームレイアウト */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

/* 決済状態トグル */
.pay-status-toggle {
  display: flex;
  gap: 0;
  background: var(--bg-main);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}

.pay-status-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-secondary);
  text-align: center;
}

.pay-status-btn.active.pending-status {
  background: rgba(255,179,71,0.15);
  color: var(--warning);
}

.pay-status-btn.active.completed-status {
  background: rgba(81,207,102,0.15);
  color: var(--success);
}

/* 源泉徴収トグル */
.withholding-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-main);
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.withholding-toggle input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.withholding-toggle.active {
  border-color: var(--info);
  background: rgba(116,192,252,0.08);
}

/* 入力モード選択ボタン */
.input-mode-group {
  display: flex;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.input-mode-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: var(--bg-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-secondary);
  border-right: 1px solid var(--border);
}

.input-mode-btn:last-child {
  border-right: none;
}

.input-mode-btn.active {
  background: var(--primary);
  color: white;
}

.input-mode-btn:hover:not(.active) {
  background: rgba(108,99,255,0.08);
}

/* 確定申告タブ */
.tax-tab-btn {
  transition: var(--transition-fast);
}

/* TikTokコイン入力フィールド */
.coin-input-section {
  background: rgba(255,215,0,0.05);
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
}

/* 売上フォームプレビューカード強化 */
.sale-preview-card {
  border-left: 4px solid var(--success);
}

/* 経費フォームプレビューカード強化 */
.expense-preview-card {
  border-left: 4px solid var(--danger);
}

/* 数値更新アニメーション（既存の補完） */
@keyframes numberUpdate {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); color: var(--primary); }
  100% { transform: scale(1); }
}

.number-update {
  animation: numberUpdate 0.4s ease;
}

/* ==================================================
   仕訳帳
   PC：マウスドラッグ
   スマホ・タブレット：指フリック
   ネイティブスクロールバー：完全非表示
   ================================================== */

.main-content,
.page-content,
.page-content > .card {
  min-width: 0;
}

/* ===== 一覧の横移動領域 ===== */

#journalTableScroll {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;

  overflow-x: auto !important;
  overflow-y: hidden !important;

  padding: 0;
  margin: 0;

  cursor: grab;

  user-select: none;
  -webkit-user-select: none;

  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;

  /* Firefox */
  scrollbar-width: none !important;
  scrollbar-color: transparent transparent !important;

  /* IE・旧Edge */
  -ms-overflow-style: none !important;
}

/* Chrome・Edge・Safari */
#journalTableScroll::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

#journalTableScroll::-webkit-scrollbar-track,
#journalTableScroll::-webkit-scrollbar-thumb,
#journalTableScroll::-webkit-scrollbar-corner {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
  border: 0 !important;
}

/* PCドラッグ中 */
#journalTableScroll.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

#journalTableScroll.is-dragging * {
  cursor: grabbing !important;
}

/* ボタンは通常操作を維持 */
#journalTableScroll button,
#journalTableScroll a,
#journalTableScroll input,
#journalTableScroll select,
#journalTableScroll textarea {
  user-select: auto;
  -webkit-user-select: auto;
}

#journalTableScroll button,
#journalTableScroll a {
  cursor: pointer;
}

/* ===== 仕訳帳テーブル ===== */

#journalTableScroll .journal-book-table {
  width: 960px !important;
  min-width: 960px !important;
  max-width: none !important;

  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

#journalTableScroll .journal-book-table th,
#journalTableScroll .journal-book-table td {
  white-space: nowrap;
  vertical-align: middle;
}

#journalTableScroll .journal-book-table th {
  padding: 9px 6px;
}

#journalTableScroll .journal-book-table td {
  padding: 10px 6px;
}

/* 展開 */
#journalTableScroll .journal-book-table th:nth-child(1),
#journalTableScroll .journal-book-table td:nth-child(1) {
  width: 48px;
  min-width: 48px;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
}

/* 日付 */
#journalTableScroll .journal-book-table th:nth-child(2),
#journalTableScroll .journal-book-table td:nth-child(2) {
  width: 105px;
  min-width: 105px;
  text-align: left;
}

/* 借方勘定科目 */
#journalTableScroll .journal-book-table th:nth-child(3),
#journalTableScroll .journal-book-table td:nth-child(3) {
  width: 155px;
  min-width: 155px;
  text-align: left;
}

/* 借方金額 */
#journalTableScroll .journal-book-table th:nth-child(4),
#journalTableScroll .journal-book-table td:nth-child(4) {
  width: 105px;
  min-width: 105px;
  text-align: right;
}

/* 貸方勘定科目 */
#journalTableScroll .journal-book-table th:nth-child(5),
#journalTableScroll .journal-book-table td:nth-child(5) {
  width: 155px;
  min-width: 155px;
  text-align: left;
}

/* 貸方金額 */
#journalTableScroll .journal-book-table th:nth-child(6),
#journalTableScroll .journal-book-table td:nth-child(6) {
  width: 105px;
  min-width: 105px;
  text-align: right;
}

/* 状態 */
#journalTableScroll .journal-book-table th:nth-child(7),
#journalTableScroll .journal-book-table td:nth-child(7) {
  width: 90px;
  min-width: 90px;
  text-align: center;
}

/* 証憑 */
#journalTableScroll .journal-book-table th:nth-child(8),
#journalTableScroll .journal-book-table td:nth-child(8) {
  width: 62px;
  min-width: 62px;
  text-align: center;
}

/* 操作 */
#journalTableScroll .journal-book-table th:nth-child(9),
#journalTableScroll .journal-book-table td:nth-child(9) {
  width: 100px;
  min-width: 100px;
  text-align: center;
}

/* ===== セル内容 ===== */

#journalTableScroll .journal-account-cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  text-align: left;
}

#journalTableScroll .journal-amount-cell {
  min-width: 0;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

#journalTableScroll .journal-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  width: 100%;
  min-width: 0;
}

/* 操作列の固定は使用しない */
#journalTableScroll .journal-book-table th:last-child,
#journalTableScroll .journal-book-table td:last-child {
  position: static;
  right: auto;
  z-index: auto;
  background: inherit;
  box-shadow: none;
}

/* ヘッダー */
#journalTableScroll .journal-book-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg-main);
}

/* ホバー */
#journalTableScroll .journal-book-table tbody tr:hover td {
  background: rgba(108, 99, 255, 0.035);
}

/* ===== 展開詳細 ===== */

.journal-detail-cell {
  padding: 0 !important;
  background: var(--bg-main);
}

.journal-detail-panel {
  padding: 18px 24px;
}

.journal-detail-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  padding: 0;

  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;

  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.journal-detail-scroll::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.journal-detail-table {
  width: max-content;
  min-width: 680px;
}

/* ===== 監査・編集履歴 ===== */

.journal-audit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
  font-size: 12px;
}

.journal-edit-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.journal-edit-line {
  display: grid;
  grid-template-columns:
    105px
    minmax(180px, 1fr)
    140px
    minmax(170px, 1fr)
    42px;
  gap: 8px;
  align-items: center;
}

.journal-revision-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.journal-revision-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.journal-revision-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 12px;
}

.journal-revision-meta {
  margin-top: 3px;
  color: var(--text-light);
}

.journal-revision-amount {
  flex-shrink: 0;
  text-align: right;
  color: var(--text-secondary);
}

/* ===== モバイル ===== */

@media (max-width: 768px) {
  #journalTableScroll .journal-book-table {
    width: 960px !important;
    min-width: 960px !important;
  }

  #journalTableScroll {
    touch-action: pan-x pan-y;
  }

  #journalTableScroll {
    touch-action: pan-x pan-y;
  }

  .journal-audit-grid {
    grid-template-columns: 1fr;
  }

  .journal-edit-line {
    grid-template-columns: 1fr;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-main);
  }

  .journal-revision-item {
    flex-direction: column;
  }

  .journal-revision-amount {
    text-align: left;
  }
}

/* ==================================================
   Dashboard accounting status
   ================================================== */

.dashboard-accounting-grid {
  align-items: stretch;
}

.dashboard-accounting-grid > .card {
  height: 100%;
}

.dashboard-balance-list {
  display: flex;
  flex-direction: column;
}

.dashboard-balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border-light);
}

.dashboard-balance-row:first-child {
  padding-top: 4px;
}

.dashboard-balance-row:last-child {
  padding-bottom: 4px;
  border-bottom: none;
}

.dashboard-balance-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.dashboard-balance-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 17px;
}

.dashboard-balance-icon.revenue-balance {
  color: var(--accent);
  background: rgba(0, 212, 170, 0.1);
}

.dashboard-balance-icon.coin-balance {
  color: #e6a700;
  background: rgba(255, 215, 0, 0.13);
}

.dashboard-balance-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.dashboard-balance-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-light);
}

.dashboard-balance-value {
  flex-shrink: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.dashboard-balance-value.is-negative {
  color: var(--danger);
}

.dashboard-review-summary {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 24px;
  align-items: center;
}

.dashboard-review-total {
  min-height: 112px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  border-radius: var(--radius-lg);
  padding: 20px 12px;
}

.dashboard-review-total.has-review {
  color: var(--warning);
  background: rgba(255, 179, 71, 0.1);
  border: 1px solid rgba(255, 179, 71, 0.25);
}

.dashboard-review-total.is-clear {
  color: var(--success);
  background: rgba(81, 207, 102, 0.1);
  border: 1px solid rgba(81, 207, 102, 0.25);
}

.dashboard-review-number {
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
}

.dashboard-review-unit {
  margin-left: 4px;
  font-size: 13px;
  font-weight: 600;
}

.dashboard-review-details {
  display: flex;
  flex-direction: column;
}

.dashboard-review-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-secondary);
}

.dashboard-review-row:last-child {
  border-bottom: none;
}

.dashboard-review-row strong {
  color: var(--text-primary);
  white-space: nowrap;
}

.dashboard-audit-list {
  display: flex;
  flex-direction: column;
}

.dashboard-audit-item {
  align-items: flex-start;
}

.dashboard-audit-detail {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.dashboard-audit-empty {
  padding: 36px 20px;
}

@media (max-width: 768px) {
  .dashboard-review-summary {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .dashboard-review-total {
    min-height: 88px;
  }

  .dashboard-balance-row {
    align-items: flex-start;
  }

  .dashboard-balance-value {
    font-size: 17px;
  }
}

/* ===== 取引登録：6項目ナビゲーション ===== */
.transaction-type-section {
  margin-bottom: 24px;
}

.transaction-type-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.transaction-type-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.transaction-type-subtitle {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
}

.transaction-type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.transaction-type-card {
  min-width: 0;
  padding: 15px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.transaction-type-card:hover {
  border-color: rgba(108, 99, 255, 0.45);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.transaction-type-card.active {
  border-color: var(--primary);
  background:
    linear-gradient(
      135deg,
      rgba(108, 99, 255, 0.09),
      rgba(255, 107, 157, 0.06)
    );
  box-shadow:
    0 0 0 3px rgba(108, 99, 255, 0.08),
    var(--shadow-sm);
}

.transaction-type-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(108, 99, 255, 0.1);
  color: var(--primary);
  font-size: 17px;
}

.transaction-type-card.active .transaction-type-icon {
  color: white;
  background:
    linear-gradient(
      135deg,
      var(--primary),
      var(--primary-light)
    );
}

.transaction-type-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.transaction-type-copy strong {
  font-size: 14px;
  line-height: 1.35;
}

.transaction-type-copy small {
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.45;
}

.transaction-expense-shortcut.active {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}

/* ===== 単独取引フォーム共通幅 ===== */
.transaction-single-form-shell {
  width: min(100%, 960px);
  margin: 0 auto;
}

/* ===== 銀行払出フォーム ===== */
.transaction-form-layout {
  display: grid;
  grid-template-columns:
    minmax(0, 1.35fr)
    minmax(280px, 0.65fr);
  gap: 20px;
  align-items: start;
}

.transaction-side-stack {
  display: grid;
  gap: 20px;
}

.transaction-balance-card {
  overflow: hidden;
  position: relative;
}

.transaction-balance-card::after {
  content: '';
  position: absolute;
  width: 140px;
  height: 140px;
  right: -50px;
  bottom: -60px;
  border-radius: 50%;
  background: rgba(255, 179, 71, 0.09);
  pointer-events: none;
}

.transaction-balance-value {
  position: relative;
  z-index: 1;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--warning);
}

.transaction-balance-subvalue {
  position: relative;
  z-index: 1;
  margin-top: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.transaction-balance-note {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.form-label-row .form-label {
  margin-bottom: 0;
}

.form-help {
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-light);
}

@media (max-width: 1100px) {
  .transaction-type-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .transaction-form-layout {
    grid-template-columns: 1fr;
  }

  .transaction-side-stack {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .transaction-type-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .transaction-expense-shortcut {
    width: 100%;
  }

  .transaction-type-grid {
    grid-template-columns: 1fr;
  }

  .transaction-type-card {
    padding: 13px;
  }

  .transaction-side-stack {
    grid-template-columns: 1fr;
  }

  .form-label-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-label-row .btn {
    width: 100%;
  }
}

/* ===== 固定資産・減価償却 ===== */
.fa-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.fa-page-head h2 {
  margin: 0;
  font-size: 22px;
}

.fa-page-head p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.fa-year-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.fa-main-grid {
  display: grid;
  grid-template-columns:
    minmax(0, 1.35fr)
    minmax(300px, 0.65fr);
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}

.fa-side-stack {
  display: grid;
  gap: 20px;
}

.fa-summary-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.fa-summary-grid > div {
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fa-summary-grid span {
  font-size: 11px;
  color: var(--text-secondary);
}

.fa-summary-grid strong {
  font-size: 17px;
  color: var(--text-primary);
}

.fa-summary-grid .emphasis {
  border-color:
    rgba(255, 107, 107, 0.28);
  background:
    rgba(255, 107, 107, 0.06);
}

.fa-summary-grid .emphasis strong {
  color: var(--danger);
}

.fa-confirm-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.fa-note,
.fa-cell-sub {
  color: var(--text-light);
  font-size: 10px;
  line-height: 1.6;
}

.fa-note {
  margin: 12px 0 0;
}

.fa-scope-list {
  display: grid;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.fa-scope-list i {
  width: 18px;
  color: var(--success);
}

.fa-scope-list .fa-circle-xmark {
  color: var(--warning);
}

.fa-preview-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.fa-multiline {
  max-width: 62%;
  white-space: pre-line;
  text-align: right;
  line-height: 1.65;
}

@media (max-width: 1050px) {
  .fa-main-grid {
    grid-template-columns: 1fr;
  }

  .fa-side-stack {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .fa-page-head {
    flex-direction: column;
  }

  .fa-year-buttons {
    justify-content: flex-start;
  }

  .fa-side-stack,
  .fa-summary-grid {
    grid-template-columns: 1fr;
  }

  .fa-multiline {
    max-width: 58%;
  }
}

/* ===== 固定資産：償却区分タブ ===== */
.fa-treatment-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.fa-treatment-tab {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
  transition: var(--transition-fast);
  display: grid;
  gap: 4px;
}

.fa-treatment-tab i {
  font-size: 18px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.fa-treatment-tab span {
  font-size: 14px;
  font-weight: 700;
}

.fa-treatment-tab small {
  font-size: 10px;
  color: var(--text-secondary);
}

.fa-treatment-tab:hover {
  border-color: rgba(108, 99, 255, 0.45);
  transform: translateY(-1px);
}

.fa-treatment-tab.active {
  border-color: var(--primary);
  background:
    linear-gradient(
      135deg,
      rgba(108, 99, 255, 0.1),
      rgba(255, 107, 157, 0.06)
    );
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.08);
}

.fa-treatment-tab.active i {
  color: var(--primary);
}

@media (max-width: 700px) {
  .fa-treatment-tabs {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   ACCOUNT PICKER
   ========================================================= */

body.account-picker-open {
  overflow: hidden;
}

.account-picker-trigger {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: var(--transition-fast);
}

.account-picker-trigger:hover {
  border-color: rgba(108, 99, 255, 0.48);
  background: var(--bg-card);
}

.account-picker-trigger:focus-visible,
.account-picker-trigger.has-value:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1);
}

.account-picker-trigger-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
}

.account-picker-trigger-copy {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 1px;
}

.account-picker-trigger-copy strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-picker-trigger-copy small {
  overflow: hidden;
  color: var(--text-light);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-picker-trigger-arrow {
  color: var(--text-light);
  font-size: 11px;
}

.account-picker-selected-path {
  min-height: 18px;
  margin-top: 6px;
  padding-left: 2px;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.5;
}

.account-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(30, 27, 75, 0);
  backdrop-filter: blur(0);
  opacity: 0;
  transition:
    opacity 0.18s ease,
    background 0.18s ease,
    backdrop-filter 0.18s ease;
}

.account-picker-overlay.is-open {
  background: rgba(30, 27, 75, 0.46);
  backdrop-filter: blur(5px);
  opacity: 1;
}

.account-picker-dialog {
  width: min(940px, 100%);
  height: min(720px, calc(100vh - 48px));
  display: grid;
  grid-template-rows:
    auto
    auto
    auto
    minmax(0, 1fr)
    auto;
  overflow: hidden;
  border: 1px solid rgba(108, 99, 255, 0.18);
  border-radius: 20px;
  background: var(--bg-card);
  box-shadow: 0 30px 90px rgba(30, 27, 75, 0.3);
  transform: translateY(12px) scale(0.985);
  transition: transform 0.18s ease;
}

.account-picker-overlay.is-open .account-picker-dialog {
  transform: translateY(0) scale(1);
}

.account-picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--border-light);
}

.account-picker-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
}

.account-picker-header p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 11px;
}

.account-picker-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 0;
  border-radius: 10px;
  background: var(--bg-main);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.account-picker-close:hover {
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
}

.account-picker-search {
  position: relative;
  margin: 14px 22px 10px;
}

.account-picker-search > i {
  position: absolute;
  top: 50%;
  left: 14px;
  color: var(--text-light);
  transform: translateY(-50%);
  pointer-events: none;
}

.account-picker-search input {
  width: 100%;
  min-height: 46px;
  padding: 10px 60px 10px 42px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: var(--transition-fast);
}

.account-picker-search input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.08);
}

.account-picker-search kbd {
  position: absolute;
  top: 50%;
  right: 12px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-light);
  font-family: inherit;
  font-size: 9px;
  transform: translateY(-50%);
}

.account-picker-recent {
  padding: 0 22px 12px;
}

.account-picker-recent-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
}

.account-picker-recent-list {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.account-picker-recent-chip {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition-fast);
}

.account-picker-recent-chip:hover {
  border-color: var(--primary);
  background: rgba(108, 99, 255, 0.06);
}

.account-picker-recent-chip span {
  font-size: 11px;
  font-weight: 600;
}

.account-picker-recent-chip small {
  color: var(--text-light);
  font-size: 9px;
}

.account-picker-main {
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.account-picker-layout {
  height: 100%;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.account-picker-groups {
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  border-right: 1px solid var(--border-light);
  background: var(--bg-main);
}

.account-picker-group {
  width: 100%;
  display: grid;
  grid-template-columns:
    30px
    minmax(0, 1fr)
    auto
    10px;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
}

.account-picker-group:hover {
  background: var(--bg-card);
}

.account-picker-group.active {
  border-color: rgba(108, 99, 255, 0.22);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  color: var(--primary);
}

.account-picker-group-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(108, 99, 255, 0.08);
  color: var(--primary);
}

.account-picker-group-label {
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-picker-group-count {
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(108, 99, 255, 0.08);
  color: var(--text-secondary);
  font-size: 9px;
  text-align: center;
}

.account-picker-group-arrow {
  color: var(--text-light);
  font-size: 8px;
}

.account-picker-panel,
.account-picker-search-view {
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 20px;
}

.account-picker-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.account-picker-panel-heading > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.account-picker-panel-heading strong {
  font-size: 14px;
}

.account-picker-panel-heading small {
  color: var(--text-light);
  font-size: 10px;
}

.account-picker-subgroup {
  margin-bottom: 18px;
}

.account-picker-subgroup:last-child {
  margin-bottom: 0;
}

.account-picker-subgroup-title {
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 3px solid var(--primary);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
}

.account-picker-account-list,
.account-picker-search-results {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.account-picker-account {
  position: relative;
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 11px 38px 11px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
}

.account-picker-account:hover {
  border-color: rgba(108, 99, 255, 0.5);
  background: rgba(108, 99, 255, 0.035);
  transform: translateY(-1px);
}

.account-picker-account.selected {
  border-color: var(--primary);
  background: rgba(108, 99, 255, 0.07);
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.08);
}

.account-picker-account-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.account-picker-account-name {
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-picker-account-code {
  flex-shrink: 0;
  color: var(--text-light);
  font-size: 9px;
}

.account-picker-account-path {
  color: var(--primary);
  font-size: 9px;
}

.account-picker-account-hint {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 9px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.account-picker-account-check {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 9px;
  transform: translateY(-50%);
}

.account-picker-account.selected .account-picker-account-check {
  display: inline-flex;
}

.account-picker-empty {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text-secondary);
  text-align: center;
}

.account-picker-empty i {
  color: var(--text-light);
  font-size: 28px;
}

.account-picker-empty strong {
  color: var(--text-primary);
  font-size: 13px;
}

.account-picker-empty span {
  font-size: 10px;
}

.account-picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  color: var(--text-secondary);
  font-size: 9px;
}

.account-picker-footer > div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.account-picker-footer i {
  color: var(--primary);
}

@media (max-width: 700px) {
  .account-picker-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .account-picker-dialog {
    width: 100%;
    height: 88dvh;
    max-height: 88dvh;
    border-radius: 20px 20px 0 0;
    transform: translateY(30px);
  }

  .account-picker-header {
    padding: 16px 16px 10px;
  }

  .account-picker-header h2 {
    font-size: 16px;
  }

  .account-picker-search {
    margin:
      10px
      16px
      8px;
  }

  .account-picker-search kbd {
    display: none;
  }

  .account-picker-search input {
    padding-right: 14px;
  }

  .account-picker-recent {
    padding:
      0
      16px
      9px;
  }

  .account-picker-layout {
    grid-template-columns: 1fr;
    grid-template-rows:
      auto
      minmax(0, 1fr);
  }

  .account-picker-groups {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border-light);
  }

  .account-picker-group {
    min-width: max-content;
    width: auto;
    grid-template-columns:
      26px
      auto
      auto;
    margin-bottom: 0;
    padding: 7px 9px;
  }

  .account-picker-group-icon {
    width: 26px;
    height: 26px;
  }

  .account-picker-group-arrow {
    display: none;
  }

  .account-picker-panel,
  .account-picker-search-view {
    padding: 12px;
  }

  .account-picker-account-list,
  .account-picker-search-results {
    grid-template-columns: 1fr;
  }

  .account-picker-footer {
    padding:
      9px
      12px;
  }

  .account-picker-footer > div {
    max-width: 65%;
  }
}

/* ===== 宝箱・お楽しみ袋・プロモーション関連 ===== */
.tiktok-service-layout {
  display: grid;
  grid-template-columns:
    minmax(0, 1.3fr)
    minmax(300px, 0.7fr);
  gap: 20px;
  align-items: start;
}

.tiktok-service-title-icon {
  background: rgba(124, 108, 242, 0.14);
  color: #7c6cf2;
}

.tiktok-service-balance-icon {
  background: rgba(245, 154, 35, 0.14);
  color: #f59a23;
}

.tiktok-service-preview-icon {
  background: rgba(32, 170, 154, 0.14);
  color: #20aa9a;
}

.tiktok-service-history-icon {
  background: rgba(61, 166, 232, 0.14);
  color: #3da6e8;
}

.tiktok-service-type-grid {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tiktok-service-type-option {
  min-width: 0;
  min-height: 92px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: var(--transition-fast);
}

.tiktok-service-type-option:hover {
  border-color: rgba(40, 169, 209, 0.42);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.tiktok-service-type-option.active {
  border-color: var(--primary);
  background:
    linear-gradient(
      135deg,
      rgba(40, 169, 209, 0.1),
      rgba(123, 203, 75, 0.07)
    );
  box-shadow:
    0 0 0 2px rgba(40, 169, 209, 0.1),
    var(--shadow-sm);
}

.tiktok-service-type-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: rgba(40, 169, 209, 0.11);
  color: var(--primary);
}

.tiktok-service-type-option.active
.tiktok-service-type-icon {
  color: white;
  background:
    linear-gradient(
      135deg,
      var(--primary),
      var(--secondary)
    );
}

.tiktok-service-type-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tiktok-service-type-copy strong {
  font-size: 13px;
  line-height: 1.4;
}

.tiktok-service-type-copy small {
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.55;
}

.tiktok-service-payment-mode-group {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
}

.tiktok-service-payment-mode-btn {
  min-width: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.tiktok-service-payment-mode-btn:disabled {
  opacity: 0.42;
  color: var(--text-light);
  background: var(--bg-main);
  cursor: not-allowed;
  box-shadow: none;
}

.tiktok-service-payment-mode-btn:disabled:hover {
  background: var(--bg-main);
}

.tiktok-service-input-panel[hidden],
.tiktok-service-payment-source[hidden] {
  display: none !important;
}

.tiktok-service-refund-notice[hidden] {
  display: none !important;
}

.tiktok-service-refund-notice strong {
  color: var(--warning-dark, #9a6500);
}

.tiktok-service-fixed-memo {
  border-color: rgba(var(--primary-rgb), 0.22);
  background:
    linear-gradient(
      135deg,
      rgba(var(--primary-rgb), 0.055),
      rgba(var(--secondary-rgb), 0.045)
    );
  color: var(--text-primary);
  font-weight: 650;
  cursor: default;
}

.tiktok-service-balance-breakdown {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.tiktok-service-balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 11px;
}

.tiktok-service-balance-row strong {
  color: var(--text-primary);
  font-size: 12px;
}

.tiktok-service-source-breakdown {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid rgba(var(--primary-rgb), 0.17);
  border-radius: var(--radius-md);
  background: rgba(var(--primary-rgb), 0.045);
}

.tiktok-service-source-breakdown-title {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
}

.tiktok-service-source-breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 10px;
}

.tiktok-service-source-breakdown-row strong {
  color: var(--text-primary);
  text-align: right;
}

.tiktok-service-preview-content {
  min-height: 190px;
}

.tiktok-service-tax-note {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(88, 189, 224, 0.28);
  border-radius: var(--radius-md);
  background: rgba(88, 189, 224, 0.08);
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.65;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.tiktok-service-tax-note i {
  margin-top: 3px;
  color: var(--info);
}

.tiktok-service-history-table {
  min-width: 1480px;
}

.tiktok-service-history-table tr.is-voided {
  opacity: 0.58;
  background: rgba(231, 101, 101, 0.05);
}


.tiktok-free-earned-card {
  border-color: rgba(245, 154, 35, 0.24);
  background:
    linear-gradient(
      145deg,
      var(--bg-card) 0%,
      rgba(245, 154, 35, 0.035) 100%
    );
}

.tiktok-free-earned-title-icon {
  background: rgba(245, 154, 35, 0.14);
  color: #f59a23;
}

.tiktok-free-earned-form {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  align-items: start;
}

.tiktok-free-earned-form > .alert,
.tiktok-free-earned-form > .tiktok-free-earned-summary,
.tiktok-free-earned-form > .btn-block {
  grid-column: 1 / -1;
}

.tiktok-free-earned-summary {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(40, 169, 209, 0.16);
  border-radius: var(--radius-md);
  background: rgba(40, 169, 209, 0.045);
}

.tiktok-free-earned-summary > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tiktok-free-earned-summary span {
  color: var(--text-secondary);
  font-size: 10px;
}

.tiktok-free-earned-summary strong {
  color: var(--text-primary);
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 1050px) {
  .tiktok-service-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .tiktok-service-payment-mode-btn {
    min-height: 46px;
    padding: 9px 6px;
    font-size: 11px;
  }

  .tiktok-service-source-breakdown-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .tiktok-service-source-breakdown-row strong {
    text-align: left;
  }

  .tiktok-service-type-grid {
    grid-template-columns: 1fr;
  }

  .tiktok-service-type-option {
    min-height: 76px;
  }

  .tiktok-free-earned-form,
  .tiktok-free-earned-summary {
    grid-template-columns: 1fr;
  }
}

/* ===== ギフト送信専用登録 ===== */

.transaction-shortcut-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.transaction-gift-shortcut.active {
  color: var(--primary);
  border-color: rgba(108, 99, 255, 0.45);
  background: rgba(108, 99, 255, 0.08);
}

.gift-send-layout {
  display: grid;
  grid-template-columns:
    minmax(0, 1.25fr)
    minmax(300px, 0.75fr);
  gap: 20px;
  align-items: start;
}

.gift-send-title-icon {
  background: rgba(108, 99, 255, 0.12);
  color: var(--primary);
}

.gift-send-preview-icon {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent);
}

.gift-purpose-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.gift-purpose-option {
  min-width: 0;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: var(--transition-fast);
}

.gift-purpose-option:hover {
  border-color: rgba(108, 99, 255, 0.38);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.gift-purpose-option.active {
  border-color: var(--primary);
  background: rgba(108, 99, 255, 0.08);
  box-shadow:
    0 0 0 1px
    rgba(108, 99, 255, 0.12);
}

.gift-purpose-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(108, 99, 255, 0.1);
  color: var(--primary);
}

.gift-purpose-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gift-purpose-copy strong {
  font-size: 13px;
  line-height: 1.4;
}

.gift-purpose-copy small {
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.55;
}

.gift-purpose-summary {
  margin-top: 10px;
  padding: 11px 12px;
  border:
    1px solid
    rgba(108, 99, 255, 0.2);
  border-radius: var(--radius-md);
  background:
    rgba(108, 99, 255, 0.06);
  color: var(--primary-dark);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.gift-purpose-summary.is-review {
  border-color:
    rgba(255, 179, 71, 0.35);
  background:
    rgba(255, 179, 71, 0.1);
  color: #9a5b00;
}

.gift-purpose-summary > i {
  margin-top: 2px;
}

.gift-purpose-summary > span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gift-purpose-summary strong {
  font-size: 12px;
}

.gift-purpose-summary small {
  color: inherit;
  font-size: 10px;
  line-height: 1.55;
}

.gift-send-preview-content {
  min-height: 150px;
}

.gift-send-preview-empty {
  padding: 22px 14px;
  border:
    1px dashed
    var(--border);
  border-radius: var(--radius-md);
  color: var(--text-light);
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
}

.gift-send-preview-error {
  padding: 13px;
  border:
    1px solid
    rgba(255, 107, 107, 0.35);
  border-radius: var(--radius-md);
  background:
    rgba(255, 107, 107, 0.08);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.65;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.gift-send-preview-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.gift-send-preview-grid > div {
  padding: 11px;
  border:
    1px solid
    var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gift-send-preview-grid span,
.gift-send-posting-preview span {
  color: var(--text-secondary);
  font-size: 10px;
}

.gift-send-preview-grid strong {
  color: var(--text-primary);
  font-size: 15px;
}

.gift-send-posting-preview {
  margin-top: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background:
    rgba(0, 212, 170, 0.08);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gift-send-posting-preview strong {
  color: var(--accent);
  font-size: 12px;
  line-height: 1.5;
}

.gift-send-source-list {
  margin-top: 10px;
  border-top:
    1px solid
    var(--border);
}

.gift-send-source-row {
  padding: 9px 2px;
  border-bottom:
    1px solid
    var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
}

.gift-send-source-row span {
  color: var(--text-secondary);
}

.gift-send-source-row strong {
  color: var(--text-primary);
  text-align: right;
}

@media (max-width: 1050px) {
  .gift-send-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .transaction-shortcut-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .transaction-gift-shortcut,
  .transaction-expense-shortcut {
    width: 100%;
  }

  .gift-purpose-grid,
  .gift-send-preview-grid {
    grid-template-columns: 1fr;
  }

  .gift-send-source-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .gift-send-source-row strong {
    text-align: left;
  }
}

.gift-recipient-mapping-hint {
  margin-top: -4px;
  margin-bottom: 16px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 10px;
  line-height: 1.6;
}

.gift-recipient-mapping-hint.info {
  color: var(--text-secondary);
  background: var(--bg-main);
}

.gift-recipient-mapping-hint.success {
  color: var(--success);
  border-color: rgba(81, 207, 102, 0.3);
  background: rgba(81, 207, 102, 0.08);
}

.gift-recipient-mapping-hint.warning {
  color: var(--warning);
  border-color: rgba(255, 179, 71, 0.35);
  background: rgba(255, 179, 71, 0.09);
}

/* ===== 開発中・ロック機能 ===== */

.nav-item-label {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.nav-item.is-locked {
  position: relative;
  opacity: 0.86;
  cursor: help;
  border:
    1px solid
    rgba(255, 179, 71, 0.08);
}

.nav-item.is-locked:hover {
  opacity: 1;
  color: var(--warning);
  background:
    rgba(255, 179, 71, 0.08);
  border-color:
    rgba(255, 179, 71, 0.24);
}

.nav-item.is-locked .nav-icon {
  color: var(--warning);
  background:
    rgba(255, 179, 71, 0.1);
}

.nav-lock-badge {
  margin-left: auto;
  padding: 3px 6px;
  border:
    1px solid
    rgba(255, 179, 71, 0.28);
  border-radius: 999px;
  background:
    rgba(255, 179, 71, 0.1);
  color: var(--warning);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.nav-lock-badge i {
  font-size: 8px;
}

.nav-lock-badge small {
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}

.locked-feature-modal {
  max-width: 560px;
}

.locked-feature-hero {
  padding: 24px 18px;
  text-align: center;
}

.locked-feature-icon {
  width: 62px;
  height: 62px;
  margin:
    0 auto
    12px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: var(--warning);
  background:
    rgba(255, 179, 71, 0.11);
  border:
    1px solid
    rgba(255, 179, 71, 0.24);
  font-size: 22px;
}

.locked-feature-status {
  display: inline-flex;
  padding: 4px 9px;
  margin-bottom: 10px;
  border-radius: 999px;
  color: var(--warning);
  background:
    rgba(255, 179, 71, 0.1);
  border:
    1px solid
    rgba(255, 179, 71, 0.25);
  font-size: 10px;
  font-weight: 700;
}

.locked-feature-hero h3 {
  margin:
    0 0
    8px;
  color: var(--text-primary);
  font-size: 18px;
}

.locked-feature-hero p {
  max-width: 440px;
  margin:
    0 auto;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.75;
}

.locked-feature-preview {
  margin:
    0 18px
    18px;
  padding: 14px;
  border:
    1px solid
    var(--border);
  border-radius:
    var(--radius-md);
  background:
    var(--bg-main);
}

.locked-feature-preview-title {
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.locked-feature-preview-row {
  padding: 10px 0;
  border-bottom:
    1px solid
    var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.locked-feature-preview-row:last-child {
  border-bottom: 0;
}

.locked-feature-preview-icon {
  width: 32px;
  height: 32px;
  flex:
    0 0
    32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background:
    rgba(108, 99, 255, 0.1);
}

.locked-feature-preview-row > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.locked-feature-preview-row strong {
  color: var(--text-primary);
  font-size: 11px;
}

.locked-feature-preview-row small {
  color: var(--text-secondary);
  font-size: 9px;
  line-height: 1.55;
}

@media (max-width: 700px) {
  .nav-lock-badge small {
    display: none;
  }

  .nav-lock-badge {
    padding:
      4px 5px;
  }
}


/* =========================================================
   TikMS諧繋 BRAND / RESPONSIVE / NATIVE FLICK POLISH
   ========================================================= */

:root {
  --primary: #2aafd2;
  --primary-light: #67d0e4;
  --primary-dark: #167f9f;
  --secondary: #7bcb4b;
  --secondary-light: #b9e955;
  --accent: #4cc8b5;
  --accent-light: #82ded0;
  --brand-lime: #b8e84f;
  --brand-cyan: #74d9e7;
  --warning: #efae45;
  --danger: #e66565;
  --success: #50b96a;
  --info: #58bde0;
  --bg-main: #f3f9fb;
  --bg-soft: #f7fcfd;
  --bg-card: #ffffff;
  --bg-sidebar: #103f52;
  --bg-sidebar-hover: #17566e;
  --text-primary: #233a43;
  --text-secondary: #627b84;
  --text-light: #91a6ad;
  --text-white: #ffffff;
  --border: #dcebed;
  --border-light: #edf5f6;
  --primary-rgb: 42, 175, 210;
  --secondary-rgb: 123, 203, 75;
  --accent-rgb: 76, 200, 181;
  --shadow-sm: 0 2px 10px rgba(20, 94, 116, 0.07);
  --shadow-md: 0 8px 26px rgba(20, 94, 116, 0.11);
  --shadow-lg: 0 16px 44px rgba(14, 77, 96, 0.16);
  --shadow-xl: 0 28px 80px rgba(10, 61, 76, 0.23);
  --sidebar-width: 248px;
  --page-max-width: 1480px;
  --topbar-height: 76px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg-main);
}

body {
  min-width: 320px;
  background:
    radial-gradient(
      circle at 92% 4%,
      rgba(var(--secondary-rgb), 0.08),
      transparent 24rem
    ),
    radial-gradient(
      circle at 20% 100%,
      rgba(var(--primary-rgb), 0.08),
      transparent 30rem
    ),
    var(--bg-main);
}

body.modal-open,
body.account-picker-open {
  overflow: hidden;
}

button,
input,
select,
textarea,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
[role="button"],
a,
label {
  touch-action: manipulation;
}

:where(
  button,
  input,
  select,
  textarea,
  a,
  [tabindex]
):focus-visible {
  outline: 3px solid rgba(var(--primary-rgb), 0.28);
  outline-offset: 3px;
}

/* ===== COMPANY BRAND ASSET ===== */

.brand-logo-frame {
  overflow: hidden;
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  background:
    linear-gradient(
      145deg,
      rgba(255, 255, 255, 1),
      rgba(244, 252, 253, 0.96)
    ) !important;
  box-shadow:
    0 8px 22px rgba(8, 71, 90, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.brand-logo-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

/* ===== LOGIN / AGREEMENT ===== */

#loginPage,
.terms-agreement-page {
  background:
    radial-gradient(
      circle at 16% 20%,
      rgba(116, 217, 231, 0.2),
      transparent 26rem
    ),
    radial-gradient(
      circle at 88% 82%,
      rgba(184, 232, 79, 0.18),
      transparent 28rem
    ),
    linear-gradient(
      135deg,
      #0b3547 0%,
      #12647c 48%,
      #65bd76 100%
    );
}

#loginPage::before {
  background:
    radial-gradient(
      circle,
      rgba(116, 217, 231, 0.2) 0%,
      transparent 70%
    );
}

#loginPage::after {
  background:
    radial-gradient(
      circle,
      rgba(184, 232, 79, 0.18) 0%,
      transparent 70%
    );
}

.login-card {
  max-width: 440px;
  padding: 42px 38px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-xl);
}

.login-logo .logo-icon.login-brand-logo {
  width: 92px;
  height: 92px;
  padding: 5px;
  margin-bottom: 18px;
  border-radius: 24px;
  animation: brandLogoBreath 4s ease-in-out infinite;
}

.login-logo h1 {
  color: var(--text-primary);
  background:
    linear-gradient(
      120deg,
      var(--primary-dark),
      var(--primary),
      var(--secondary)
    );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

@keyframes brandLogoBreath {
  0%,
  100% {
    transform: translateY(0);
    box-shadow:
      0 8px 22px rgba(8, 71, 90, 0.16),
      0 0 0 0 rgba(var(--primary-rgb), 0.1);
  }

  50% {
    transform: translateY(-3px);
    box-shadow:
      0 14px 30px rgba(8, 71, 90, 0.2),
      0 0 0 8px rgba(var(--primary-rgb), 0.06);
  }
}

.terms-agreement-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

.terms-agreement-card {
  width: min(720px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  padding: 38px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-xl);
  animation: slideUpFade 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.terms-agreement-header {
  margin-bottom: 24px;
  text-align: center;
}

.terms-agreement-brand {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  padding: 4px;
  overflow: hidden;
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  border-radius: 22px;
  background: white;
  box-shadow: var(--shadow-md);
}

.terms-agreement-title {
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 700;
}

.terms-agreement-subtitle {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 14px;
}

.terms-agreement-summary {
  max-height: 360px;
  margin-bottom: 22px;
  padding: 20px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-main);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.8;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.terms-agreement-consent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px;
  cursor: pointer;
  border: 1px solid rgba(var(--primary-rgb), 0.23);
  border-radius: 12px;
  background:
    linear-gradient(
      135deg,
      rgba(var(--primary-rgb), 0.07),
      rgba(var(--secondary-rgb), 0.06)
    );
}

.terms-agreement-checkbox {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--primary);
}

.terms-agreement-consent-text {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
}

/* ===== APP SHELL ===== */

#mainApp,
.main-content,
.page-content,
.card,
.grid-2,
.grid-3,
.grid-4,
.grid-auto,
.stats-grid {
  min-width: 0;
}

.sidebar {
  width: var(--sidebar-width);
  background:
    linear-gradient(
      180deg,
      #0d3546 0%,
      var(--bg-sidebar) 48%,
      #123a35 100%
    );
  box-shadow: 6px 0 30px rgba(6, 43, 54, 0.2);
}

.sidebar-logo {
  min-height: var(--topbar-height);
  padding: 16px 16px;
  gap: 11px;
}

.sidebar-logo .logo-icon.brand-logo-frame {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  padding: 3px;
  border-radius: 15px;
  font-size: 0;
}

.sidebar-logo .logo-text {
  min-width: 0;
}

.sidebar-logo .logo-text h2 {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logo .logo-text span {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  padding: 14px 10px;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.nav-item {
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 13px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.09);
}

.nav-item.active {
  background:
    linear-gradient(
      135deg,
      rgba(var(--primary-rgb), 0.62),
      rgba(var(--secondary-rgb), 0.42)
    );
  box-shadow: 0 7px 18px rgba(3, 42, 54, 0.24);
}

.nav-item.active::before {
  background:
    linear-gradient(
      to bottom,
      var(--brand-cyan),
      var(--brand-lime)
    );
}

.nav-item .nav-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

.user-avatar {
  background:
    linear-gradient(
      135deg,
      var(--primary),
      var(--secondary)
    );
}

.main-content {
  margin-left: var(--sidebar-width);
}

.topbar {
  min-height: var(--topbar-height);
  height: var(--topbar-height);
  padding-inline: clamp(18px, 2.4vw, 36px);
  background: rgba(243, 249, 251, 0.9);
  border-bottom-color: rgba(20, 94, 116, 0.08);
  box-shadow: 0 3px 18px rgba(15, 76, 94, 0.035);
}

.topbar-title {
  font-size: clamp(19px, 1.6vw, 23px);
  letter-spacing: -0.025em;
}

.topbar-subtitle {
  max-width: min(72vw, 780px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-content {
  width: 100%;
  max-width: var(--page-max-width);
  margin-inline: auto;
  padding: clamp(20px, 2.2vw, 32px);
}

/* ===== CORE COMPONENT SCALE ===== */

.card,
.settings-section {
  border-color: rgba(20, 94, 116, 0.08);
  box-shadow: var(--shadow-sm);
}

.card {
  padding: clamp(18px, 1.45vw, 24px);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  margin-bottom: clamp(15px, 1.5vw, 20px);
}

.card-title-icon {
  background:
    color-mix(
      in srgb,
      currentColor 12%,
      transparent
    ) !important;
}

.stats-grid {
  gap: 16px;
  margin-bottom: 24px;
}

#pageContent > .stats-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat-card {
  min-height: 150px;
  padding: 20px;
  border-color: rgba(20, 94, 116, 0.08);
  box-shadow: var(--shadow-sm);
}

.stat-card::before {
  transition:
    width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.32s ease;
}

/*
 * 既存仕様を維持する。
 * 右上の1/4円がカード全体を覆うアニメーションと、
 * カードの浮き上がりを残す。
 */
.stat-card:hover,
.stat-card:focus-within {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::before,
.stat-card:focus-within::before {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
}

.stat-card.revenue::before {
  background: var(--primary);
}

.stat-card.fee::before {
  background: var(--warning);
}

.stat-card.withholding::before {
  background: var(--info);
}

.stat-card.expense::before {
  background: var(--secondary);
}

.stat-card.profit::before {
  background: var(--success);
}

.stat-card.pending::before {
  background: var(--accent);
}

.stat-card.revenue .stat-icon {
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.12);
}

.stat-card.expense .stat-icon {
  color: var(--secondary);
  background: rgba(var(--secondary-rgb), 0.13);
}

.stat-card.pending .stat-icon {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.13);
}

.stat-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  border-radius: 14px;
}

.stat-value {
  font-size: clamp(20px, 1.55vw, 24px);
  letter-spacing: -0.035em;
}

.grid-2,
.grid-3,
.grid-4,
.grid-auto {
  gap: 18px;
}

.grid-2 {
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
}

.chart-container {
  width: 100%;
  height: clamp(255px, 24vw, 330px);
  min-width: 0;
}

.chart-container canvas {
  max-width: 100%;
}

.btn-primary {
  background:
    linear-gradient(
      135deg,
      var(--primary-dark),
      var(--primary) 58%,
      var(--accent)
    );
  box-shadow: 0 6px 18px rgba(var(--primary-rgb), 0.28);
}

.btn-primary:hover {
  box-shadow: 0 10px 26px rgba(var(--primary-rgb), 0.34);
}

.btn-secondary {
  color: var(--primary-dark);
  border-color: var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
}

.btn-ghost:hover {
  border-color: rgba(var(--primary-rgb), 0.55);
  background: rgba(var(--primary-rgb), 0.055);
}

.form-input,
.form-select,
.search-input,
.account-picker-trigger {
  border-color: var(--border);
  background-color: var(--bg-soft);
}

.form-input:focus,
.form-select:focus,
.search-input:focus,
.account-picker-trigger:focus-visible,
.account-picker-trigger.has-value:focus {
  border-color: var(--primary);
  background-color: white;
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.1);
}

.toggle-option.active,
.mode-btn.active {
  color: var(--primary-dark);
  box-shadow: 0 3px 10px rgba(var(--primary-rgb), 0.13);
}

.input-mode-btn.active,
.progress-bar {
  background:
    linear-gradient(
      90deg,
      var(--primary),
      var(--accent)
    );
}

.table th {
  background: #f2f9fa;
}

.table tbody tr:hover td {
  background: rgba(var(--primary-rgb), 0.04);
}

/* ===== NATIVE FINGER FLICK ===== */

.native-flick-scroll,
.table-wrapper,
.tabs,
.tax-tab-nav,
.account-picker-recent-list,
.account-picker-groups,
.account-picker-panel,
.account-picker-search-view,
.journal-detail-scroll,
#journalTableScroll {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.table-wrapper,
.tabs,
.tax-tab-nav,
.account-picker-recent-list,
.account-picker-groups,
.journal-detail-scroll,
#journalTableScroll {
  overflow-x: auto;
  touch-action: pan-x pan-y;
  overscroll-behavior-x: contain;
}

.legal-document-scroll,
.terms-agreement-summary,
.account-picker-panel,
.account-picker-search-view {
  touch-action: pan-y;
  overscroll-behavior-y: contain;
}

.table-wrapper > .table {
  min-width: max(680px, 100%);
}

/* ===== MODAL / LEGAL DOCUMENT ===== */

.modal-overlay {
  padding: clamp(14px, 2.4vw, 28px);
  background: rgba(7, 43, 54, 0.58);
  backdrop-filter: blur(10px);
}

.modal {
  max-width: min(560px, 100%);
  max-height: calc(100dvh - 40px);
  padding: clamp(22px, 2.4vw, 32px);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-lg {
  max-width: min(860px, 100%);
}

.modal-sm {
  max-width: min(420px, 100%);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 8;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: rgba(247, 252, 253, 0.95);
}

.modal-header {
  padding-right: 50px;
}

.legal-document-modal {
  width: min(900px, 100%);
  height: min(820px, calc(100dvh - 40px));
  max-width: 900px;
  max-height: calc(100dvh - 40px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding: 0;
}

.legal-document-modal > .modal-header {
  min-height: 78px;
  margin: 0;
  padding: 24px 72px 18px 28px;
  border-bottom: 1px solid var(--border-light);
  background:
    linear-gradient(
      135deg,
      rgba(var(--primary-rgb), 0.07),
      rgba(var(--secondary-rgb), 0.045)
    );
}

.legal-document-modal .modal-title {
  font-size: 19px;
}

.legal-document-scroll {
  min-height: 0;
  overflow-y: auto;
  padding: 22px 28px 28px;
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.9;
}

.legal-document-scroll p,
.legal-document-scroll li,
.legal-document-scroll td,
.legal-document-scroll th {
  overflow-wrap: anywhere;
}

.legal-document-modal > .modal-footer {
  min-height: 72px;
  margin: 0;
  padding: 14px 28px;
  border-top: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.96);
}

/* ===== ACCOUNT PICKER ===== */

.account-picker-overlay.is-open {
  background: rgba(7, 43, 54, 0.54);
}

.account-picker-dialog {
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 34px 95px rgba(7, 43, 54, 0.3);
}

.account-picker-group.active,
.account-picker-account.selected {
  border-color: rgba(var(--primary-rgb), 0.35);
  background:
    linear-gradient(
      135deg,
      rgba(var(--primary-rgb), 0.08),
      rgba(var(--secondary-rgb), 0.055)
    );
}

.account-picker-account-check {
  background: var(--primary);
}

/* ===== TOUCH DEVICE FEEDBACK ===== */

@media (hover: none) and (pointer: coarse) {
  .stat-card:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  .stat-card:active::before {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
  }

  .table-wrapper,
  .tabs,
  .tax-tab-nav,
  .account-picker-recent-list,
  .account-picker-groups,
  .journal-detail-scroll,
  #journalTableScroll,
  .legal-document-scroll,
  .terms-agreement-summary {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .table-wrapper::-webkit-scrollbar,
  .tabs::-webkit-scrollbar,
  .tax-tab-nav::-webkit-scrollbar,
  .account-picker-recent-list::-webkit-scrollbar,
  .account-picker-groups::-webkit-scrollbar,
  .journal-detail-scroll::-webkit-scrollbar,
  #journalTableScroll::-webkit-scrollbar,
  .legal-document-scroll::-webkit-scrollbar,
  .terms-agreement-summary::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  .btn,
  .month-nav button,
  .mobile-menu-btn,
  .account-picker-close {
    min-height: 44px;
  }

  .btn-icon-sm {
    width: 40px;
    height: 40px;
  }
}

/* ===== RESPONSIVE SCALE ===== */

@media (max-width: 1580px) {
  #pageContent > .stats-grid {
    grid-template-columns:
      repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1240px) {
  :root {
    --page-max-width: 1180px;
  }

  .page-content {
    padding: 24px;
  }

  .chart-container {
    height: 280px;
  }

  .stat-card {
    min-height: 142px;
  }
}

@media (max-width: 1080px) {
  .sidebar {
    width: min(300px, 86vw);
    transform: translateX(-105%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .page-content {
    max-width: 100%;
  }
}

@media (max-width: 860px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-auto,
  .dashboard-accounting-grid,
  .transaction-form-layout,
  .gift-send-layout,
  .tiktok-service-layout,
  .fa-main-grid {
    grid-template-columns: 1fr !important;
  }

  .fa-side-stack,
  .transaction-side-stack {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .opening-balance-detail-row {
    grid-template-columns:
      repeat(2, minmax(0, 1fr)) !important;
  }

  .opening-balance-detail-row > button {
    width: 100%;
  }

  .chart-container {
    height: 290px;
  }
}

@media (max-width: 700px) {
  :root {
    --topbar-height: 68px;
  }

  .topbar {
    min-height: var(--topbar-height);
    height: auto;
    padding: 10px 14px;
    gap: 10px;
  }

  .topbar > div:nth-child(2) {
    min-width: 0;
    flex: 1;
  }

  .topbar-title {
    font-size: 18px;
  }

  .topbar-subtitle {
    max-width: 100%;
    font-size: 11px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .page-content {
    padding:
      14px
      max(12px, env(safe-area-inset-right))
      max(22px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  #pageContent > .stats-grid,
  .stats-grid,
  .stats-grid[style] {
    grid-template-columns:
      repeat(2, minmax(0, 1fr)) !important;
    gap: 12px;
  }

  .stat-card {
    min-height: 134px;
    padding: 16px;
  }

  .stat-card::before {
    width: 66px;
    height: 66px;
  }

  .stat-icon {
    width: 42px;
    height: 42px;
    margin-bottom: 10px;
    font-size: 19px;
  }

  .stat-label {
    font-size: 11px;
  }

  .stat-value {
    font-size: 19px;
  }

  .card,
  .settings-section {
    padding: 16px;
    border-radius: 15px;
  }

  .card-header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  .card-title {
    font-size: 15px;
  }

  .chart-container {
    height: 260px;
  }

  .form-input,
  .form-select,
  .search-input {
    min-height: 48px;
    font-size: 16px;
  }

  .transaction-shortcut-actions {
    width: 100% !important;
    grid-template-columns: 1fr !important;
  }

  .tax-tab-nav {
    width: 100%;
    flex-wrap: nowrap !important;
    justify-content: flex-start;
    padding-bottom: 5px !important;
  }

  .tax-tab-btn,
  .tab-item {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }

  .filter-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-bar .form-select,
  .filter-bar .btn,
  .search-input-wrapper {
    width: 100%;
    max-width: none !important;
  }

  .fa-side-stack,
  .transaction-side-stack,
  .opening-balance-detail-row,
  .form-row-2,
  .gift-purpose-grid,
  .gift-send-preview-grid {
    grid-template-columns: 1fr !important;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 94dvh;
    padding:
      24px
      18px
      max(20px, env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
  }

  .modal-close {
    top: 12px;
    right: 12px;
  }

  .modal-header {
    min-height: 44px;
    padding-right: 48px;
  }

  .modal-title {
    font-size: 18px;
  }

  .legal-document-modal {
    height: 94dvh;
    max-height: 94dvh;
    padding: 0;
  }

  .legal-document-modal > .modal-header {
    min-height: 70px;
    padding: 20px 60px 15px 18px;
  }

  .legal-document-modal .modal-title {
    font-size: 17px;
  }

  .legal-document-scroll {
    padding: 18px;
    font-size: 13px;
    line-height: 1.85;
  }

  .legal-document-modal > .modal-footer {
    min-height: 66px;
    padding:
      11px
      18px
      max(11px, env(safe-area-inset-bottom));
  }

  .legal-document-modal > .modal-footer .btn {
    width: 100%;
  }

  .terms-agreement-page {
    align-items: flex-end;
    padding: 0;
  }

  .terms-agreement-card {
    width: 100%;
    max-height: 96dvh;
    padding:
      26px
      18px
      max(20px, env(safe-area-inset-bottom));
    border-radius: 26px 26px 0 0;
  }

  .terms-agreement-brand {
    width: 68px;
    height: 68px;
  }

  .terms-agreement-title {
    font-size: 21px;
  }

  .terms-agreement-summary {
    max-height: 38dvh;
    padding: 15px;
  }

  .toast-container {
    top: auto;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    max-width: none;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 520px) {
  #pageContent > .stats-grid,
  .stats-grid,
  .stats-grid[style] {
    grid-template-columns: 1fr !important;
  }

  .stat-card {
    min-height: 126px;
  }

  .month-nav {
    width: 100%;
    justify-content: space-between;
  }

  .month-display {
    min-width: 0;
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================================================
   ダッシュボード集計カード：最終カラー上書き
   必ずstyle.cssの一番下に配置
   ========================================================= */

/* 1. 収益合計：パープル */
.stat-card.revenue {
  --stat-card-color: #7c6cf2;
  --stat-card-icon-bg: rgba(124, 108, 242, 0.14);
}

/* 2. 支払手数料：オレンジ */
.stat-card.fee {
  --stat-card-color: #f59a23;
  --stat-card-icon-bg: rgba(245, 154, 35, 0.14);
}

/* 3. 源泉徴収：ブルー */
.stat-card.withholding {
  --stat-card-color: #3da6e8;
  --stat-card-icon-bg: rgba(61, 166, 232, 0.14);
}

/* 4. 必要経費：ピンク */
.stat-card.expense {
  --stat-card-color: #f45191;
  --stat-card-icon-bg: rgba(244, 81, 145, 0.14);
}

/* 5. 損益：グリーン */
.stat-card.profit {
  --stat-card-color: #49b957;
  --stat-card-icon-bg: rgba(73, 185, 87, 0.14);
}

/* 6. 売掛金・未収入金：ターコイズ */
.stat-card.pending {
  --stat-card-color: #20aa9a;
  --stat-card-icon-bg: rgba(32, 170, 154, 0.14);
}

/* 右上の装飾色 */
.stat-card.revenue::before,
.stat-card.fee::before,
.stat-card.withholding::before,
.stat-card.expense::before,
.stat-card.profit::before,
.stat-card.pending::before {
  background: var(--stat-card-color) !important;
}

/* アイコンの文字色と背景色 */
.stat-card.revenue .stat-icon,
.stat-card.fee .stat-icon,
.stat-card.withholding .stat-icon,
.stat-card.expense .stat-icon,
.stat-card.profit .stat-icon,
.stat-card.pending .stat-icon {
  color: var(--stat-card-color) !important;
  background: var(--stat-card-icon-bg) !important;
}

/* =========================================================
   Workspace access / invitation foundation
   ========================================================= */

.workspace-access-settings-section {
  overflow: hidden;
}

.workspace-access-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-soft);
}

.workspace-access-summary-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.workspace-access-logo {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 14px;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.12);
}

.workspace-access-name {
  overflow: hidden;
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-access-badges {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-readiness-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.workspace-readiness-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
}

.workspace-readiness-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
}

.workspace-readiness-icon.ready {
  color: var(--success);
  background: rgba(34, 197, 94, 0.12);
}

.workspace-readiness-icon.pending {
  color: var(--warning);
  background: rgba(245, 158, 11, 0.12);
}

.workspace-bootstrap-form {
  display: grid;
  gap: 14px;
  max-width: 620px;
}

.workspace-plan-assignment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
}

.workspace-plan-assignment strong {
  color: var(--primary);
}

.workspace-permission-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.workspace-permission-grid > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
}

.workspace-permission-grid span {
  color: var(--text-light);
  font-size: 11px;
}

.workspace-permission-grid strong {
  font-size: 13px;
}

.workspace-settings-readonly {
  position: relative;
}

.workspace-settings-readonly::before {
  content: "この設定は閲覧専用です";
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  margin-bottom: 12px;
  border: 1px solid rgba(59, 130, 246, 0.24);
  border-radius: 999px;
  color: var(--info);
  background: rgba(59, 130, 246, 0.08);
  font-size: 11px;
  font-weight: 700;
}

.workspace-settings-readonly :is(
  input,
  select,
  textarea,
  button
):disabled {
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .workspace-readiness-list,
  .workspace-permission-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .workspace-access-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace-access-badges {
    justify-content: flex-start;
  }

  .workspace-readiness-list,
  .workspace-permission-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Workspace accounting snapshot sync
   ========================================================= */

.workspace-snapshot-sync-card {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  border-radius: 18px;
  background:
    linear-gradient(
      145deg,
      var(--bg-card) 0%,
      rgba(var(--primary-rgb), 0.035) 100%
    );
}

.workspace-snapshot-sync-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.workspace-snapshot-sync-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 800;
}

.workspace-snapshot-sync-title i {
  color: var(--primary);
}

.workspace-snapshot-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  border-radius: 14px;
  background: rgba(var(--primary-rgb), 0.06);
}

.workspace-snapshot-message > i {
  margin-top: 3px;
  color: var(--primary);
}

.workspace-snapshot-message.is-success {
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.07);
}

.workspace-snapshot-message.is-success > i {
  color: var(--success);
}

.workspace-snapshot-message.is-danger {
  border-color: rgba(239, 68, 68, 0.24);
  background: rgba(239, 68, 68, 0.07);
}

.workspace-snapshot-message.is-danger > i {
  color: var(--danger);
}

.workspace-snapshot-metadata-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.workspace-snapshot-metadata-grid > div {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg-soft);
}

.workspace-snapshot-metadata-grid span {
  color: var(--text-light);
  font-size: 10px;
}

.workspace-snapshot-metadata-grid strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-snapshot-hash {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;
  letter-spacing: 0.02em;
}

.workspace-snapshot-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.btn-warning,
.workspace-snapshot-replace-button {
  color: #fff;
  background:
    linear-gradient(
      135deg,
      #f59e0b,
      #ea8a00
    );
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.24);
}

.btn-warning:hover,
.workspace-snapshot-replace-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(245, 158, 11, 0.3);
}

.workspace-snapshot-sync-card code {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-main);
  color: var(--primary-dark);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

@media (max-width: 800px) {
  .workspace-snapshot-metadata-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .workspace-snapshot-sync-head {
    flex-direction: column;
  }

  .workspace-snapshot-metadata-grid {
    grid-template-columns: 1fr;
  }

  .workspace-snapshot-actions .btn {
    width: 100%;
  }
}

.btn-info {
  color: #fff;
  background:
    linear-gradient(
      135deg,
      var(--info),
      var(--primary)
    );
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.22);
}

.btn-info:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(var(--primary-rgb), 0.28);
}

/* =========================================================
   Step 3-C：証憑ファイル共同保存
   ========================================================= */

.workspace-evidence-sync-card {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(var(--secondary-rgb), 0.22);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(
      145deg,
      var(--bg-card) 0%,
      rgba(var(--secondary-rgb), 0.035) 100%
    );
}

.workspace-evidence-sync-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.workspace-evidence-sync-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.workspace-evidence-sync-title i {
  color: var(--secondary);
}

.workspace-evidence-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  border-radius: var(--radius-md);
  background: rgba(var(--primary-rgb), 0.055);
}

.workspace-evidence-message > i {
  margin-top: 3px;
  color: var(--primary);
}

.workspace-evidence-message.is-success {
  border-color: rgba(73, 185, 87, 0.28);
  background: rgba(73, 185, 87, 0.075);
}

.workspace-evidence-message.is-success > i {
  color: var(--success);
}

.workspace-evidence-message.is-danger {
  border-color: rgba(231, 101, 101, 0.28);
  background: rgba(231, 101, 101, 0.075);
}

.workspace-evidence-message.is-danger > i {
  color: var(--danger);
}

.workspace-evidence-metadata-grid {
  display: grid;
  grid-template-columns:
    repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.workspace-evidence-metadata-grid > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-main);
}

.workspace-evidence-metadata-grid span {
  color: var(--text-secondary);
  font-size: 10px;
}

.workspace-evidence-metadata-grid strong {
  color: var(--text-primary);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.workspace-evidence-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.workspace-evidence-sync-card code {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-dark);
  font-size: 11px;
}

@media (max-width: 980px) {
  .workspace-evidence-metadata-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .workspace-evidence-sync-head {
    flex-direction: column;
  }

  .workspace-evidence-metadata-grid {
    grid-template-columns: 1fr;
  }

  .workspace-evidence-actions .btn {
    width: 100%;
  }
}


/* ===== Step 3-D: ワークスペース・メンバー管理 ===== */
.workspace-member-management-card {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-main);
}

.workspace-member-management-card.is-readonly {
  opacity: 0.82;
}

.workspace-member-management-head,
.workspace-slot-head,
.workspace-member-row,
.workspace-invitation-row,
.workspace-management-audit-row,
.workspace-copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workspace-member-management-title,
.workspace-management-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.workspace-slot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.workspace-slot-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.workspace-slot-card.is-disabled {
  opacity: 0.62;
}

.workspace-slot-meter {
  height: 7px;
  margin: 12px 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border-light);
}

.workspace-slot-meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.workspace-management-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
}

.workspace-invitation-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.workspace-invitation-form .form-group {
  margin-bottom: 0;
}

.workspace-member-list,
.workspace-invitation-list,
.workspace-management-audit-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.workspace-member-row,
.workspace-invitation-row,
.workspace-management-audit-row {
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.workspace-member-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-member-identity strong,
.workspace-invitation-row strong {
  overflow-wrap: anywhere;
}

.workspace-member-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.workspace-member-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-invitation-error {
  margin-top: 5px;
  color: var(--danger);
  font-size: 10px;
  overflow-wrap: anywhere;
}

.workspace-development-invitation {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(var(--warning-rgb, 245, 154, 35), 0.35);
  border-radius: var(--radius-md);
  background: rgba(245, 154, 35, 0.07);
}

.workspace-copy-row {
  align-items: stretch;
}

.workspace-copy-row .form-input {
  min-width: 0;
}

.workspace-confirmation-code {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.24em;
}

.workspace-management-audit {
  margin-top: 18px;
}

.workspace-management-audit summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.workspace-management-audit-row code {
  max-width: 42%;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-management-empty {
  padding: 22px 14px;
}

@media (max-width: 900px) {
  .workspace-slot-grid {
    grid-template-columns: 1fr;
  }

  .workspace-invitation-form {
    grid-template-columns: 1fr;
  }

  .workspace-invitation-form .btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .workspace-member-management-head,
  .workspace-member-row,
  .workspace-invitation-row,
  .workspace-management-audit-row,
  .workspace-copy-row {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-member-row-actions {
    justify-content: flex-start;
  }

  .workspace-member-row-actions .btn,
  .workspace-copy-row .btn {
    width: 100%;
  }

  .workspace-management-audit-row code {
    max-width: 100%;
  }
}

/* ===== Step 3-E: Cloudflare Access・招待コード分離 ===== */
.workspace-owner-invitation-secret {
  margin: 16px 0;
  padding: 18px;
  border: 1px solid rgba(245, 154, 35, 0.38);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(
      145deg,
      rgba(255, 249, 236, 0.96),
      rgba(255, 255, 255, 0.98)
    );
  box-shadow: var(--shadow-sm);
}

.workspace-owner-invitation-secret
.workspace-confirmation-code {
  color: #8a5200;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-align: center;
}

.workspace-external-integration-card {
  margin: 16px 0;
  padding: 18px;
  border: 1px solid rgba(40, 135, 170, 0.24);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(
      145deg,
      rgba(40, 135, 170, 0.055),
      rgba(255, 255, 255, 0.98)
    );
}

.workspace-external-integration-card.is-ready {
  border-color: rgba(81, 207, 102, 0.34);
  background:
    linear-gradient(
      145deg,
      rgba(81, 207, 102, 0.055),
      rgba(255, 255, 255, 0.98)
    );
}

.workspace-external-status-grid {
  display: grid;
  grid-template-columns:
    repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.workspace-external-status-grid > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.workspace-external-status-grid span {
  display: block;
  color: var(--text-secondary);
  font-size: 10px;
}

.workspace-external-status-grid strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-external-integration-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
}

@media (max-width: 800px) {
  .workspace-external-status-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .workspace-external-integration-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .workspace-external-status-grid {
    grid-template-columns: 1fr;
  }
}
