:root {
  --ink: #171815;
  --muted: #75776f;
  --line: #e8e7e2;
  --soft: #f6f5f1;
  --paper: #fff;
  --accent: #d93025;
  --green: #297760;
  --blue: #376e8f;
  --yellow: #cc8f2c;
  --sidebar: 244px;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--soft); font-family: "DM Sans", sans-serif; font-size: 14px; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.main-sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 27px 18px 18px; background: #1c1d1a; color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 31px; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 8px; background: #fff; color: #1c1d1a; font: 700 18px Manrope; }
.brand strong, .sidebar-footer strong { display: block; font: 600 14px Manrope; }
.brand small, .sidebar-footer small { display: block; margin-top: 2px; color: #92948d; font-size: 11px; }
nav { display: flex; flex-direction: column; gap: 5px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 7px; padding: 10px 12px; color: #b7b9b2; background: transparent; text-align: left; transition: .2s; }
.nav-item span { width: 19px; color: #85877f; font-size: 17px; text-align: center; }
.nav-item:hover, .nav-item.active { background: #2c2d29; color: #fff; }
.nav-item.active span { color: #fff; }
.nav-label { margin: 25px 12px 8px; color: #666860; font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.sidebar-footer { margin-top: auto; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 15px 8px 2px; border-top: 1px solid #30312d; }
.sidebar-footer button { border: 0; color: #797b74; background: none; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #1c1d1a; background: #e5d8c7; font-size: 11px; font-weight: 700; }

main { min-width: 0; padding: 0 36px 50px; overflow: hidden; }
.topbar { height: 105px; display: flex; align-items: center; justify-content: space-between; }
.eyebrow { margin: 0 0 3px; color: #999b94; font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: Manrope, sans-serif; }
h1 { font-size: 25px; letter-spacing: -.04em; }
h2 { font-size: 20px; }
h3 { font-size: 14px; }
.topbar-actions { display: flex; gap: 10px; }
.primary-button, .secondary-button, .icon-button { border-radius: 7px; padding: 9px 14px; border: 1px solid var(--ink); font-weight: 600; }
.primary-button { color: #fff; background: var(--ink); }
.secondary-button, .icon-button { background: #fff; border-color: var(--line); }
.icon-button { width: 38px; padding: 8px; color: var(--muted); }

.page { display: none; }
.page.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card, .card { border: 1px solid var(--line); border-radius: 11px; background: var(--paper); box-shadow: 0 1px 1px rgba(0,0,0,.02); }
.stat-card { position: relative; min-height: 122px; padding: 18px; overflow: hidden; }
.stat-card .label { color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin-top: 14px; font: 600 28px Manrope; }
.stat-card small { color: #969890; }
.stat-card .corner { position: absolute; right: 17px; top: 16px; display: grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: var(--soft); color: var(--muted); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 18px; }
.card { padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.text-button { border: 0; background: none; color: var(--muted); font-size: 12px; }
.workload-list { display: flex; flex-direction: column; gap: 17px; }
.workload-row { display: grid; grid-template-columns: 145px 1fr 36px; align-items: center; gap: 14px; }
.person { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.mini-avatar { display: grid; place-items: center; width: 29px; height: 29px; flex: none; border-radius: 50%; background: #ede6dc; font-size: 10px; font-weight: 700; }
.progress { height: 7px; border-radius: 10px; background: #efeee9; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--ink); }
.workload-row > small { color: var(--muted); text-align: right; }
.milestone-list { display: flex; flex-direction: column; gap: 3px; }
.milestone { display: grid; grid-template-columns: 41px 1fr; gap: 13px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.milestone:last-child { border-bottom: 0; }
.date-block { text-align: center; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.date-block strong { display: block; color: var(--ink); font: 600 18px Manrope; }
.milestone p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.search { position: relative; flex: 1; max-width: 330px; }
.search input, .toolbar select { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: #fff; }
.search input { padding-left: 35px; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 8px; color: var(--muted); }
.toolbar select { width: auto; color: #575952; }
.count { margin-left: auto; color: var(--muted); font-size: 12px; }
.table-card { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 15px; color: #969890; background: #fafaf8; font-size: 10px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 14px 15px; border-top: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: #fcfcfa; }
.project-name { font-weight: 600; }
.project-name small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 20px; background: var(--soft); color: #555750; font-size: 10px; font-weight: 600; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #8b8d86; }
.badge.in-progress { color: var(--green); background: #ebf5f1; }
.badge.in-progress::before { background: var(--green); }
.badge.at-risk { color: #a7602c; background: #fff1e5; }
.badge.at-risk::before { background: #c76e32; }
.badge.done { color: var(--blue); background: #edf3f7; }
.badge.done::before { background: var(--blue); }
.table-actions { text-align: right; }
.delete-button { border: 0; padding: 5px 7px; color: #a4a69f; background: none; font-size: 17px; }
.delete-button:hover { color: var(--accent); }
.edit-button { border: 0; padding: 5px 7px; color: #686a63; background: none; font-size: 11px; font-weight: 600; }
.edit-button:hover { color: var(--ink); text-decoration: underline; }

.planning-toolbar { justify-content: space-between; }
.month-control { display: flex; align-items: center; gap: 8px; }
.month-control h2 { min-width: 165px; font-size: 16px; text-align: center; text-transform: capitalize; }
.planning-filters { display: flex; gap: 8px; }
.planning-wrap { border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: auto; }
.timeline { min-width: 1280px; }
.timeline-row { display: grid; grid-template-columns: 300px repeat(var(--days), minmax(28px, 1fr)); min-height: 52px; }
.timeline-row.header { min-height: 53px; position: sticky; top: 0; z-index: 3; background: #fafaf8; }
.project-cell { position: sticky; left: 0; z-index: 2; display: flex; align-items: center; padding: 10px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.header .project-cell { z-index: 4; background: #fafaf8; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.project-info { min-width: 0; }
.project-info strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.project-info small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.day-cell { position: relative; display: flex; align-items: center; justify-content: center; border-right: 1px solid #f0efeb; border-bottom: 1px solid var(--line); color: #a1a39c; background: #fff; font-size: 9px; }
.day-cell.weekend { background: #eeede9; }
.day-cell.today { background: #fff0ef; box-shadow: inset 1px 0 var(--accent), inset -1px 0 var(--accent); color: var(--accent); font-weight: 700; }
.header .day-cell.today::after { content: "AUJ."; position: absolute; top: 3px; font-size: 6px; }
.active-day { background: #fff; }
.active-day.weekend { background: #eeede9; }
.active-day.today { background: #fff0ef; }
.active-day.start { border-radius: 5px 0 0 5px; }
.active-day.end { border-radius: 0 5px 5px 0; }
.active-day::before { content: ""; position: absolute; left: 0; right: 0; top: 15px; height: 22px; background: #9ecbe3; }
.active-day.today::before { background: #84bddb; }
.milestone-dot { position: relative; z-index: 1; width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.leave-band { position: absolute; inset: 8px 2px; border-radius: 4px; background: repeating-linear-gradient(135deg,#f0e7da,#f0e7da 4px,#e7d8c5 4px,#e7d8c5 8px); }
.planning-legend { display: flex; gap: 18px; margin-top: 12px; color: var(--muted); font-size: 10px; }
.planning-legend span { display: flex; align-items: center; gap: 6px; }
.legend-box { width: 13px; height: 8px; border-radius: 2px; background: #9ecbe3; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }
.legend-today { width: 8px; height: 13px; background: #fff0ef; border-left: 1px solid var(--accent); border-right: 1px solid var(--accent); }

.empty-state { padding: 50px 20px; color: var(--muted); text-align: center; }
.connection-error { margin-bottom: 14px; padding: 11px 14px; border: 1px solid #efc9c5; border-radius: 7px; color: #9b3b32; background: #fff1f0; font-size: 12px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: none; place-items: center; padding: 20px; background: rgba(20,21,18,.5); backdrop-filter: blur(3px); }
.modal-backdrop.open { display: grid; }
.modal { width: min(720px, 100%); max-height: 90vh; padding: 24px; border-radius: 12px; background: #fff; overflow: auto; animation: modal .2s ease; }
@keyframes modal { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.modal-header { display: flex; align-items: start; justify-content: space-between; margin-bottom: 24px; }
.close-button { border: 0; background: none; color: var(--muted); font-size: 26px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #676961; font-size: 11px; font-weight: 600; }
.field input, .field select { height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: #fff; }
.field input:focus, .field select:focus, .search input:focus { border-color: #888a83; box-shadow: 0 0 0 3px #f0efeb; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 25px; padding-top: 18px; border-top: 1px solid var(--line); }
.toast { position: fixed; right: 28px; bottom: 25px; z-index: 30; padding: 11px 16px; border-radius: 7px; color: #fff; background: var(--ink); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 900px) {
  :root { --sidebar: 74px; }
  .brand div, .main-sidebar .nav-item:not(.active), .nav-label, .sidebar-footer div:not(.avatar), .sidebar-footer button { display: none; }
  .brand { padding-left: 1px; }
  .nav-item { justify-content: center; }
  .nav-item span { width: auto; }
  .sidebar-footer { display: flex; justify-content: center; }
  main { padding: 0 18px 35px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .app-shell { display: block; }
  .main-sidebar { position: fixed; top: auto; bottom: 0; z-index: 10; width: 100%; height: 62px; padding: 8px; }
  .brand, .nav-label, .sidebar-footer { display: none; }
  nav { flex-direction: row; justify-content: space-around; }
  .nav-item, .main-sidebar .nav-item:not(.active) { display: flex; width: auto; font-size: 0; }
  main { padding-bottom: 82px; }
  .topbar { height: 90px; }
  .topbar .eyebrow, #reset-data { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 105px; padding: 14px; }
  .stat-card strong { font-size: 23px; }
  .workload-row { grid-template-columns: 120px 1fr 30px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .planning-filters { display: none; }
}
