/* ============================================================
   SES Tool Server — Main Stylesheet
   ============================================================ */

/* ── CSS Variables ── */
:root {
  /* Backgrounds */
  --bg:       #fafafa;
  --bg2:      #f0f0f0;
  --bg3:      #e5e5e5;

  /* Text */
  --text:     #1a1a1a;
  --text2:    #666;
  --text3:    #999;

  /* Borders */
  --border:   #e0e0e0;
  --border2:  #d0d0d0;

  /* Accent (primary blue) */
  --accent:    #2563eb;
  --accent-bg: #eff6ff;
  --accent2:   #1d4ed8;

  /* Semantic colours */
  --success-bg:   #ecfdf5;
  --success-text: #065f46;
  --warn-bg:      #fffbeb;
  --warn-text:    #92400e;
  --danger-bg:    #fef2f2;
  --danger-text:  #991b1b;
  --orange-bg:    #fff7ed;
  --orange-text:  #9a3412;
  --info-bg:      #eff6ff;
  --info-text:    #1e40af;

  /* Misc */
  --radius:     6px;
  --shadow:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,.1);
  --text-muted: #666;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* iOS Safari: テキスト自動拡大ズームを無効化 */
html {
  -webkit-text-size-adjust: 100%;
      -ms-text-size-adjust: 100%;
          text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 100vw;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#loginScreen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 48px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.login-card > p { color: var(--text2); margin-bottom: 32px; font-size: 14px; }
.login-card .logo { font-size: 32px; margin-bottom: 16px; }
.login-card .logo-text {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-card .logo-text h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0;
}
.login-card .logo-text p { font-size: 12px; color: var(--text3); margin-top: 4px; margin-bottom: 0; }

.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Setup screen (legacy compat) */
#setup {
  display: none;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: var(--bg);
}
.setup-card {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 500px;
}
.setup-card h1 { font-size: 18px; margin-bottom: 1rem; }
.setup-card input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  margin: 8px 0;
}
.setup-card .hint { font-size: 11px; color: var(--text3); margin: 4px 0 12px; }

/* ============================================================
   APP SHELL
   ============================================================ */

/* app root — shown when logged in */
#app { display: none; }
#app.visible { display: flex; flex-direction: row; height: 100vh; overflow: hidden; }

/* ============================================================
   NAVIGATION SIDEBAR
   ============================================================ */
nav.sidebar {
  width: 210px !important;
  min-width: 210px;
  background: #1e293b !important;
  border-right: none !important;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
  z-index: 10;
  overflow: hidden;
  transition: width 0.25s ease, min-width 0.25s ease;
}

/* デスクトップ: サイドバー折りたたみ */
#app.sidebar-collapsed nav.sidebar {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
}

