:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface2: #243040;
  --border: #2e3a4a;
  --text: #e8eef6;
  --muted: #9aacbf;
  --accent: #3b82f6;
  --accent2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --holiday: #94a3b8;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* Login */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(ellipse at top, #1a2a40 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-card h1 { margin: 0 0 6px; font-size: 1.35rem; }
.login-card .sub { color: var(--muted); margin: 0 0 24px; font-size: .95rem; line-height: 1.4; }
.login-card label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.login-card input[type=password] {
  width: 100%; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); margin-bottom: 14px;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--surface2); border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-block { width: 100%; }
.error-msg { color: #fca5a5; font-size: .9rem; margin: 0 0 12px; min-height: 1.2em; }

/* App shell */
#app-shell { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.25rem; }
.topbar .meta { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
}
.badge.admin { color: #86efac; border-color: #166534; background: #052e16; }
.badge.viewer { color: #93c5fd; border-color: #1e40af; background: #0c1a33; }

.tabs {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px;
  background: var(--surface); padding: 6px; border-radius: 12px; border: 1px solid var(--border);
}
.tab {
  flex: 1; min-width: 110px; padding: 10px 12px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 600;
}
.tab.active { background: var(--surface2); color: var(--text); }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 6px; font-size: 1.1rem; }
.card .caption { color: var(--muted); font-size: .9rem; margin: 0 0 14px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-bottom: 12px; font-size: .85rem; color: var(--muted); }
.legend span::before {
  content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px;
}
.legend .c0::before { background: #3b82f6; }
.legend .c1::before { background: #22c55e; }
.legend .c2::before { background: #f59e0b; }
.legend .c3::before { background: #94a3b8; }

.gantt-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gantt-wrap svg { min-width: 720px; display: block; }

table.data {
  width: 100%; border-collapse: collapse; font-size: .92rem;
}
table.data th, table.data td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
table.data tr:hover td { background: rgba(255,255,255,.02); }
.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.status-pill.not-started { background: #422006; color: #fbbf24; }
.status-pill.in-progress { background: #1e3a5f; color: #93c5fd; }
.status-pill.done { background: #052e16; color: #86efac; }
.status-pill.blocked { background: #450a0a; color: #fca5a5; }
select.status-select {
  padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}

.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--bg);
}
.task-item.done .task-text { text-decoration: line-through; color: var(--muted); }
.task-text { flex: 1; }
.task-meta { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.task-actions { display: flex; gap: 6px; flex-shrink: 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.form-row input {
  flex: 1; min-width: 160px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}

.file-list { list-style: none; margin: 0; padding: 0; }
.file-item {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--bg);
}
.file-item .title { font-weight: 600; }
.file-item .detail { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.upload-box {
  border: 2px dashed var(--border); border-radius: 12px; padding: 20px; text-align: center;
  margin-bottom: 16px; background: rgba(255,255,255,.02);
}
.upload-box input[type=file] { margin: 10px 0; color: var(--muted); }
.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--surface2); border: 1px solid var(--border);
  padding: 12px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 50;
  max-width: 320px;
}
.toast.error { border-color: var(--danger); color: #fecaca; }
.note-box {
  background: #0c1a33; border: 1px solid #1e40af; color: #bfdbfe; border-radius: 8px;
  padding: 12px 14px; font-size: .9rem; margin-bottom: 16px; line-height: 1.45;
}
@media (max-width: 640px) {
  table.data th:nth-child(3), table.data td:nth-child(3),
  table.data th:nth-child(4), table.data td:nth-child(4) { display: none; }
  .topbar h1 { font-size: 1.05rem; }
}
.btn-sm { padding: 6px 10px; font-size: .82rem; }
.row-actions { white-space: nowrap; display: flex; gap: 6px; }
.gantt-click { cursor: pointer; }
.gantt-click:hover rect, .gantt-click:hover path, .gantt-click:hover circle { opacity: .8; }
.badge.chinateam { color: #fcd34d; border-color: #92400e; background: #2a1503; }
.ua { max-width: 340px; word-break: break-word; font-size: .8rem; color: var(--muted); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; width: 100%; max-width: 440px; }
.modal h3 { margin: 0 0 12px; }
.modal label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.modal input, .modal select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
