:root {
  --font: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --text: #333333;
  --subtle: #777777;
  --accent: #0077E6;
  --green: #15B042;
  --badge-fill: #CAFACE;
  --border: #E4E4E4;
  --bg-soft: #F5F6F8;
  --selected: #E8F2FF;
  --white: #FFFFFF;
  --radius-btn: 10px;
  --radius-badge: 6px;
  --row-h: 40px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

/* Typography roles */
.title { font-size: 16px; line-height: 20px; font-weight: 500; color: var(--text); }
.label { font-size: 13px; line-height: 16px; font-weight: 500; color: var(--text); }
.subtle { color: var(--subtle); }

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.topbar-title { display: flex; flex-direction: column; gap: 2px; }
.topbar-title h1 { margin: 0; }

.eyebrow { color: var(--subtle); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-badge);
  background: var(--badge-fill);
  color: var(--green);
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
  white-space: nowrap;
}

/* View switcher */
.view-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-soft);
  border-radius: var(--radius-btn);
  padding: 2px;
}

.view-tab {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
  color: var(--subtle);
  cursor: pointer;
}

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

.view-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.view-tab[aria-selected="true"] {
  background: var(--text);
  color: var(--white);
}

/* Calendar */
.cal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}

.cal-weekdays span {
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
  color: var(--subtle);
  padding: 4px 6px;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day {
  position: relative;
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  text-align: left;
  font-family: var(--font);
  cursor: default;
}

.day.has-event { cursor: pointer; }
.day.has-event:hover { border-color: var(--accent); }

.day:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.day.outside { background: var(--bg-soft); border-color: transparent; }

.day.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.day-num {
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
  color: var(--text);
}

.day.outside .day-num { color: #B8B8B8; }

/* Event chip in a day */
.chip {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: 6px;
  padding: 5px 6px;
  background: var(--accent);
  color: var(--white);
  font-size: 13px;
  line-height: 16px;
  overflow: hidden;
}

.chip-client { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-type { font-weight: 400; opacity: 0.9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip.done { opacity: 0.55; }

/* Open work panel (calendar) */
.open-work {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.open-work .section-label { color: var(--subtle); }

.open-client {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  text-align: left;
  width: 100%;
}

.open-client:hover { background: var(--bg-soft); }
.open-client:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.open-client.selected { background: var(--selected); border-color: var(--accent); }

.open-client .open-name { flex: none; width: 132px; font-weight: 500; }
.open-client .open-label {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Board (client folders) */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}

.column {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}

.column:hover { border-color: var(--accent); }

.column.selected {
  border-color: var(--accent);
  background: var(--selected);
}

.column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.column-head .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Links block inside a folder card */
.folder-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  text-decoration: none;
  color: var(--text);
}

.link-item .link-label {
  flex: none;
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
  color: var(--subtle);
}

a.link-item .link-value { color: var(--accent); }
a.link-item:hover .link-value { text-decoration: underline; }

.link-value {
  min-width: 0;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-empty .link-value { color: var(--subtle); }

/* To-do rows inside a folder card */
.folder-todos {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.todo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--row-h);
  padding: 6px 8px;
  border-radius: 8px;
}

.todo-row .todo-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-row .todo-date {
  flex: none;
  font-size: 13px;
  line-height: 16px;
  color: var(--subtle);
}

.todo-row.done .todo-label { text-decoration: line-through; color: var(--subtle); }
.todo-row.done .todo-date { color: #A9A9A9; }

.todo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.todo-row.open .todo-dot { background: #C9C9C9; }
.todo-row.done .todo-dot { background: var(--green); }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 4px; }

.tl-week {
  padding: 14px 2px 6px;
  color: var(--subtle);
}

.tl-row {
  height: var(--row-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.tl-row:hover { background: var(--bg-soft); }

.tl-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tl-row.selected {
  background: var(--selected);
  border-color: var(--accent);
}

.tl-date { width: 96px; flex: none; font-size: 13px; line-height: 16px; color: var(--subtle); }
.tl-client { flex: none; max-width: 220px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-label { flex: 1 1 auto; min-width: 0; font-size: 13px; line-height: 16px; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tl-row.done .tl-client { text-decoration: line-through; color: var(--subtle); font-weight: 400; }
.tl-row.done .tl-label { color: #A9A9A9; }

/* Footnote */
.footnote {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.footnote .label { color: var(--subtle); font-weight: 400; }

/* Drawer */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 30, 0.4);
  z-index: 20;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: var(--white);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.10);
  z-index: 30;
  transform: translateX(100%);
  transition: transform 0.18s ease;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.drawer-head .title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.close-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-btn);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--subtle);
  flex: none;
}
.close-btn:hover { background: var(--bg-soft); color: var(--text); }
.close-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.close-btn svg { width: 16px; height: 16px; }

.drawer-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-section { display: flex; flex-direction: column; gap: 6px; }

.section-label { color: var(--subtle); }

.drawer-section .link-item {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
}

.drawer-section .link-item.link-empty { cursor: default; }

.todo-item {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
}

.todo-item.done { background: var(--bg-soft); }

.todo-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }

.todo-label { font-size: 14px; line-height: 1.5; font-weight: 400; color: var(--text); }
.todo-date { font-size: 13px; line-height: 16px; color: var(--subtle); }

.todo-item.done .todo-label { text-decoration: line-through; color: var(--subtle); }

/* Switch */
.switch {
  width: 24px;
  height: 14px;
  border-radius: 14px;
  background: #D5D5D5;
  border: none;
  padding: 0;
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background 0.15s ease;
}

.switch[aria-checked="true"] { background: var(--accent); }

.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--white);
  transition: left 0.15s ease;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.switch[aria-checked="true"] .thumb { left: 12px; }

.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Mobile */
@media (max-width: 620px) {
  .app { padding: 16px 12px 32px; }
  .topbar { gap: 12px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .view-switcher { flex: 1 1 auto; }
  .view-tab { flex: 1 1 0; padding: 0 8px; }

  .day { min-height: 74px; padding: 4px; gap: 3px; }
  .chip { padding: 4px 5px; }
  .chip-type { display: none; }

  .board { grid-template-columns: 1fr; }
  .tl-date { width: 78px; }
  .tl-client { max-width: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer { transition: none; }
  .switch, .switch .thumb { transition: none; }
}