.sidebar-logo {
  padding: 18px 16px 16px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.sidebar-logo span { color: #60a5fa; }

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-menu::-webkit-scrollbar { width: 3px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  font-size: 13px;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  user-select: none;
  border-right: 3px solid transparent;
}
.menu-item:hover { background: rgba(255,255,255,0.07); color: #e2e8f0; }
.menu-item.active {
  background: rgba(37,99,235,0.25);
  color: #93c5fd;
  font-weight: 600;
  border-right-color: #2563eb;
}
.menu-item .icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.user-info { margin-bottom: 10px; }
.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
#sidebarUserRole { font-size: 11px; color: #64748b; margin-top: 2px; }

/* Main content wrapper */
main.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Top bar ── */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 15px; font-weight: 700; color: var(--accent); }
.topbar h2 { font-size: 18px; font-weight: 600; }
.topbar-sub { font-size: 11px; color: var(--text3); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-user { font-size: 12px; color: var(--text2); }

/* ── Tab navigation ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
  padding: 0 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text); background: var(--bg2); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Invoice tab buttons ── */
.invoice-tab-btn {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.invoice-tab-btn:hover  { color: var(--text); background: var(--bg2); }
.invoice-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

/* ── Tab content ── */
.tab-content { display: none; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; flex-direction: column; }

/* page (non-tab layout) */
.page { padding: 24px; display: none; }
.page.active { display: block; flex: 1; min-height: 0; overflow-y: auto; }

/* ── 2-pane main layout ── */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar (left pane — 280 px) ── */
.sidebar {
  width: 280px;
  border-right: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-header input[type="text"],
.sidebar-header input[type="search"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  transition: border-color .15s;
}
.sidebar-header input:focus { border-color: var(--accent); background: #fff; }

/* Filter bar */
.filter-bar {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
}
.filter-bar label { font-size: 11px; color: var(--text2); white-space: nowrap; }
.filter-bar select {
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  min-width: 0;
}
.filter-bar select:focus { outline: none; border-color: var(--accent); }

.sidebar-count { font-size: 11px; color: var(--text3); padding: 4px 12px; }

/* Sidebar list */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.sidebar-list::-webkit-scrollbar { width: 4px; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* Grouped sidebar */
.sidebar-group { border-bottom: 1px solid var(--border); }
.sidebar-group-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  transition: background .1s;
  user-select: none;
}
.sidebar-group-header:hover { background: var(--bg2); }
.sidebar-group-header .count { color: var(--text3); font-weight: 400; font-size: 11px; }

/* Flat sidebar item */
.sidebar-item {
  padding: 7px 12px 7px 24px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  transition: background .1s;
  border-bottom: 1px solid var(--bg2);
}
.sidebar-item:last-child { border-bottom: none; }
.sidebar-item:hover { background: var(--accent-bg); }
.sidebar-item.selected { background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.sidebar-item-main { flex: 1; min-width: 0; }
.sidebar-item-name {
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-item-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }

/* ── Detail panel (right pane) ── */
.panel {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.panel-title { font-size: 16px; font-weight: 700; }
.panel-actions { display: flex; gap: 6px; }

/* Detail card */
.detail-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.2rem;
  margin-bottom: 1rem;
}
.detail-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.detail-row {
  display: flex;
  padding: 5px 0;
  border-bottom: 1px solid var(--bg2);
  font-size: 12px;
  align-items: flex-start;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 120px; color: var(--text2); flex-shrink: 0; padding-top: 2px; }
.detail-value { flex: 1; word-break: break-word; }

/* Info grid */
.info-grid { display: grid; grid-template-columns: 120px 1fr; font-size: 12px; }
.info-grid .ig-label { color: var(--text2); padding: 5px 0; border-bottom: 1px solid var(--bg2); align-self: start; }
.info-grid .ig-value { padding: 5px 0; border-bottom: 1px solid var(--bg2); word-break: break-word; }

/* Section actions */
.panel-footer-actions { display: flex; gap: 8px; padding-top: 1rem; flex-wrap: wrap; }

/* ── Card (generic) ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* ============================================================
   SKILL TAGS  (11 categories)
   ============================================================ */
.skill-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  margin: 1px 2px;
  white-space: nowrap;
  cursor: default;
}

/* 言語: bg:#ede9fe color:#5b21b6 */
.skill-cat-言語             { background: #ede9fe; color: #5b21b6; }
/* クラウド・インフラ: bg:#fef3c7 color:#92400e */
.skill-cat-クラウド・インフラ { background: #fef3c7; color: #92400e; }
/* フレームワーク: bg:#dbeafe color:#1e40af */
.skill-cat-フレームワーク    { background: #dbeafe; color: #1e40af; }
/* ゲーム・モバイル: bg:#fce7f3 color:#9d174d */
.skill-cat-ゲーム・モバイル  { background: #fce7f3; color: #9d174d; }
/* DB: bg:#d1fae5 color:#065f46 */
.skill-cat-DB               { background: #d1fae5; color: #065f46; }
/* デザイン（2D）: bg:#fce4ec color:#880e4f */
.skill-cat-デザイン2D        { background: #fce4ec; color: #880e4f; }
/* デザイン（3D・映像）: bg:#e8eaf6 color:#283593 */
.skill-cat-デザイン3D映像    { background: #e8eaf6; color: #283593; }
/* UI/UX・Web制作: bg:#e0f2f1 color:#00695c */
.skill-cat-UIUX             { background: #e0f2f1; color: #00695c; }
/* AI・データ: bg:#fae8ff color:#86198f */
.skill-cat-AIデータ          { background: #fae8ff; color: #86198f; }
/* セキュリティ・運用: bg:#fee2e2 color:#991b1b */
.skill-cat-セキュリティ運用  { background: #fee2e2; color: #991b1b; }
/* マネジメント・業務系: bg:#f0fdf4 color:#166534 */
.skill-cat-マネジメント業務  { background: #f0fdf4; color: #166534; }

/* Generic tag chips */
.tag-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  display: inline-block;
  margin: 1px 2px;
  cursor: pointer;
  user-select: none;
  transition: filter .12s;
}
.tag-badge.industry { background: #e0e7ff; color: #3730a3; }
.tag-badge.skill    { background: #dbeafe; color: #1e40af; }
.tag-badge.active   { outline: 2px solid var(--accent); outline-offset: 1px; }
.tag-badge:hover    { filter: brightness(.94); }

.tag-container { display: flex; flex-wrap: wrap; gap: 3px; }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 500;
  white-space: nowrap;
  display: inline-block;
  margin: 1px 2px;
}

/* colour variants (generic) */
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-orange { background: #fff7ed; color: #9a3412; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f1f5f9; color: #64748b; }

/* ── Deal statuses ── */
.s-新規       { background: var(--accent-bg);  color: var(--accent); }
.s-提案中     { background: #ede9fe;            color: #5b21b6; }
.s-面談調整中 { background: var(--orange-bg);   color: var(--orange-text); }
.s-内定       { background: #ecfdf5;            color: #065f46; }
.s-成約       { background: #d1fae5;            color: #047857; }
.s-失注       { background: var(--danger-bg);   color: var(--danger-text); }
.s-保留       { background: var(--bg3);         color: var(--text2); }

/* ── Engineer statuses ── */
.s-待機中     { background: var(--success-bg);  color: var(--success-text); }
.s-アサイン中 { background: var(--accent-bg);   color: var(--accent); }
.s-終了予定   { background: var(--orange-bg);   color: var(--orange-text); }
.s-退場済     { background: var(--bg3);         color: var(--text2); }

/* ── Assignment statuses ── */
.s-稼働予定   { background: #dbeafe;            color: #1e40af; }
.s-稼働中     { background: #d1fae5;            color: #047857; }
.s-更新予定   { background: var(--warn-bg);     color: var(--warn-text); }
.s-終了       { background: var(--bg3);         color: var(--text2); }
.s-お断り     { background: #fee2e2;            color: #991b1b; }

/* ── Contact statuses ── */
.s-未対応     { background: var(--danger-bg);   color: var(--danger-text); }
.s-フォロー中 { background: var(--warn-bg);     color: var(--warn-text); }
.s-商談中     { background: var(--orange-bg);   color: var(--orange-text); }
.s-完了       { background: var(--success-bg);  color: var(--success-text); }

/* ============================================================
   BUTTONS
   ============================================================ */
button, .btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  user-select: none;
}
button:disabled, .btn:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover  { background: var(--accent2); }

.btn-success  { background: #10b981;        color: #fff; }
.btn-success:hover  { background: #059669; }

.btn-danger   { background: #ef4444;        color: #fff; }
.btn-danger:hover   { background: #dc2626; }

.btn-outline  { background: #fff;           color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover  { background: var(--bg); }

.btn-secondary { background: #fff;          color: var(--accent); border: 1px solid var(--accent); }
.btn-secondary:hover { background: var(--accent-bg); }

/* Sizes */
.btn-sm  { font-size: 12px; padding: 6px 12px; }
.btn-lg  { font-size: 15px; padding: 12px 24px; }
.btn-icon { padding: 6px 8px; font-size: 16px; background: none; border: none; cursor: pointer; border-radius: 6px; }
.btn-icon:hover { background: var(--bg2); }

/* Refresh button */
.btn-refresh { font-size: 12px; padding: 5px 10px; color: var(--text2); border: 1px solid var(--border); background: #fff; }
.btn-refresh:hover { color: var(--accent); }

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label,
.form-group .form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

/* Inline form fields (parse card) */
.parse-result {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1rem;
}
.parse-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.parse-header h4 { font-size: 13px; font-weight: 600; }
.parse-body { padding: 16px; }
.parse-field {
  display: flex;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid var(--bg2);
  font-size: 12px;
}
.parse-field:last-child { border-bottom: none; }
.parse-field label { width: 140px; color: var(--text2); flex-shrink: 0; padding-top: 5px; }
.parse-field input,
.parse-field select,
.parse-field textarea {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.parse-field input:focus,
.parse-field select:focus,
.parse-field textarea:focus { border-color: var(--accent); }
.parse-field textarea { resize: vertical; min-height: 60px; }
.parse-field .tag-container { flex: 1; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open,
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  width: 560px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  scrollbar-width: thin;
}
.modal h2 { font-size: 16px; font-weight: 700; margin-bottom: 1rem; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--bg);
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}
.kpi-icon  { font-size: 32px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); }
.kpi-label { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* Colored left-border variants */
.kpi-card.accent  { border-left: 3px solid var(--accent); }
.kpi-card.success { border-left: 3px solid #059669; }
.kpi-card.warning { border-left: 3px solid #d97706; }
.kpi-card.danger  { border-left: 3px solid #dc2626; }

/* Per-person cards */
.person-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 1.5rem;
}
.person-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  border-top: 3px solid transparent;
}
.person-card .person-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.person-card .person-stats { display: flex; gap: 10px; font-size: 11px; color: var(--text3); flex-wrap: wrap; }
.person-card .person-stat-value { font-weight: 600; color: var(--text); }

/* Revenue chart area */
.chart-area {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.chart-area h4 { font-size: 13px; font-weight: 600; margin-bottom: 12px; }

/* Summary cards */
.summary-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 1.5rem; }
.summary-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.summary-card h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.summary-card .summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px solid var(--bg2);
}
.summary-card .summary-row:last-child { border-bottom: none; }

/* Match cards */
.match-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 20px;
  border-left: 4px solid var(--accent);
}
.match-score { font-size: 32px; font-weight: 700; color: var(--accent); min-width: 60px; text-align: center; }
.match-info  { flex: 1; }
.match-name  { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.match-tags  { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.match-tag     { background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.match-concern { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 4px; font-size: 12px; }

/* ============================================================
   TABLES (Invoices, etc.)
   ============================================================ */
.table-wrap { overflow-x: auto; }
.data-table, table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
}
.data-table th, table th {
  background: #f8fafc;
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.data-table td, table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover td,
table tr:hover td { background: #f8fafc; }
.data-table tbody tr.selected td { background: #dbeafe; }
table tr:last-child td { border-bottom: none; }
.data-table .col-num  { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .col-date { white-space: nowrap; }

/* ============================================================
   TOOLBAR / SEARCH BOX
   ============================================================ */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.search-box { display: flex; align-items: center; gap: 8px; }
.search-input {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  width: 280px;
  font-family: inherit;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-title  { font-size: 20px; font-weight: 700; }

/* ============================================================
   DROP ZONE
   ============================================================ */
.dropzone {
  border: 2px dashed var(--border2);
  border-radius: 8px;
  padding: 2.5rem 2rem;
  text-align: center;
  color: var(--text2);
  cursor: pointer;
  transition: all .2s;
  background: #fff;
  user-select: none;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}
.dropzone h4  { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.dropzone p   { font-size: 12px; }
.dropzone .drop-icon { font-size: 28px; margin-bottom: 8px; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast-item {
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  animation: slideIn .3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}
.toast-success { background: #10b981; color: #fff; }
.toast-error   { background: #ef4444; color: #fff; }
.toast-info    { background: var(--accent); color: #fff; }

/* Legacy single-toast (ok/err/info) */
#toast.ok   { background: var(--success-bg); color: var(--success-text); display: block;
               padding: 10px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
               box-shadow: 0 4px 16px rgba(0,0,0,.15); max-width: 320px; }
#toast.err  { background: var(--danger-bg);  color: var(--danger-text);  display: block;
               padding: 10px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
               box-shadow: 0 4px 16px rgba(0,0,0,.15); max-width: 320px; }
#toast.info { background: var(--info-bg);    color: var(--info-text);    display: block;
               padding: 10px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
               box-shadow: 0 4px 16px rgba(0,0,0,.15); max-width: 320px; }

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* ============================================================
   SKELETON LOADER
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text2);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h4 { font-size: 15px; font-weight: 600; margin-bottom: 8px; color: var(--text2); }
.empty-state p  { font-size: 15px; }

/* ============================================================
   SWITCH TOGGLE
   ============================================================ */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: .3s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .3s;
}
input:checked + .switch-slider { background: var(--accent); }
input:checked + .switch-slider::before { transform: translateX(20px); }

/* ============================================================
   SHORYU DIAGRAM
   ============================================================ */
.shoryu-diagram-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
}
.shoryu-desc { font-size: 11px; color: var(--text3); margin-top: 6px; }

/* ============================================================
   UTILITY
   ============================================================ */
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-muted   { color: var(--text2); }
.text-small   { font-size: 11px; }
.fw-600       { font-weight: 600; }
.mt-1 { margin-top:    4px; }
.mt-2 { margin-top:    8px; }
.mt-3 { margin-top:   12px; }
.mt-4 { margin-top:  1rem; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom:12px; }
.mb-4 { margin-bottom:1rem; }
.flex       { display: flex; }
.flex-1     { flex: 1; }
.items-center { align-items: center; }
.gap-2 { gap: 6px; }
.gap-3 { gap: 10px; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================================================
   2ペインレイアウト (エンジニア管理・案件管理)
   ============================================================ */
.two-pane-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 130px);
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.pane-sidebar {
  width: 300px;
  min-width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.pane-toolbar {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.pane-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.pane-list::-webkit-scrollbar { width: 4px; }
.pane-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.pane-detail {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.pane-detail::-webkit-scrollbar { width: 6px; }
.pane-detail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ペイン内サイドバーアイテム */
.pane-sidebar .sidebar-item {
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px solid var(--bg2);
  transition: background .1s;
}
.pane-sidebar .sidebar-item:hover   { background: var(--accent-bg); }
.pane-sidebar .sidebar-item.selected { background: var(--accent-bg); border-left: 3px solid var(--accent); }

/* ============================================================
   HAMBURGER BUTTON
   ============================================================ */
.hamburger {
  display: flex;
  background: none;
  border: none;
  padding: 6px 8px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text2);
  border-radius: var(--radius);
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.hamburger:hover { background: var(--bg2); }

/* Sidebar close button (mobile only) */
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}
.sidebar-close-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

/* Sidebar backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-backdrop.active { display: block; }

/* Mobile back button (two-pane detail → list) */
.mobile-back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 0 12px;
  cursor: pointer;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  width: 100%;
  text-align: left;
}
.mobile-back-btn:hover { opacity: .75; }

/* ============================================================
   RESPONSIVE — TABLET (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
  nav.sidebar { width: 186px !important; min-width: 186px !important; }
  .menu-item  { font-size: 12px; padding: 8px 12px; }
  .kpi-grid   { grid-template-columns: repeat(3, 1fr) !important; gap: 12px; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 768px)
   ============================================================ */

/* iOS Safari ではみ出し防止: 全ページの横幅を 100vw に固定 */
html {
  overflow-x: hidden;
  max-width: 100vw;
}

@media (max-width: 768px) {

  /* ── body: height:100vh / overflow:hidden を解除してモバイルで縦スクロールを有効化 ── */
  body {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* ── アプリシェル: flex row → block に変更してサイドバーの幅問題を解消 ── */
  #app.visible {
    display: block !important;   /* flex row をやめる */
    overflow: visible !important; /* overflow:hidden をすべて解除 → body がスクロール担当 */
    width: 100%;
    max-width: 100vw;
    height: auto !important;
  }

  /* ── Sidebar: slide-in overlay (transform ベース — iOS 対応) ── */
  nav.sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0;
    height: 100vh;
    z-index: 100;
    width: 75vw !important;
    max-width: 280px !important;
    min-width: 0 !important;
    -webkit-transform: translateX(-105%);
            transform: translateX(-105%);
    -webkit-transition: -webkit-transform .25s cubic-bezier(.4,0,.2,1),
                                box-shadow .25s ease;
            transition:         transform .25s cubic-bezier(.4,0,.2,1),
                                box-shadow .25s ease;
    box-shadow: none;
    overflow-y: auto;
    overflow-x: hidden;
    will-change: transform;
  }
  nav.sidebar.open {
    -webkit-transform: translateX(0);
            transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .sidebar-close-btn { display: block; }

  /* ── Show hamburger ── */
  .hamburger { display: flex; }

  /* ── Topbar ── */
  .topbar { padding: 0 10px; height: 48px; }
  .topbar h2 { font-size: 15px; }

  /* ── Main: flex コンテナをやめ、overflow 制約を完全解除（body がスクロールコンテナ）── */
  main.main {
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    display: block !important;     /* flex column をやめる → ブロックレイアウトに */
    overflow: visible !important;  /* overflow:hidden を解除 */
    height: auto !important;       /* 自然な高さ（コンテンツ量で伸びる） */
    flex: none !important;         /* 親の flex:1 制約をやめる */
  }

  /* ── Page padding tighter ── */
  .page { padding: 12px; }

  /* ── Section header wrap on small screens ── */
  .section-header { flex-wrap: wrap; gap: 8px; padding: 8px 12px !important; }
  .section-title  { font-size: 15px; }

  /* ── KPI grid: 2 columns ── */
  .kpi-grid  { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .kpi-card  { padding: 12px; gap: 10px; }
  .kpi-value { font-size: 20px; }
  .kpi-icon  { font-size: 22px; }

  /* ── Tanto / person cards: 2 col ── */
  .person-cards-grid { grid-template-columns: 1fr 1fr; }

  /* ── Summary cards: 1 col ── */
  .summary-cards { grid-template-columns: 1fr; }

  /* ── Card padding ── */
  .card { padding: 14px; margin-bottom: 14px; }

  /* ── Two-pane: absolute 配置で幅はみ出し問題を完全回避 ── */
  .two-pane-layout {
    position: relative;   /* absolute 子のアンカー */
    display: block;       /* flex row をやめる */
    height: 73vh;
    min-height: 300px;
    width: 100%;
    overflow: hidden;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
  .pane-sidebar {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border-right: none;
    border-bottom: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  .pane-detail {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    overflow-y: auto;
  }
  /* ← Show list, hide detail */
  .two-pane-layout.mobile-detail-visible > .pane-sidebar { display: none; }
  /* ← Show detail, hide list */
  .two-pane-layout.mobile-detail-visible > .pane-detail  { display: flex; }

  /* ── Show mobile back button ── */
  .mobile-back-btn { display: flex; }

  /* ── Search full width ── */
  .search-input { width: 100%; }

  /* ── Form rows: 1 column ── */
  .form-row { grid-template-columns: 1fr !important; gap: 0 !important; }

  /* ── Tables: compact ── */
  .data-table th, .data-table td,
  table th, table td { padding: 8px 10px; font-size: 12px; }

  /* ── Buttons ── */
  .btn-sm { font-size: 11px; padding: 5px 10px; }

  /* ── Tab buttons ── */
  .tab-btn { padding: 8px 12px; font-size: 12px; }

  /* ── iOS Safari: フォーカス時の自動ズームを防ぐ (font-size が 16px 未満だと iOS がズームイン) ── */
  input, select, textarea,
  .form-control, .search-input {
    font-size: 16px !important;
  }

  /* ── ページ: overflow 制約を解除・高さ auto（body がスクロール）── */
  .page.active {
    display: block !important;     /* flex 子要素の伸縮をやめブロックレイアウトに */
    overflow: visible !important;  /* overflow-y:auto を解除（二重スクロール防止）*/
    height: auto !important;       /* flex:1 による高さ制約をやめ自然な高さに */
    flex: none !important;         /* flex item の伸縮をやめる */
    min-height: 0 !important;
  }
}

/* ============================================================
   RESPONSIVE — SMALL PHONES (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
  .kpi-grid  { gap: 8px; }
  .kpi-card  { padding: 10px; gap: 8px; }
  .kpi-value { font-size: 18px; }
  .kpi-label { font-size: 11px; }

  .person-cards-grid { grid-template-columns: 1fr; }

  .page { padding: 10px; }
  .card { padding: 10px; }

  .topbar { height: 44px; }
  .topbar h2 { font-size: 14px; }

  .two-pane-layout { height: 76vh; }

  .modal { padding: 20px; }
  .modal-title { font-size: 16px; }
}

/* 新着バッジの点滅アニメーション */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
