:root {
  --accent: #7b68ee;
  --accent-light: #ede9fe;
  --sidebar-bg: #fafafa;
  --border: #e5e5e5;
  --text: #1f2124;
  --text-muted: #6b7280;
  --bg: #ffffff;
  --blue: #1e88e5;
  --green: #43a047;
  --orange: #fb8c00;
  --red: #e53935;
  --gray: #757575;
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }

.layout { display: flex; min-height: 100vh; }

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: block;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
  padding: 6px 10px 14px;
  border-radius: 6px;
}

.sidebar-header:hover { background: var(--accent-light); }

.sidebar-header .brand-sub {
  font-weight: 500;
  font-size: 11.5px;
  color: var(--text-muted);
}

.project-nav { display: flex; flex-direction: column; gap: 2px; }

.project-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-link:hover { background: var(--accent-light); }

.project-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.project-link .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.due-mark {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--red);
  font-weight: 600;
}

details.dept-group { margin-bottom: 2px; }

details.dept-group > summary { list-style: none; cursor: pointer; }
details.dept-group > summary::-webkit-details-marker { display: none; }

.dept-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.dept-summary:hover { background: var(--accent-light); }

.dept-toggle {
  width: 12px;
  flex-shrink: 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.dept-toggle::before { content: "+"; }
details.dept-group[open] > .dept-summary .dept-toggle::before { content: "\2212"; }

.dept-projects {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 4px 12px;
}

.new-project-link {
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  text-align: center;
}

.new-project-link:hover { color: var(--accent); border-color: var(--accent); }

.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------------- main */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  height: 52px;
}

.tabs { display: flex; gap: 4px; height: 100%; }

.tab {
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 13.5px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Inline department tab bars used inside page content (dashboard, weekly
   report) — separate from the topbar's .tabs so they don't inherit its
   `height: 100%` (which blows up to fill the flex-stretched .main column). */
.subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 16px 0 20px;
}

.subtab {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 13.5px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}

.subtab:hover { color: var(--text); }

.subtab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.admin-link {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 5px;
}

.admin-link:hover { background: var(--accent-light); color: var(--accent); }
.admin-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

.content { padding: 24px 28px 60px; max-width: 1180px; width: 100%; }

h1.page-title { font-size: 20px; margin: 0 0 14px; }
h2.section-title { font-size: 15px; margin: 28px 0 12px; }

.text-muted { color: var(--text-muted); }
.caption { color: var(--text-muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ cards */

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 16px;
}

.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }

.stat-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.stat-card .stat-value { font-size: 22px; font-weight: 700; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.banner {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

.banner.success { background: #eafaf0; color: #1e7e34; border: 1px solid #bfe9cd; }
.banner.info { background: #eef2ff; color: #3949ab; border: 1px solid #c9d3f7; }
.banner.warning { background: #fff4e5; color: #b25c00; border: 1px solid #fcd9a8; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
}

/* ----------------------------------------------------------------- table */

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}
table.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }

/* ------------------------------------------------------------------ form */

.form-row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.form-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 160px; }
.form-field label { font-size: 12px; color: var(--text-muted); }

input[type="text"], input[type="date"], input[type="email"], textarea, select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: white;
}

textarea { resize: vertical; min-height: 60px; }

button, .btn {
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}

button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }

button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.primary:hover { opacity: 0.9; color: white; }

button.small, .btn.small { padding: 4px 10px; font-size: 12px; }
button.danger:hover { border-color: var(--red); color: var(--red); }

details.expander {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 14px;
  margin-bottom: 18px;
}
details.expander summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 13.5px;
  font-weight: 600;
}
details.expander[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 12px; }

.inline-form { display: inline-flex; gap: 6px; align-items: center; }

.note-row { display: flex; gap: 8px; padding: 6px 10px 14px; align-items: center; }
.note-row input[type="text"] { flex: 1; }

.project-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}
.project-group summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}
.project-group .group-body { padding: 0 14px 14px; }

.task-line { padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px; }
.task-line:first-child { border-top: none; }
.task-meta { color: var(--text-muted); font-size: 12px; }
.task-note { color: var(--text-muted); font-size: 12px; font-style: italic; margin-top: 2px; }

/* ---------------------------------------------------------------- kanban */

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.board-col {
  background: var(--sidebar-bg);
  border-radius: 8px;
  padding: 12px;
  min-height: 200px;
}

.board-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  padding: 0 2px;
}

.board-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.board-card .content { padding: 0; font-size: 13px; margin-bottom: 6px; word-break: break-word; }
.board-card .task-meta { margin-bottom: 8px; }
.board-card footer { display: flex; justify-content: space-between; align-items: center; }

/* ----------------------------------------------------------------- gantt */

.gantt-wrap { overflow-x: auto; }
.gantt { min-width: 640px; position: relative; padding-top: 26px; }

.gantt-ticks {
  position: relative;
  height: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.gantt-tick {
  position: absolute;
  top: 0;
  font-size: 11px;
  color: var(--text-muted);
  transform: translateX(-2px);
  border-left: 1px solid var(--border);
  padding-left: 4px;
  height: 100%;
}

.gantt-row {
  position: relative;
  height: 34px;
  border-bottom: 1px dashed var(--border);
}

.gantt-row-label {
  position: absolute;
  left: 0;
  top: 8px;
  font-size: 12.5px;
  z-index: 2;
}

.gantt-bar {
  position: absolute;
  top: 6px;
  height: 20px;
  border-radius: 5px;
  color: white;
  font-size: 11px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-bar.selected { outline: 2px solid var(--accent); outline-offset: 1px; }

.gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px dashed var(--red);
}

/* ------------------------------------------------------------------ modal */

.link-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

dialog.modal {
  border: none;
  border-radius: 10px;
  padding: 20px 24px;
  max-width: 480px;
  width: 90%;
  color: var(--text);
  background: var(--bg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

/* ------------------------------------------------------------- dark mode */

@media (prefers-color-scheme: dark) {
  :root {
    --sidebar-bg: #1c1c1f;
    --border: #333338;
    --text: #ececec;
    --text-muted: #9a9aa2;
    --bg: #121214;
    --accent-light: #2a2440;
  }
  input[type="text"], input[type="date"], input[type="email"], textarea, select, button, .btn {
    background: #1c1c1f;
    color: var(--text);
  }
  .board-card { background: #1c1c1f; }
}
