/* Zite+ — Outlook-inspired styling */
:root {
  --blue: #0078d4;
  --blue-dark: #005a9e;
  --blue-tint: #deecf9;
  --blue-tint-2: #c7e0f4;
  --text: #242424;
  --text-2: #616161;
  --text-3: #8a8a8a;
  --line: #e0e0e0;
  --line-2: #f0f0f0;
  --bg: #ffffff;
  --bg-2: #f5f5f5;
  --red: #c4314b;
  --now: #d13438;
  --hour: 52px;
  --gutter: 56px;
  --tabbar: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overscroll-behavior-y: none; }
button { font: inherit; color: inherit; }
a { color: var(--blue); }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { display: flex; flex-direction: column; height: 100dvh; height: 100vh; }
@supports (height: 100dvh) { .app { height: 100dvh; } }
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Nav: bottom tab bar (mobile) ---------- */
.nav {
  order: 2; display: flex; border-top: 1px solid var(--line); background: #fafafa;
  padding-bottom: var(--safe-b); height: calc(var(--tabbar) + var(--safe-b)); flex-shrink: 0;
}
.nav-brand { display: none; }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--text-2); font-size: 11px; font-weight: 600;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.active { color: var(--blue); }
.nav-item.active svg { stroke-width: 2.1; }

