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

:root {
  --teal-dark:   #005F73;
  --teal:        #0096B7;
  --teal-mid:    #0077A8;
  --teal-light:  #48CAE4;
  --teal-pale:   #ADE8F4;
  --teal-bg:     #E8F7FB;
  --teal-row:    #F0FBFE;
  --accent:      #00B4D8;
  --text-dark:   #023340;
  --text-mid:    #3a6070;
  --text-light:  #7ab5c5;
  --border:      #C8E8F0;
  --surface:     #FFFFFF;
  --bg:          #F2FAFB;
}

body {
  font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  font-size: 14px;
}

.hidden { display: none !important; }
.page { min-height: 100vh; }

/* ── Login ──────────────────────────────────────────────────────────────────── */
#login-page {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--teal-dark) 0%, var(--teal) 60%, var(--teal-light) 100%);
  min-height: 100vh;
}
.login-box {
  background: #fff; border-radius: 16px; padding: 44px 40px;
  width: 380px; box-shadow: 0 12px 40px rgba(0,96,183,0.18);
}
.login-logo {
  display: flex; flex-direction: column; align-items: center; margin-bottom: 28px;
}
.login-logo-ring {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal-light));
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
  box-shadow: 0 4px 16px rgba(0,150,183,0.3);
}
.login-logo-ring span { color: #fff; font-size: 22px; font-weight: 900; letter-spacing: -1px; }
.login-box h1 { color: var(--teal-dark); font-size: 18px; font-weight: 700; text-align: center; line-height: 1.3; }
.login-box .subtitle { color: var(--text-light); text-align: center; margin-top: 4px; margin-bottom: 26px; font-size: 12px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--text-mid); font-size: 13px; }
.form-group input {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: 9px; font-size: 14px; transition: border 0.2s; background: var(--teal-bg);
}
.form-group input:focus { outline: none; border-color: var(--teal); background: #fff; }
.error-msg { color: #e05; font-size: 13px; margin-bottom: 10px; min-height: 18px; }
.btn-primary {
  width: 100%; padding: 12px; background: linear-gradient(90deg, var(--teal-dark), var(--teal));
  color: #fff; border: none; border-radius: 9px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: opacity 0.2s; letter-spacing: 0.5px;
}
.btn-primary:hover { opacity: 0.88; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.header {
  background: linear-gradient(90deg, var(--teal-dark) 0%, var(--teal) 100%);
  color: #fff; padding: 0 20px;
  height: 54px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(0,95,115,0.3);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-badge {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900; letter-spacing: -0.5px; color: #fff;
}
.logo { font-size: 16px; font-weight: 700; letter-spacing: 0.3px; }
.logo-sub { font-size: 11px; opacity: 0.7; margin-top: 1px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-pill {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,0.15); border-radius: 20px;
  padding: 4px 12px 4px 6px;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,0.3); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.user-name { font-size: 13px; color: #fff; font-weight: 600; }
.btn-logout {
  padding: 5px 14px; background: rgba(255,255,255,0.12); color: #fff;
  border: 1px solid rgba(255,255,255,0.3); border-radius: 20px;
  cursor: pointer; font-size: 12px; transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.22); }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.main-layout {
  display: flex; height: calc(100vh - 54px); overflow: hidden;
}
.projects-panel {
  flex: 1; display: flex; flex-direction: column; background: var(--surface); overflow: hidden;
}
.side-panel {
  width: 292px; background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

/* ── Legend ─────────────────────────────────────────────────────────────────── */
.legend {
  display: flex; gap: 16px; padding: 7px 14px;
  background: var(--teal-bg); border-bottom: 1px solid var(--border);
  flex-wrap: wrap; align-items: center;
}
.leg-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-mid); }
.leg-dot { width: 13px; height: 13px; border-radius: 3px; }
.leg-dot.done    { background: #22c55e; }
.leg-dot.planned { background: #f59e0b; }
.leg-dot.delayed { background: #ef4444; }
.leg-dot.question{ background: #94a3b8; }
.leg-hint { font-size: 11px; color: var(--text-light); margin-left: auto; font-style: italic; }

/* ── Project Tabs ───────────────────────────────────────────────────────────── */
.project-tabs {
  display: flex; border-bottom: 2px solid var(--border);
  background: #fff; padding: 0 4px;
}
.tab-btn {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 7px 16px; border: none; background: none;
  color: var(--text-light); border-bottom: 3px solid transparent;
  margin-bottom: -2px; transition: all 0.2s; gap: 3px; cursor: pointer;
}
.tab-btn.active { color: var(--teal-dark); border-bottom-color: var(--teal); background: #fff; }
.tab-btn:hover { background: var(--teal-bg); }
.tab-top-row {
  display: flex; align-items: center; gap: 8px;
}
.tab-name {
  font-size: 14px; font-weight: 700; cursor: pointer; color: inherit;
}
.tab-name:hover { text-decoration: underline; color: var(--teal); }
.tab-name-input {
  font-size: 14px; font-weight: 700; border: 1.5px solid var(--teal);
  border-radius: 5px; padding: 1px 6px; outline: none; width: 140px;
  font-family: inherit; background: #fff;
}
.status-badge {
  font-size: 11px; font-weight: 700; border-radius: 10px; padding: 2px 8px;
  border: 1px solid; cursor: pointer; white-space: nowrap;
  position: relative; z-index: 1; transition: opacity 0.15s; user-select: none;
}
.status-badge:hover { opacity: 0.75; }
.tab-owner {
  font-size: 11px; color: var(--text-light); display: flex; align-items: center;
  gap: 4px; white-space: nowrap; position: relative; z-index: 1; cursor: pointer;
}
.tab-btn.active .tab-owner { color: var(--teal-mid); }
.tab-owner:hover { text-decoration: underline; }
.owner-badge {
  background: var(--teal-bg); color: var(--teal-dark); border: 1px solid var(--teal-pale);
  border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 700;
}
.owner-empty { color: #bbb; font-size: 11px; }
.tab-add-btn {
  align-self: center; margin: 0 8px; padding: 5px 14px;
  background: none; border: 1.5px dashed var(--teal-pale);
  border-radius: 8px; color: var(--teal-light); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.tab-add-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-bg); }

/* ── Gantt ──────────────────────────────────────────────────────────────────── */
.gantt-wrapper { flex: 1; overflow: auto; }
#gantt-container { min-width: 920px; }

.gantt-table { width: 100%; border-collapse: collapse; }
.gantt-table th {
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff; font-weight: 600;
  padding: 9px 5px; text-align: center; font-size: 12px;
  position: sticky; top: 0; z-index: 10; white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.15);
}
.gantt-table th.col-cat  { width: 55px; }
.gantt-table th.col-name { text-align: left; padding-left: 12px; width: 200px; }
.gantt-table th.col-kpi  { width: 38px; }
.gantt-table th.col-asgn { width: 88px; }
.gantt-table th.col-month{ width: 44px; }

.gantt-table td { border: 1px solid #e2f0f4; padding: 0; height: 34px; }
.gantt-table tbody tr:nth-child(even) td { background: var(--teal-row); }
.gantt-table tbody tr:nth-child(even) td.td-cat { background: #dff0f6; }

.gantt-table td.td-cat {
  text-align: center; font-weight: 700; color: var(--teal-dark);
  background: #dff0f6; font-size: 12px; vertical-align: middle;
  border-right: 2px solid var(--teal-pale);
  white-space: nowrap;
}
/* Dim repeated category labels — JS adds .cat-repeat class */
.gantt-table td.td-cat.cat-repeat {
  color: var(--teal-pale);
  font-weight: 400;
  font-size: 11px;
}
/* Thick top border when category changes */
.gantt-table tr.cat-new-group td {
  border-top: 2px solid var(--teal-pale) !important;
}
.gantt-table td.td-name {
  padding: 0 8px; font-size: 13px; vertical-align: middle;
  max-width: 200px; cursor: pointer;
}
.gantt-table td.td-name:hover { background: var(--teal-bg); }
.name-display { display: flex; align-items: center; gap: 5px; }
.name-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dark); }
.name-edit-input {
  width: 100%; border: 1.5px solid var(--teal); border-radius: 5px;
  padding: 2px 7px; font-size: 13px; font-family: inherit; outline: none; background: #fff;
}
.open-task-btn {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--teal-pale); font-size: 14px; padding: 2px 3px; border-radius: 4px;
  line-height: 1; transition: color 0.15s, background 0.15s;
}
.open-task-btn:hover { color: var(--teal); background: var(--teal-bg); }

.gantt-table td.td-kpi {
  text-align: center; vertical-align: middle; font-size: 12px;
  color: var(--teal); font-weight: 700;
}
.gantt-table td.td-asgn {
  vertical-align: middle; text-align: center; cursor: pointer; padding: 2px 4px;
}
.gantt-table td.td-asgn:hover { background: var(--teal-bg); }
.asgn-badge {
  display: inline-block; background: var(--teal-bg); color: var(--teal-dark);
  border: 1px solid var(--teal-pale); border-radius: 10px;
  padding: 2px 8px; font-size: 11px; font-weight: 600;
  white-space: nowrap; max-width: 80px; overflow: hidden; text-overflow: ellipsis;
}
.asgn-empty { color: #ccc; font-size: 12px; }

.gantt-table td.td-month {
  text-align: center; vertical-align: middle; cursor: pointer;
  transition: opacity 0.15s; border-right: 1px solid rgba(0,0,0,0.04);
}
.gantt-table td.td-month:hover { opacity: 0.75; }
.cell-done     { background: #22c55e; }
.cell-planned  { background: #f59e0b; }
.cell-delayed  { background: #ef4444; }
.cell-question { background: #94a3b8; }
.cell-none     { background: transparent; }
.cell-question::after { content: '?'; color: #fff; font-weight: 700; font-size: 12px; }

tr[data-task-id] { cursor: grab; }
tr[data-task-id].drag-over td { background: var(--teal-pale) !important; outline: 2px dashed var(--teal); }
tr[data-task-id]:active { cursor: grabbing; }

/* ── Context menu ───────────────────────────────────────────────────────────── */
.ctx-menu {
  position: fixed; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 6px 20px rgba(0,95,115,0.15);
  z-index: 999; overflow: hidden; min-width: 140px;
}
.ctx-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; cursor: pointer; font-size: 13px; color: var(--text-dark);
}
.ctx-item:hover { background: var(--teal-bg); }
.ctx-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* ── Member dropdown ────────────────────────────────────────────────────────── */
.member-dropdown {
  position: fixed; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 6px 20px rgba(0,95,115,0.15);
  z-index: 1000; overflow: hidden; min-width: 140px;
}
.member-item {
  padding: 8px 14px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; gap: 9px; color: var(--text-dark);
}
.member-item:hover { background: var(--teal-bg); }
.member-item.selected { color: var(--teal-dark); font-weight: 700; background: var(--teal-bg); }
.member-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal-light));
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Side Panel ─────────────────────────────────────────────────────────────── */
.panel-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: var(--teal-bg); flex-shrink: 0;
}
.panel-header h3 { font-size: 14px; color: var(--teal-dark); font-weight: 700; }
.task-header { display: flex; flex-direction: column; gap: 5px; }
.btn-back {
  background: none; border: none; color: var(--teal); cursor: pointer;
  font-size: 12px; padding: 0; text-align: left; font-weight: 600;
}
.btn-back:hover { text-decoration: underline; }
#task-panel-title {
  font-size: 13px; color: var(--teal-dark); font-weight: 700;
  line-height: 1.4; word-break: break-word;
}

.panel-section {
  padding: 10px 14px; border-bottom: 1px solid #edf6f9; flex-shrink: 0;
}
.section-label {
  font-size: 11px; font-weight: 700; color: var(--text-light);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.shared-badge {
  background: var(--teal-bg); color: var(--teal); border: 1px solid var(--teal-pale);
  border-radius: 8px; padding: 1px 6px; font-size: 10px; font-weight: 600;
  text-transform: none; letter-spacing: 0;
}

.todo-input-row { display: flex; gap: 6px; margin-bottom: 8px; padding: 10px 14px 0; flex-shrink: 0; }
.panel-section .todo-input-row { padding: 0; margin-bottom: 8px; }
.todo-input-row input {
  flex: 1; padding: 7px 10px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 13px; background: var(--teal-bg);
}
.todo-input-row input:focus { outline: none; border-color: var(--teal); background: #fff; }
.btn-add {
  padding: 7px 11px; background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 18px; line-height: 1;
}
.btn-add:hover { opacity: 0.85; }

.todo-list {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 5px;
  padding: 0 14px 10px;
}
.panel-section .todo-list { padding: 0; max-height: 160px; overflow-y: auto; }
.todo-item {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 7px 9px; background: var(--teal-bg); border-radius: 8px;
  border: 1px solid var(--border); transition: border-color 0.15s;
}
.todo-item:hover { border-color: var(--teal-light); }
.todo-item.done-item { opacity: 0.5; }
.todo-item input[type="checkbox"] { margin-top: 2px; cursor: pointer; flex-shrink: 0; accent-color: var(--teal); }
.todo-text { flex: 1; font-size: 12px; line-height: 1.4; word-break: break-word; color: var(--text-dark); }
.done-item .todo-text { text-decoration: line-through; }
.todo-meta { font-size: 10px; color: var(--text-light); margin-top: 2px; }
.todo-del {
  background: none; border: none; color: #ccc; cursor: pointer;
  font-size: 15px; padding: 0 2px; line-height: 1; flex-shrink: 0;
}
.todo-del:hover { color: #ef4444; }

.panel-section textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 8px;
  padding: 7px 9px; font-size: 12px; resize: vertical; font-family: inherit;
  background: var(--teal-bg);
}
.panel-section textarea:focus { outline: none; border-color: var(--teal); background: #fff; }
.btn-save {
  margin-top: 6px; padding: 5px 14px;
  background: linear-gradient(90deg, var(--teal-dark), var(--teal));
  color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 12px;
}
.btn-save:hover { opacity: 0.85; }
.update-input-row { display: flex; gap: 6px; margin-bottom: 8px; }
.update-input-row input {
  flex: 1; padding: 7px 9px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 12px; background: var(--teal-bg);
}
.update-input-row input:focus { outline: none; border-color: var(--teal); background: #fff; }
.update-input-row .btn-add { font-size: 12px; padding: 7px 10px; }
.updates-list { max-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.update-item {
  background: var(--teal-bg); border-radius: 8px; padding: 8px 10px;
  border-left: 3px solid var(--teal);
}
.update-meta { font-size: 10px; color: var(--text-light); margin-bottom: 3px; }
.update-content { font-size: 12px; line-height: 1.5; color: var(--text-dark); }

/* scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--teal-bg); }
::-webkit-scrollbar-thumb { background: var(--teal-pale); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--teal-light); }
