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

:root {
  --bg: #F0F2F5;
  --sidebar-bg: #1A2332;
  --sidebar-hover: #253347;
  --sidebar-active: #2E4A6E;
  --card-bg: #FFFFFF;
  --text: #1A2332;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body { font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* LOGIN */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1A2332 0%, #2E4A6E 100%); }
.login-box { background: white; border-radius: 12px; padding: 40px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-box h1 { font-size: 24px; text-align: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--text-muted); font-size: 12px; margin-bottom: 28px; }
.login-box label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.login-box input { display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; margin-top: 4px; }
.login-box .btn-primary { width: 100%; margin-top: 8px; padding: 12px; font-size: 15px; }
.login-hint { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 14px; }
.error-msg { background: #FEE2E2; color: var(--danger); padding: 10px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }

/* LAYOUT */
#main-screen { display: flex; min-height: 100vh; }
#sidebar { width: 220px; background: var(--sidebar-bg); display: flex; flex-direction: column; flex-shrink: 0; }
#content { flex: 1; overflow-y: auto; padding: 28px; }

/* SIDEBAR */
.sidebar-logo { padding: 20px 20px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo-icon { font-size: 22px; color: #60A5FA; }
.logo-text { font-size: 16px; font-weight: 700; color: white; }
.nav-list { list-style: none; padding: 10px 0; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: rgba(255,255,255,0.65); text-decoration: none; font-size: 13.5px; transition: all 0.15s; }
.nav-link:hover { background: var(--sidebar-hover); color: white; }
.nav-link.active { background: var(--sidebar-active); color: white; font-weight: 600; }
.nav-icon { font-size: 15px; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.user-name { color: white; font-size: 13px; font-weight: 600; }
.user-role { color: rgba(255,255,255,0.5); font-size: 11px; }
.btn-logout { width: 100%; padding: 7px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: rgba(255,255,255,0.7); border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.btn-logout:hover { background: rgba(255,255,255,0.15); }

/* PAGE */
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header .page-title { margin-bottom: 0; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* BUTTONS */
.btn-primary { background: var(--primary); color: white; border: none; padding: 8px 16px; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 600; transition: background 0.15s; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); padding: 8px 16px; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.btn-secondary:hover { background: var(--bg); }
.btn-icon { background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 4px; color: var(--text-muted); font-size: 14px; }
.btn-icon:hover { background: var(--bg); }
.btn-sm { background: white; color: var(--primary); border: 1px solid var(--primary); padding: 4px 10px; border-radius: var(--radius); cursor: pointer; font-size: 12px; font-weight: 600; transition: all 0.15s; }
.btn-sm:hover { background: var(--primary); color: white; }
.user-color-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; flex-shrink: 0; vertical-align: middle; }

/* CARD */
.card { background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; box-shadow: var(--shadow); }
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 14px; }

/* STATS */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border); padding: 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-value.blue { color: var(--primary); }
.stat-value.green { color: var(--success); }
.stat-value.orange { color: var(--warning); }
.stat-value.red { color: var(--danger); }

/* DASHBOARD */
.dash-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dash-card { position: relative; cursor: default; transition: box-shadow 0.15s, opacity 0.15s; }
.dash-card.dragging { opacity: 0.4; box-shadow: none; }
.dash-card.drag-over { box-shadow: 0 0 0 2px var(--primary); }
.dash-card-handle { position: absolute; top: 14px; right: 14px; color: #CBD5E1; font-size: 16px; cursor: grab; line-height: 1; user-select: none; }
.dash-card-handle:hover { color: #94A3B8; }
.dash-summary-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.dash-summary-row:last-child { border-bottom: none; }
.dash-summary-name { font-size: 13px; font-weight: 500; min-width: 100px; flex: 0 0 auto; }
.dash-summary-badges { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.dash-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.dash-badge.todo { background: #F3F4F6; color: #6B7280; }
.dash-badge.inprog { background: #FEF3C7; color: #92400E; }
.dash-badge.done { background: #D1FAE5; color: #065F46; }
.task-item-small { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.task-item-small:last-child { border-bottom: none; }
.task-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.task-name-small { flex: 1; font-size: 13px; }
.task-project-small { font-size: 11px; color: var(--text-muted); }
.project-summary-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.project-summary-row:last-child { border-bottom: none; }
.proj-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.proj-name { flex: 1; font-size: 13px; font-weight: 600; }
.proj-progress-wrap { display: flex; align-items: center; gap: 8px; }
.progress-bar { width: 80px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--primary); }
.progress-pct { font-size: 11px; color: var(--text-muted); width: 30px; text-align: right; }

/* GANTT */
.gantt-controls { display: flex; gap: 10px; align-items: center; }
.toggle-group { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: white; }
.view-btn { padding: 7px 14px; background: none; border: none; cursor: pointer; font-size: 13px; color: var(--text-muted); }
.view-btn.active { background: var(--primary); color: white; font-weight: 600; }
.view-btn:hover:not(.active) { background: var(--bg); }

/* ガントアコーディオンパネル */
.gantt-accordion-card { padding: 0; margin-bottom: 12px; overflow: hidden; transition: box-shadow 0.15s, opacity 0.15s; }
.gantt-accordion-card.dragging { opacity: 0.4; }
.gantt-accordion-card.drag-over { box-shadow: 0 0 0 2px var(--primary); }
#gantt-sections { display: flex; flex-direction: column; }
.accordion-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; cursor: pointer;
  font-weight: 600; font-size: 15px;
  user-select: none; background: #F8FAFC;
  color: var(--text); border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.accordion-header:hover { background: #F1F5F9; }
.acc-arrow { font-size: 11px; color: #64748B; width: 14px; text-align: center; }
.gantt-drag-handle { color: #CBD5E1; font-size: 16px; cursor: grab; margin-right: -4px; }
.gantt-drag-handle:hover { color: #94A3B8; }
.gantt-user-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: #F8FAFC; }
.gantt-tab-btn { display: flex; align-items: center; gap: 5px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 20px; background: white; font-size: 12px; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: all 0.15s; }
.gantt-tab-btn:hover { border-color: var(--primary); color: var(--primary); }
.gantt-tab-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.gantt-tab-btn.active .user-color-dot { outline: 2px solid rgba(255,255,255,0.6); }

/* frappe-gantt overrides */
.gantt .bar { rx: 4; }
.gantt .bar-label { font-size: 11px; }





/* ガントチャート親バー色 */
.gantt .bar-wrapper.project-bar .bar { fill: #1D4ED8 !important; stroke: #1D4ED8 !important; }
.gantt .bar-wrapper.project-bar .bar-label { fill: #fff !important; font-weight: 700 !important; }
.gantt .bar-wrapper.user-bar .bar-label { fill: #fff !important; font-weight: 700 !important; }
.gantt .bar-wrapper.status-bar-done .bar { fill: #6EE7B7 !important; }
.gantt .bar-wrapper.status-bar-in_progress .bar { fill: #93C5FD !important; }
.gantt .bar-wrapper.status-bar-review .bar { fill: #FCD34D !important; }
.gantt .bar-wrapper.status-bar-todo .bar { fill: #E5E7EB !important; }
.gantt .bar-wrapper.client-bar .bar { fill: #7C3AED !important; stroke: #7C3AED !important; }
.gantt .bar-wrapper.client-bar .bar-label { fill: #fff !important; font-weight: 700 !important; }

/* ガントポップアップ */
.gantt .popup-wrapper { background: white; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); padding: 12px 16px; min-width: 220px; }
.gantt .popup-wrapper .pointer { display: none; }
.gantt .popup-wrapper .title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; line-height: 1.4; }
.gantt .popup-wrapper .subtitle { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.gantt .popup-wrapper .details { font-size: 0; }
.gpop-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #374151; margin-bottom: 5px; }
.gpop-row:last-child { margin-bottom: 0; }
.gpop-label { color: var(--text-muted); font-size: 11px; min-width: 60px; flex-shrink: 0; }
.gpop-user { display: flex; align-items: center; gap: 4px; }

/* BACKLOG */
.backlog-header-row { display: grid; grid-template-columns: 36px 1fr 130px 110px 100px 90px 90px 90px 60px; gap: 8px; padding: 8px 12px; background: var(--bg); border-radius: 6px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.backlog-row { display: grid; grid-template-columns: 36px 1fr 130px 110px 100px 90px 90px 90px 60px; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); align-items: center; cursor: grab; transition: background 0.1s; }
.backlog-row:hover { background: #F9FAFB; }
.backlog-row.dragging { opacity: 0.4; }
.backlog-row.drag-over { border-top: 2px solid var(--primary); }
.priority-handle { color: var(--text-muted); cursor: grab; font-size: 16px; text-align: center; }
.task-title-cell { font-size: 13px; font-weight: 500; }
.task-project-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; color: white; }
.task-client-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; background: #F3F4F6; color: #6B7280; margin-left: 4px; }
.task-client-cell { font-size: 12px; color: var(--text-muted); }
.task-user-cell { font-size: 12px; color: var(--text-muted); }
.date-cell { font-size: 12px; color: var(--text-muted); }
.status-badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.status-todo { background: #F3F4F6; color: #374151; }
.status-in_progress { background: #DBEAFE; color: #1D4ED8; }
.status-review { background: #FEF3C7; color: #92400E; }
.status-done { background: #D1FAE5; color: #065F46; }
.actions-cell { display: flex; gap: 2px; }

/* SELECT */
.select-input { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: white; }

/* KANBAN */
.kanban-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kanban-col { background: var(--bg); border-radius: var(--radius); min-height: 500px; display: flex; flex-direction: column; }
.kanban-col-header { padding: 12px 14px; font-weight: 700; font-size: 13px; border-radius: var(--radius) var(--radius) 0 0; display: flex; align-items: center; gap: 8px; }
.todo-header { background: #F3F4F6; color: #374151; }
.inprog-header { background: #DBEAFE; color: #1D4ED8; }
.review-header { background: #FEF3C7; color: #92400E; }
.done-header { background: #D1FAE5; color: #065F46; }
.badge { background: rgba(0,0,0,0.12); border-radius: 10px; padding: 1px 7px; font-size: 11px; }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 50px; }
.kanban-cards.drag-over { background: rgba(59,130,246,0.06); border-radius: 0 0 var(--radius) var(--radius); }
.kanban-card { background: white; border-radius: var(--radius); padding: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); cursor: grab; }
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.kanban-card.dragging { opacity: 0.4; }
.kcard-project { font-size: 10px; font-weight: 600; color: white; padding: 2px 7px; border-radius: 3px; display: inline-block; margin-bottom: 3px; }
.kcard-client { font-size: 10px; color: #6B7280; margin-bottom: 5px; }
.kcard-title { font-size: 13px; font-weight: 500; margin-bottom: 6px; line-height: 1.4; }
.kcard-meta { font-size: 11px; color: var(--text-muted); display: flex; justify-content: space-between; }
.kcard-user { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* PROJECTS GRID */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card { background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow); }
.project-card-top { height: 6px; }
.project-card-body { padding: 16px; }
.project-card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.project-card-client { font-size: 11px; color: #6B7280; margin-bottom: 6px; }
.project-card-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.project-card-dates { font-size: 11px; color: var(--text-muted); margin-bottom: 10px; }
.project-card-footer { display: flex; align-items: center; justify-content: space-between; }
.proj-status-badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 4px; }
.proj-active { background: #DBEAFE; color: #1D4ED8; }
.proj-done { background: #D1FAE5; color: #065F46; }
.proj-pending { background: #FEF3C7; color: #92400E; }

/* MODAL */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal-box { position: relative; background: white; border-radius: 12px; width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); padding: 0 4px; }
.modal-body { padding: 20px; }
.modal-body label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.modal-body input[type=text], .modal-body input[type=number], .modal-body input[type=date], .modal-body select, .modal-body textarea {
  display: block; width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; margin-top: 4px; font-family: inherit;
}
.modal-body textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* USER LIST */
.user-list-header { display: grid; grid-template-columns: 1fr 1fr 100px 80px; gap: 8px; padding: 8px 12px; background: var(--bg); border-radius: 6px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.user-row { display: grid; grid-template-columns: 1fr 1fr 100px 80px; gap: 8px; padding: 12px 12px; border-bottom: 1px solid var(--border); align-items: center; }
.user-row:last-child { border-bottom: none; }
.user-row:hover { background: #F9FAFB; }
.user-row-name { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13px; }
.user-row-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.user-row-email { font-size: 13px; color: var(--text-muted); }
.role-badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.role-admin { background: #EDE9FE; color: #5B21B6; }
.role-member { background: #F3F4F6; color: #374151; }

/* CLIENTS */
#clients-list { display: flex; flex-direction: column; gap: 16px; }
.client-card { padding: 0; overflow: hidden; }
.client-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: #F8F5FF; border-bottom: 1px solid #EDE9FE;
}
.client-name-wrap { display: flex; align-items: center; gap: 8px; }
.client-icon { font-size: 18px; }
.client-name { font-size: 16px; font-weight: 700; color: var(--text); }
.client-summary { display: flex; align-items: center; gap: 10px; }
.client-badge { font-size: 12px; font-weight: 600; background: #EDE9FE; color: #7C3AED; padding: 3px 8px; border-radius: 12px; }
.client-projects-list { padding: 0 8px 8px; }
.client-proj-header {
  display: grid; grid-template-columns: 1fr 80px 180px 120px 50px;
  gap: 8px; padding: 8px 12px;
  font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  background: var(--bg); border-radius: 6px; margin: 8px 0 4px;
}
.client-project-row {
  display: grid; grid-template-columns: 14px 1fr 80px 180px 120px 50px;
  gap: 8px; padding: 10px 12px; align-items: center;
  border-bottom: 1px solid var(--border);
}
.client-project-row:last-child { border-bottom: none; }
.client-proj-name { font-size: 13px; font-weight: 500; }
.client-proj-dates { font-size: 12px; color: var(--text-muted); }
.client-proj-progress { display: flex; align-items: center; gap: 6px; }
.client-proj-tasks { font-size: 12px; color: var(--text-muted); text-align: right; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }

/* gantt scroll fix */
.accordion-body { overflow: visible; }
#gantt-container-project .gantt-container,
#gantt-container-user .gantt-container,
#gantt-container-client .gantt-container {
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: auto;
  overscroll-behavior: contain;
}
#gantt-container-project .gantt-container .grid-header,
#gantt-container-user .gantt-container .grid-header,
#gantt-container-client .gantt-container .grid-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

/* ATTACHMENTS */
.attachment-section { margin-top: 8px; }
.attachment-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.attachment-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 4px; font-size: 13px; }
.attachment-item a { flex: 1; color: var(--primary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-item a:hover { text-decoration: underline; }
.attachment-size { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.attachment-del { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; line-height: 1; padding: 0 2px; flex-shrink: 0; }
.attachment-del:hover { color: #E74C3C; }
.attachment-upload-btn { display: inline-block; margin-top: 6px; padding: 6px 14px; background: var(--bg); border: 1px dashed var(--border); border-radius: 6px; font-size: 13px; color: var(--primary); cursor: pointer; }
.attachment-upload-btn:hover { background: #F1F5F9; }