/* ---------- Top bar ---------- */
.topbar { padding: 10px 14px 8px; border-bottom: 1px solid var(--line); background: var(--bg); flex-shrink: 0; }
.topbar-row { display: flex; align-items: center; gap: 8px; }
.today-btn {
  border: 1px solid #d1d1d1; background: #fff; border-radius: 4px; padding: 5px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.today-btn:hover { background: var(--bg-2); }
.today-btn:disabled { color: var(--text-3); cursor: default; background: #fff; }
.day-arrows { display: flex; }
.icon-btn { border: 0; background: none; padding: 6px; border-radius: 4px; cursor: pointer; display: inline-flex; color: var(--text); }
.icon-btn:hover { background: var(--bg-2); }
.icon-btn svg { width: 20px; height: 20px; }
.date-title { font-size: 17px; font-weight: 600; margin: 0 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.count { color: var(--text-2); font-size: 14px; }
.updated { color: var(--text-3); font-size: 12px; margin-top: 4px; min-height: 15px; }
.updated .stale { color: #a4262c; font-weight: 600; }

.banner { background: #fff4ce; color: #5c4400; font-size: 13px; padding: 8px 14px; border-bottom: 1px solid #f2dc8a; }
.banner a { color: inherit; font-weight: 600; }

/* ---------- Day view ---------- */
.dayview { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.allday { display: flex; border-bottom: 1px solid var(--line); background: var(--bg); flex-shrink: 0; }
.allday-label { width: var(--gutter); flex-shrink: 0; font-size: 11px; color: var(--text-2); padding: 7px 6px 0 0; text-align: right; }
.allday-events { flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 4px 6px 5px 4px; border-left: 1px solid var(--line); }
.grid-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.grid { display: flex; position: relative; height: calc(var(--hour) * 24 + 12px); padding-top: 8px; }
.gutter { width: var(--gutter); flex-shrink: 0; position: relative; }
.gutter .hr { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--text-2); white-space: nowrap; }
.col { flex: 1; position: relative; border-left: 1px solid var(--line); margin-right: 6px;
  background-image:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, transparent calc(var(--hour) / 2), var(--line-2) calc(var(--hour) / 2), var(--line-2) calc(var(--hour) / 2 + 1px), transparent calc(var(--hour) / 2 + 1px));
  background-size: 100% var(--hour);
  height: calc(var(--hour) * 24);
}
.col.today-col { background-color: #fbfdff; }

.ev {
  position: absolute; border-radius: 4px; overflow: hidden; cursor: pointer; text-align: left;
  background: var(--blue-tint); border: 1px solid var(--blue-tint-2); border-left: 4px solid var(--blue);
  color: #1b1a19; padding: 3px 6px 3px 6px; font-size: 12px; line-height: 1.3;
  box-shadow: 0 0 0 1px #fff; /* gap between side-by-side events */
}
.ev:hover { background: var(--blue-tint-2); }
.ev:focus-visible { outline: 2px solid var(--blue-dark); outline-offset: 1px; }
.ev .t { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev .s { color: #3b3a39; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.short { padding-top: 1px; padding-bottom: 1px; }
.ev.short .t, .ev.short .s { display: inline; }
.ev.short .s::before { content: " · "; }
.ev.tentative { background: repeating-linear-gradient(-45deg, #fff, #fff 4px, var(--blue-tint) 4px, var(--blue-tint) 8px); }
.ev.free { background: #fff; }
.ev.oof { background: #f3e8f8; border-color: #e4cdee; border-left-color: #8764b8; }
.ev.past { opacity: .72; }
.ev.cancelled { background: #f5f5f5; border-color: #e0e0e0; border-left-color: #a19f9d; color: var(--text-2); }
.ev.cancelled .t { text-decoration: line-through; }
.ev .job-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #107c10; margin-right: 4px; vertical-align: 1px; }

.allday .ev { position: static; padding: 3px 8px; font-size: 12px; }

.now-line { position: absolute; left: -5px; right: 0; height: 0; border-top: 2px solid var(--now); z-index: 5; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -1px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--now); }
.now-label { position: absolute; right: 4px; transform: translateY(-50%); font-size: 10.5px; font-weight: 700; color: #fff; background: var(--now); border-radius: 3px; padding: 1px 3px; z-index: 6; }

.empty-day { position: absolute; left: var(--gutter); right: 0; top: 30%; display: flex; justify-content: center; pointer-events: none; }
.empty { text-align: center; color: var(--text-2); padding: 28px 20px; font-size: 14px; }
.empty-card { background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; box-shadow: 0 4px 14px rgba(0,0,0,.06); pointer-events: auto; max-width: 290px; text-align: center; }
.empty-card b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.link-btn { margin-top: 10px; border: 0; background: var(--blue); color: #fff; padding: 7px 14px; border-radius: 4px; font-weight: 600; cursor: pointer; font-size: 13px; }

/* ---------- Detail sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: #fff; border-radius: 14px 14px 0 0;
  max-height: 88vh; overflow-y: auto; padding: 8px 18px calc(22px + var(--safe-b)); box-shadow: 0 -8px 30px rgba(0,0,0,.18);
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-grabber { width: 38px; height: 5px; border-radius: 3px; background: #d1d1d1; margin: 0 auto 8px; }
.sheet-close { position: absolute; top: 10px; right: 10px; }
.sh-title { font-size: 20px; font-weight: 700; margin: 6px 36px 4px 0; line-height: 1.25; }
.sh-title .bar { display: inline-block; width: 4px; height: 18px; background: var(--blue); border-radius: 2px; margin-right: 8px; vertical-align: -2px; }
.sh-time { color: var(--text-2); font-size: 14px; margin-bottom: 10px; }
.sh-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px; background: var(--blue-tint); color: var(--blue-dark); margin-right: 6px; vertical-align: 1px; }
.sh-tag.red { background: #fde7e9; color: var(--red); }
.sh-sec { border-top: 1px solid var(--line-2); padding: 11px 0; display: flex; gap: 12px; }
.sh-sec > svg { flex-shrink: 0; color: var(--text-2); margin-top: 1px; }
.sh-sec .k { font-size: 12px; color: var(--text-2); margin-bottom: 2px; }
.sh-sec .v { font-size: 15px; word-break: break-word; }
.sh-sec .v a { text-decoration: none; font-weight: 600; }
.sh-sec .sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.sh-sec .sub a { font-weight: 500; }
.sh-notes { white-space: pre-wrap; font-size: 14px; line-height: 1.45; background: #fafafa; border: 1px solid var(--line-2); border-radius: 6px; padding: 9px 11px; }
.pm-notes { background: #fff8e6; border-color: #f4e2b3; }
.sh-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; }
.btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; padding: 9px 14px; border-radius: 6px; font-weight: 600; font-size: 14px; border: 1px solid #d1d1d1; color: var(--text); background: #fff; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.people { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.people li { padding: 2px 0; }
.people .r { color: var(--text-3); font-size: 12px; margin-left: 4px; }

/* ---------- Reports ---------- */
.search { margin-top: 10px; display: flex; align-items: center; gap: 8px; border: 1px solid #d1d1d1; border-radius: 6px; padding: 0 10px; background: #fff; }
.search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.search svg { width: 18px; height: 18px; color: var(--text-2); }
.search input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 9px 0; background: transparent; min-width: 0; }
.chips { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; border: 1px solid #d1d1d1; background: #fff; border-radius: 16px; padding: 5px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip .n { color: var(--text-3); margin-left: 4px; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.on .n { color: #cfe4f7; }

.report-list { list-style: none; margin: 0; padding: 8px 12px 16px; overflow-y: auto; flex: 1; min-height: 0; }
.report { display: block; text-decoration: none; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; background: #fff; }
.report:hover { border-color: #b3b3b3; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.report:active { background: #fafafa; }
.r-top { display: flex; align-items: flex-start; gap: 8px; }
.r-site { font-weight: 700; font-size: 15px; flex: 1; min-width: 0; }
.r-addr { color: var(--text-2); font-size: 13px; margin-top: 2px; font-weight: 400; }
.r-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.r-meta span { display: inline-flex; align-items: center; gap: 4px; }
.r-meta svg { width: 14px; height: 14px; }
.status { flex-shrink: 0; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 10px; background: #f0f0f0; color: #424242; }
.status.draft { background: #fff4ce; color: #8a5a00; }
.status.in-progress { background: var(--blue-tint); color: var(--blue-dark); }
.status.submitted { background: #e8e1f5; color: #5c2e91; }
.status.completed, .status.complete, .status.approved { background: #dff6dd; color: #0e700e; }
.status.needs-revision, .status.rejected { background: #fde7e9; color: var(--red); }
.r-ext { color: var(--text-3); }
.r-ext svg { width: 16px; height: 16px; }

/* ---------- Desktop ---------- */
@media (min-width: 768px) {
  :root { --hour: 56px; --gutter: 64px; }
  .app { flex-direction: row; }
  .nav {
    order: 0; flex-direction: column; width: 200px; height: auto; border-top: 0; border-right: 1px solid var(--line);
    padding: 14px 10px; gap: 2px; background: #f7f7f7;
  }
  .nav-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; padding: 4px 8px 16px; color: var(--text); }
  .nav-brand img { border-radius: 6px; }
  .nav-item { flex: 0; flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 14px; padding: 9px 10px; border-radius: 6px; color: var(--text); font-weight: 500; }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-item:hover { background: #ebebeb; }
  .nav-item.active { background: #e1ecf7; color: var(--blue-dark); font-weight: 700; }
  .topbar { padding: 14px 22px 10px; }
  .date-title { font-size: 20px; }
  .page-title { font-size: 22px; }
  .col { margin-right: 18px; }
  .ev { font-size: 12.5px; padding: 4px 8px; }
  .report-list { padding: 12px 22px 22px; display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; align-content: start; }
  .report { margin: 0; }
  #page-reports .search, #page-reports .chips { max-width: 640px; }
  .sheet {
    left: auto; top: 0; bottom: 0; right: 0; width: 440px; max-height: none; border-radius: 0; padding: 18px 24px 24px;
    box-shadow: -8px 0 30px rgba(0,0,0,.15); animation: slide .18s ease-out;
  }
  .sheet-grabber { display: none; }
  @keyframes slide { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
}
@media (display-mode: standalone) and (max-width: 767px) {
  .topbar { padding-top: 6px; }
}

/* ---------- Source badges / job states ---------- */
.ev { padding-right: 26px; }
.src-badge { position: absolute; top: 3px; right: 3px; font-size: 9px; font-weight: 800; line-height: 1; padding: 2px 3px; border-radius: 3px; letter-spacing: .02em; background: #fff; color: var(--blue-dark); border: 1px solid var(--blue-tint-2); }
.src-badge.src-zite { color: #0b6a0b; border-color: #b7dfb3; }
.src-badge.src-both { color: #fff; background: var(--blue); border-color: var(--blue); }
.allday .ev { position: relative; }
.ev.src-zite, .ev.src-both { border-left-color: var(--blue-dark); }
.ev.src-outlook { background: #eff6fc; }
.ev.done { opacity: .78; }
.ev.done .t::after { content: " ✓"; color: #107c10; }
.ev.est { border-bottom-style: dashed; border-bottom-color: var(--blue); }
.sh-tag.green { background: #dff6dd; color: #0e700e; }
.sh-tag.src-zite { background: #dff6dd; color: #0b6a0b; }
.sh-tag.src-both { background: var(--blue); color: #fff; }
.sh-tag.src-outlook { background: #eff6fc; color: var(--blue-dark); }
.sh-sub { color: var(--text-2); font-size: 13px; margin: -4px 0 10px; }
.btn-note { font-weight: 500; font-size: 12px; opacity: .85; margin-left: 2px; }
.btn-note::before { content: "· "; }
