/* ── リセット・変数 ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --bg:        #efefef;
  --bg2:       #ffffff;
  --bg3:       #f7f7f7;
  --border:    #e2e2e6;
  --text:      #1a1d2e;
  --text-muted:#6b7280;
  --primary:   #0abfbc;
  --primary-dark: #089b98;
  --primary-hover: #089b98;
  --primary-light: rgba(10,191,188,.09);
  --accent:    #e8196e;
  --gradient:  linear-gradient(135deg, #0abfbc 0%, #e8196e 100%);
  --gradient-warm: linear-gradient(135deg, #e8196e 0%, #f5a623 100%);
  --success:   #10b981;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --x-color:   #1d9bf0;
  --ig-color:  #e1306c;
  --tt-color:  #fe2c55;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 4px rgba(10,191,188,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 20px rgba(10,191,188,.12);
  --shadow-lg: 0 10px 40px rgba(10,191,188,.16);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  font-size: 14px;
  display: flex;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── サイドバー ──────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 2px 0 16px rgba(10,191,188,.06);
}

.sidebar-logo {
  padding: 22px 18px 20px;
  display: flex; align-items: center; gap: 10px;
  background: var(--gradient);
  font-weight: 800; font-size: 17px;
  color: #fff;
  letter-spacing: -.4px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* 幾何学デコレーション（サイドバーロゴ） */
.sidebar-logo::before {
  content: '';
  position: absolute; right: -18px; top: -18px;
  width: 56px; height: 56px;
  background: rgba(255,255,255,.12);
  border-radius: 10px;
  transform: rotate(20deg);
}
.sidebar-logo::after {
  content: '';
  position: absolute; right: 20px; bottom: -12px;
  width: 32px; height: 32px;
  background: rgba(255,255,255,.08);
  border-radius: 6px;
  transform: rotate(-15deg);
}
.logo-icon { font-size: 22px; filter: drop-shadow(0 1px 4px rgba(0,0,0,.25)); position: relative; z-index: 1; }
.logo-text { color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.15); position: relative; z-index: 1; }

.sidebar-nav { flex: 1; padding: 12px 10px; }

.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  color: var(--text-muted); text-transform: uppercase;
  padding: 12px 10px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; color: var(--text-muted);
  border-radius: 8px; transition: background .15s, color .15s;
  font-size: 13px; font-weight: 500;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--gradient);
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
}
.user-info { margin-bottom: 10px; }
.user-name { font-weight: 700; font-size: 13px; color: var(--text); }
.user-role { font-size: 11px; margin-top: 2px; }
.role-admin   { color: var(--primary); font-weight: 600; }
.role-manager { color: var(--warning); font-weight: 600; }
.role-staff   { color: var(--text-muted); }

.logout-btn {
  display: block; text-align: center; padding: 7px;
  background: var(--bg2); border-radius: var(--radius);
  color: var(--text-muted); font-size: 12px; font-weight: 500;
  transition: all .15s; border: 1px solid var(--border);
  margin-bottom: 4px;
}
.logout-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── メインコンテンツ ─────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; padding: 28px 32px;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ── ページヘッダー ───────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 12px;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.4px; }
.header-actions { display: flex; gap: 8px; }
.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.breadcrumb a:hover { color: var(--primary); }
.section-header { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 12px; }
.section-title { font-size: 16px; font-weight: 700; }

/* ── アラート ────────────────────────────────── */
.alert { padding: 11px 15px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.alert-error   { background: rgba(239,68,68,.07);  border: 1px solid rgba(239,68,68,.22);  color: #dc2626; }
.alert-success { background: rgba(10,191,188,.07); border: 1px solid rgba(10,191,188,.22); color: var(--primary-dark); }

/* ── カード ──────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ── 統計カード ──────────────────────────────── */
.stats-row { display: flex; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  min-width: 120px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient);
  border-radius: var(--radius) var(--radius) 0 0;
}
/* 幾何学デコ（stat card） */
.stat-card::after {
  content: '';
  position: absolute; bottom: -12px; right: -12px;
  width: 48px; height: 48px;
  background: linear-gradient(135deg, rgba(10,191,188,.07) 0%, rgba(232,25,110,.07) 100%);
  border-radius: 10px;
  transform: rotate(20deg);
}
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

/* ── アカウントカードグリッド ─────────────────── */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }

.account-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: box-shadow .2s, transform .2s, border-color .2s;
  display: block;
  box-shadow: var(--shadow-sm);
}
.account-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: rgba(10,191,188,.3);
}

.account-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.platform-icon { font-size: 22px; }
.account-info { flex: 1; min-width: 0; }
.account-handle { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-client { font-size: 11px; color: var(--text-muted); }

.account-metrics { display: flex; gap: 16px; margin-bottom: 10px; }
.metric { display: flex; flex-direction: column; }
.metric-value { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -.3px; }
.metric-label { font-size: 10px; color: var(--text-muted); font-weight: 500; }

.progress-bar-wrap { background: var(--bg3); border-radius: 4px; height: 6px; overflow: hidden; margin-bottom: 4px; }
.progress-bar-wrap.large { height: 10px; margin: 8px 0; }
.progress-bar { background: var(--gradient); height: 100%; border-radius: 4px; transition: width .3s; }
.progress-label { font-size: 11px; color: var(--text-muted); }
.progress-label-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.progress-section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 16px 0; box-shadow: var(--shadow-sm); }

