:root {
  --bg: #ffffff;
  --text: #0f172a;
  --muted: #6b7280;
  --line: rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); -webkit-user-select: none; user-select: none; }
body { font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; }
input, textarea, [contenteditable="true"], .selectable { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; user-drag: none; }

.topbar { position: sticky; top: 0; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,0.03); z-index: 1000; }
.topbar__inner { width: 100%; height: 56px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; }
.topbar__left { display: inline-flex; align-items: center; gap: 10px; }
.brand { font-weight: 600; font-size: 16px; letter-spacing: 0.2px; }
.brand small { color: var(--muted); font-weight: 500; margin-left: 8px; }
.nav-toggle { display: none; appearance: none; border: 0; background: transparent; padding: 8px; margin-right: 8px; border-radius: 8px; }
.nav-toggle:focus-visible { outline: 2px solid #7aa7ff; outline-offset: 2px; }
.nav-toggle .bar { display: block; width: 20px; height: 2px; background: currentColor; margin: 4px 0; border-radius: 1px; }
/* Search in topbar */
.topbar__center { flex: 1; max-width: 520px; margin: 0 16px; }
.search__input { width: 100%; height: 36px; padding: 0 12px 0 36px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.search__input:focus { outline: 2px solid #7aa7ff; outline-offset: 1px; }
.search { position: relative; }
.search__icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #64748b; display: inline-flex; align-items: center; }
.search__dropdown { position: absolute; top: 40px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); z-index: 50; max-height: 300px; overflow: auto; }
.search__group { padding: 6px 8px; border-bottom: 1px solid var(--line); background: rgba(15, 23, 42, 0.02); font-size: 12px; color: #334155; font-weight: 600; }
.search__item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; }
.search__item:hover, .search__item[aria-selected="true"] { background: rgba(15, 23, 42, 0.05); }
.search__badge { font-size: 11px; color: #475569; background: rgba(15,23,42,0.06); padding: 2px 6px; border-radius: 999px; margin-left: auto; }

/* Notifications */
.notif { position: relative; }
.notif__button { position: relative; }
.notif__badge { position: absolute; top: 4px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 10px; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.notif__badge[hidden] { display: none !important; }
.notif__dropdown { position: absolute; top: 44px; right: 0; width: 320px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); z-index: 1100; max-height: 360px; overflow: auto; }
/* Ensure hidden attribute hides dropdown reliably across browsers */
.notif__dropdown[hidden] { display: none !important; }
.notif__group { padding: 6px 10px; border-bottom: 1px solid var(--line); background: rgba(15, 23, 42, 0.02); font-size: 12px; color: #334155; font-weight: 600; }
.notif__item { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; padding: 8px 10px; align-items: center; cursor: pointer; }
.notif__item:hover { background: rgba(15,23,42,0.05); }
.notif__item.unread { font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 999px; }
.dot.holiday { background: #16a34a; }
.dot.event { background: #1d4ed8; }
.dot.reminder { background: #f59e0b; }
.notif__empty { padding: 12px; color: #64748b; }

.topbar__right { display: inline-flex; align-items: center; gap: 10px; }

.team-header { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.team-header .team-avatar { width: 20px; height: 20px; }
.team-header .team-name { font-size: 13px; color: #334155; }

.layout { display: flex; width: 100%; }
.layout__inner { display: flex; width: 100%; min-height: calc(100vh - 56px); }

.sidebar { width: 260px; border-right: 1px solid var(--line); background: #fff; position: sticky; top: 56px; height: calc(100vh - 56px); padding: 16px; overflow: auto; flex-shrink: 0; display: flex; flex-direction: column; }
.user { display: flex; align-items: center; gap: 12px; padding: 8px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(120% 120% at 20% 10%, #bfdcff, #7aa7ff); color: #fff; display: grid; place-items: center; font-weight: 600; letter-spacing: 0.3px; }
.username { font-weight: 600; }
.user-role { color: var(--muted); font-size: 12px; margin-top: 2px; }

nav.menu { margin-top: 8px; display: grid; gap: 4px; flex: 1 1 auto; align-content: start; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: inherit; text-decoration: none; }
.menu a:hover { background: rgba(15, 23, 42, 0.04); }
.menu a:focus-visible { outline: 2px solid #7aa7ff; outline-offset: 2px; }
.menu a.active { background: rgba(15, 23, 42, 0.06); font-weight: 600; }
.menu .icon { width: 18px; height: 18px; opacity: 0.8; }

/* Teams panel */
.teams { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.teams__header { font-size: 12px; color: #64748b; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.teams__select { position: relative; }
.teams__dropdown { position: absolute; left: 0; right: 0; bottom: 44px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); z-index: 70; max-height: 240px; overflow: auto; padding: 6px 0; }
.team-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; }
.team-item:hover, .team-item[aria-selected="true"] { background: rgba(15, 23, 42, 0.05); }
.team-dot { width: 8px; height: 8px; border-radius: 999px; background: #7aa7ff; opacity: 0.8; }
.team-manage { padding: 8px 10px; color: #1d4ed8; cursor: pointer; border-top: 1px solid var(--line); }
.team-manage:hover { background: rgba(29,78,216,0.08); }
/* Team avatars */
.team-avatar { width: 18px; height: 18px; border-radius: 999px; object-fit: cover; display: inline-block; }
.team-avatar.fallback { display: inline-grid; place-items: center; color: #fff; font-size: 10px; font-weight: 600; letter-spacing: 0.3px; }

/* Simple Gantt (per project) */
.gantt { margin-top: 8px; }
.gantt__title { font-size: 12px; color: #64748b; margin-bottom: 4px; }
.gantt__toolbar { display: flex; align-items: center; justify-content: space-between; margin: 6px 0; }
.gantt__bars { height: 160px; display: flex; align-items: flex-end; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; background-image: repeating-linear-gradient(to top, rgba(15,23,42,0.06) 0, rgba(15,23,42,0.06) 1px, transparent 1px, transparent 20px); }
.gantt__col { flex: 1 1 0; min-width: 3px; display: flex; align-items: flex-end; height: 100%; position: relative; }
.gantt__bar { width: 100%; background: #22c55e; /* green-500 */ border-radius: 3px 3px 0 0; position: relative; z-index: 1; }
.gantt__col.is-selected .gantt__bar { box-shadow: inset 0 0 0 2px #2563eb; }
.gantt__nonwork { position: absolute; inset: 6px 0 6px 0; display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; transform: rotate(180deg); font-size: 9px; color: #94a3b8; font-weight: 700; letter-spacing: 0.2px; pointer-events: none; }
.gantt__nonwork.holiday { color: #166534; }
.gantt__nonwork.weekoff { color: #64748b; }
/* Stronger contrast for non-working columns */
.gantt__col.nonwork::before { content: ""; position: absolute; inset: 0; border-radius: 6px; background: rgba(15,23,42,0.08); z-index: 0; }
.gantt__col.nonwork.holiday::before { background: rgba(22,163,74,0.12); }
.gantt__fab { position: fixed; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); padding: 6px 10px; z-index: 100; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.gantt__fab:hover { background: rgba(15,23,42,0.04); }
.gantt__axis { display: flex; gap: 2px; margin-top: 4px; }
.gantt__label { flex: 1 1 0; text-align: center; font-size: 9px; color: #64748b; }
.gantt__col.today::after { content: ""; position: absolute; top: -4px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 6px solid #ef4444; z-index: 2; }
.gantt__tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(4px); opacity: 0; pointer-events: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); padding: 6px 8px; z-index: 40; white-space: nowrap; }
.gantt__tip::after { content: ""; position: absolute; top: -6px; left: 50%; transform: translateX(-50%); border-width: 0 6px 6px 6px; border-style: solid; border-color: transparent transparent #fff transparent; }
.gantt__col:hover .gantt__tip { opacity: 1; transform: translateX(-50%) translateY(0); }
.gantt__tip .tip-count { font-weight: 700; margin-right: 8px; font-size: 13px; }
.gantt__tip .tip-avatars { display: inline-flex; gap: 6px; vertical-align: middle; }

main.content { flex: 1; padding: 24px 16px; width: 100%; }

/* Utility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 1px, 1px); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: inherit; text-decoration: none; cursor: pointer; }
.btn:hover { background: rgba(15, 23, 42, 0.03); }
.btn:focus-visible { outline: 2px solid #7aa7ff; outline-offset: 2px; }
.btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn.primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn.danger { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn.danger:hover { background: #dc2626; border-color: #dc2626; }
.btn.icon { padding: 0 8px; width: 36px; justify-content: center; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar h1 { font-size: 18px; margin: 0; }

/* Table */
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: rgba(15, 23, 42, 0.02); font-weight: 600; font-size: 13px; color: #334155; }
.table tr:last-child td { border-bottom: none; }
.cell-actions { display: inline-flex; gap: 8px; }
.avatar.small { width: 28px; height: 28px; font-size: 12px; }
.name-cell { display: flex; align-items: center; gap: 10px; }

/* Empty state */
.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 24px; text-align: center; color: var(--muted); }

/* Dialog (modal) */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: none; z-index: 20; }
.dialog { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 21; }
.dialog.open, .dialog-backdrop.open { display: flex; }
.dialog__panel { width: 100%; max-width: 560px; background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); border: 1px solid var(--line); }
.dialog__header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dialog__title { font-size: 16px; font-weight: 600; margin: 0; }
.dialog__body { padding: 16px; display: grid; gap: 12px; }
.dialog__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); }

/* Form */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: #334155; }
.input, .select { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
.textarea { min-height: 72px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid #7aa7ff; outline-offset: 1px; }
.hint { font-size: 12px; color: var(--muted); }
.required { color: #ef4444; margin-left: 2px; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

/* Chips */
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; background: rgba(15, 23, 42, 0.06); font-size: 12px; color: #334155; }

/* Image preview & actions */
.img-row { display: flex; align-items: center; gap: 12px; }
.img-actions { display: inline-flex; gap: 8px; }
.avatar.preview { width: 56px; height: 56px; font-size: 18px; }
img.preview { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; display: block; }

/* Panels for Export/Import */
.stack { display: grid; gap: 16px; }
.panel { border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 12px; }
.panel__header { padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.panel__body { padding: 14px; display: grid; gap: 12px; }
.panel .row { align-items: center; }
.inline { display: inline-flex; gap: 8px; align-items: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 12px; color: #334155; }
.split { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; margin-bottom: 12px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
/* Small inline icons */
.ico { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; color: currentColor; }
.btn .ico { margin-right: 6px; }
.panel__header .ico { margin-right: 8px; }

/* Dashboard timeline */
.dash-timeline { width: 100%; display: grid; gap: 8px; }
.dash-header { display: grid; grid-template-columns: 260px 1fr; align-items: center; }
.dash-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.dash-axis { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
.dash-scroll { overflow: hidden; }
.dash-cell { text-align: center; font-size: 11px; color: #64748b; padding: 2px 0; border-bottom: 1px solid var(--line); }
.dash-row { display: grid; grid-template-columns: 260px 1fr; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.dash-track { position: relative; height: 36px; background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.dash-track--axis { height: 0; border: 0; }
.dash-bar { position: absolute; top: 4px; bottom: 4px; background: #22c55e; border-radius: 4px; }
.dash-today { position: absolute; top: -6px; bottom: -6px; width: 2px; background: #ef4444; opacity: 0.9; }

/* Calendar */
.cal { display: grid; gap: 12px; }
.cal__toolbar { display: flex; align-items: center; justify-content: space-between; }
.cal__month { font-size: 18px; font-weight: 600; }
.cal__nav { display: inline-flex; gap: 8px; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.cal__dayname, .cal__cell { padding: 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); min-height: 90px; }
.cal__dayname { background: rgba(15, 23, 42, 0.02); font-weight: 600; font-size: 12px; color: #334155; min-height: auto; }
.cal__cell:nth-child(7n), .cal__dayname:nth-child(7n) { border-right: none; }
.cal__row:last-child .cal__cell { border-bottom: none; }
.cal__cell { position: relative; cursor: pointer; }
.cal__date { position: absolute; top: 8px; right: 8px; font-size: 12px; color: #334155; }
.cal__events { margin-top: 28px; display: grid; gap: 6px; }
.event { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }
.event.type-holiday { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.event.type-event { background: #dbeafe; color: #1e3a8a; border-color: #bfdbfe; }
.event.type-reminder { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.event .remove { all: unset; cursor: pointer; color: inherit; opacity: 0.8; }
.muted-date { color: #94a3b8; }
/* Weekoffs (weekends) */
.weekoff { background: #f1f5f9; }
.weekoff .cal__date { color: #64748b; }
.cal__cell.today { background: #ffe4e6; }
.cal__cell.today .cal__date { background: transparent; color: inherit; padding: 0; }
.event .meta { color: #475569; font-size: 11px; opacity: 0.9; }
.cal__cell.highlight { outline: 2px solid #2563eb; outline-offset: -2px; }

@media (max-width: 768px) {
  .nav-toggle { display: inline-block; }
  .topbar__center { max-width: none; }
  .sidebar { position: fixed; left: 0; top: 56px; height: calc(100vh - 56px); transform: translateX(-100%); transition: transform 200ms ease; box-shadow: 0 10px 30px rgba(0,0,0,0.12); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open { overflow: hidden; }
  .backdrop { display: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,0.25); }
}

/* Mini brand link (match Project Management tool) */
.brand-mini { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; color: #1f2937; text-decoration: none; font-weight: 800; }
.brand-mini img { display: inline-block; width: 50px; height: 50px; border-radius: 8px; }
.brand-mini span { font-size: 20px; line-height: 1.1; }
.brand-mini:hover { opacity: .9; }
