:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e1e4e8;
  --text: #1f2328;
  --text-muted: #656d76;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  transition: background .15s;
}
.btn:hover { background: #f0f1f3; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger-bg); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 3px 9px; font-size: 12px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 16px; margin: 0; color: var(--text-muted); font-weight: 600; }
.topbar .tabs { flex: 1; }

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}
.tab {
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 13.5px;
}
.tab:hover { background: var(--bg); }
.tab.active {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}
.tab.archived { opacity: .5; }

.section-tabs {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.section-tab {
  padding: 12px 18px;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 14px;
}
.section-tab:hover { color: var(--text); }
.section-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}
.section-tab .count { color: var(--text-muted); font-size: 12px; }
.section-tab-add {
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 600;
  padding: 12px 14px;
}
.section-tab-add:hover { color: var(--primary); }
.section-tab .overdue-badge {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 6px;
  margin-left: 4px;
}

.section-content {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 24px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.section-header h2 { margin: 0; font-size: 17px; }

.task-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: #fafbfc; }
.task-row.overdue { background: #fff8f8; }
.task-row .task-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .task-deadline { width: 100px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.task-row.overdue .task-deadline { color: var(--danger); font-weight: 600; }
.task-row .task-responsible { width: 160px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .badge-overdue {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.task-row .badge-done {
  background: #dcfce7;
  color: var(--success);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.task-detail {
  padding: 16px 20px 20px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}
.task-detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  row-gap: 8px;
  font-size: 13.5px;
  margin-bottom: 14px;
}
.task-detail-grid .label { color: var(--text-muted); }
.task-detail-actions { display: flex; gap: 8px; }

.archive-toggle {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 10px;
  padding: 8px 16px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
}
.archive-toggle:hover { background: var(--surface); }

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

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
}
.modal h3 { margin: 0 0 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 60px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Gantt */
.gantt-wrap {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.gantt-table {
  width: 340px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}
.gantt-table-header, .gantt-row {
  display: grid;
  grid-template-columns: 1fr 90px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
  height: 38px;
  font-size: 12.5px;
}
.gantt-table-header { font-weight: 600; color: var(--text-muted); background: #fafbfc; }
.gantt-row .gname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.gantt-row .gresp { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-row.indent .gname { padding-left: 18px; }
.gantt-row.overdue .gname { color: var(--danger); }
.gantt-scroll {
  flex: 1;
  overflow-x: auto;
}
.gantt-chart {
  position: relative;
}
.gantt-header-days {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  height: 38px;
}
.gantt-day {
  flex-shrink: 0;
  width: 28px;
  font-size: 10.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #f0f1f3;
}
.gantt-day.weekend { background: #f7f7f8; }
.gantt-body { position: relative; }
.gantt-grid-row {
  height: 38px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.gantt-bar {
  position: absolute;
  top: 8px;
  height: 22px;
  border-radius: 4px;
  background: #93c5fd;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  color: #1e3a8a;
  white-space: nowrap;
  overflow: hidden;
}
.gantt-bar.done { background: #86efac; color: #14532d; }
.gantt-bar.overdue { background: #fca5a5; color: #7f1d1d; }
.gantt-bar.sub { height: 16px; top: 11px; opacity: .9; }
.gantt-today-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--danger);
  z-index: 5;
}

.add-subtask-link { font-size: 12px; color: var(--primary); background: none; border: none; padding: 0; }

.gantt-toggle { background: none; border: none; cursor: pointer; color: var(--text-muted); width: 16px; }

/* Auth */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 320px;
}
.login-box h1 { font-size: 18px; margin: 0 0 16px; }

.topbar-user {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* Settings */
.modal-wide { width: 640px; }
.settings-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row input.settings-project-name {
  flex: 1;
  border: 1px solid transparent;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13.5px;
}
.settings-row input.settings-project-name:hover,
.settings-row input.settings-project-name:focus { border-color: var(--border); }
.settings-row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Finance */
.badge-urgency {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: #e5e7eb;
  color: var(--text-muted);
  white-space: nowrap;
}
.badge-urgency.urgent { background: var(--danger-bg); color: var(--danger); }
.badge-status {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  background: #e5e7eb;
  color: var(--text-muted);
}
.badge-status.status-approved { background: #dcfce7; color: var(--success); }
.badge-status.status-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-status.status-paid { background: #dbeafe; color: var(--primary); }
.expense-row .task-deadline { font-variant-numeric: tabular-nums; }
.expense-files { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.expense-files a { color: var(--primary); font-size: 13px; text-decoration: none; }
.expense-files a:hover { text-decoration: underline; }