.sync-badge { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.sync-badge.manual { color: var(--warning); }

/* ── プラットフォームバッジ ──────────────────── */
.platform-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap;
}
.platform-x         { background: rgba(29,155,240,.1);  color: var(--x-color);  border: 1px solid rgba(29,155,240,.25); }
.platform-instagram { background: rgba(225,48,108,.1);  color: var(--ig-color); border: 1px solid rgba(225,48,108,.25); }
.platform-tiktok    { background: rgba(254,44,85,.1);   color: var(--tt-color); border: 1px solid rgba(254,44,85,.25); }

/* ── バッジ ──────────────────────────────────── */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.badge-success { background: rgba(16,185,129,.1);  color: #059669;       border: 1px solid rgba(16,185,129,.25); }
.badge-warning { background: rgba(245,158,11,.1);  color: var(--warning); border: 1px solid rgba(245,158,11,.25); padding: 4px 12px; }
.badge-gray    { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }
.role-badge-admin   { background: rgba(10,191,188,.1);  color: var(--primary);  border: 1px solid rgba(10,191,188,.25); }
.role-badge-manager { background: rgba(245,158,11,.1);  color: var(--warning);  border: 1px solid rgba(245,158,11,.25); }
.role-badge-staff   { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }

/* ── アクションバッジ（ログ）───────────────────── */
.action-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-family: monospace; font-weight: 600; }
.action-login, .action-logout { background: var(--bg3); color: var(--text-muted); }
.action-approve { background: rgba(16,185,129,.1); color: #059669; }
.action-reject  { background: rgba(239,68,68,.1);  color: var(--danger); }
.action-client_add, .action-account_add, .action-user_add         { background: rgba(10,191,188,.1); color: var(--primary); }
.action-client_delete, .action-account_delete, .action-user_deactivate { background: rgba(239,68,68,.1); color: var(--danger); }

/* ── テーブル ────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--bg2); }
.table { width: 100%; border-collapse: collapse; }
.table th {
  background: var(--bg3); padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; background: var(--bg2); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--primary-light); }
.row-inactive td { opacity: .5; }

/* ── ボタン ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius); border: none;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--gradient); color: #fff;
  box-shadow: 0 2px 10px rgba(10,191,188,.35);
}
.btn-primary:hover {
  opacity: .88;
  box-shadow: 0 4px 18px rgba(10,191,188,.45);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg3); border-color: rgba(10,191,188,.3); }
.btn-danger { background: rgba(239,68,68,.07); color: var(--danger); border: 1px solid rgba(239,68,68,.2); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-block { width: 100%; }

/* ── フォーム ────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 13px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); background: var(--bg2);
  box-shadow: 0 0 0 3px rgba(10,191,188,.12);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.required { color: var(--danger); }

.checkbox-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; padding: 4px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 5px 8px; border-radius: 6px; }
.checkbox-item:hover { background: var(--primary-light); }
.checkbox-item input { width: auto; }

/* ── モーダル ────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.modal-box-sm { max-width: 360px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h2 { font-size: 17px; font-weight: 800; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; padding: 4px; border-radius: 6px; transition: background .15s; }
.modal-close:hover { background: var(--bg3); color: var(--text); }

/* ── チャート ────────────────────────────────── */
.chart-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-top: 8px; box-shadow: var(--shadow-sm); }

/* ── その他ユーティリティ ─────────────────────── */
.link { color: var(--primary); font-weight: 500; }
.link:hover { text-decoration: underline; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.detail-meta { display: flex; gap: 16px; font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.empty-state { text-align: center; padding: 64px 20px; color: var(--text-muted); }
.empty-state p { margin-bottom: 16px; }

/* ── ログイン・認証画面 ──────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: #ebebeb;
  position: relative;
  overflow: hidden;
}

/* 幾何学デコレーション（ログイン背景） */
.login-body::before,
.login-body::after {
  content: ''; position: absolute; border-radius: 12px;
}
.login-body::before {
  width: 180px; height: 180px;
  background: linear-gradient(135deg, rgba(10,191,188,.25) 0%, rgba(10,191,188,.1) 100%);
  top: 60px; left: 80px;
  transform: rotate(18deg);
}
.login-body::after {
  width: 120px; height: 120px;
  background: linear-gradient(135deg, rgba(232,25,110,.2) 0%, rgba(232,25,110,.08) 100%);
  bottom: 100px; right: 100px;
  transform: rotate(-12deg);
}

/* 追加デコ要素（JSで生成） */
.geo-block {
  position: absolute; border-radius: 8px; pointer-events: none;
}

.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.1), 0 4px 16px rgba(0,0,0,.06);
  position: relative; z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 60px; height: 60px;
  background: var(--gradient);
  border-radius: 16px;
  margin-bottom: 14px;
  font-size: 28px;
  box-shadow: 0 4px 16px rgba(10,191,188,.35);
}
.login-logo h1 {
  font-size: 26px; font-weight: 800; margin: 0 0 4px;
  background: var(--gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -.5px;
}
.login-logo p { font-size: 12px; color: var(--text-muted); }

/* ── hidden ──────────────────────────────────── */
.hidden { display: none !important; }

/* ── スクロールバー（WebKit） ─────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #c8d0e0; }
