/* ── Issue & Workflow Tracker · design ported from the Claude prototype ── */
:root {
  --bg: #faf9f7;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #7b8794;
  --line: #e4e0da;
  --primary: #2d3f89;
  --green: #22a06b;
  --amber: #e8a13c;
  --red: #d64545;
  --radius: 10px;
  font-family: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
/* 16px+ inputs stop iOS Safari from auto-zooming on focus */
input, select, textarea, button { font: inherit; }
.serif { font-family: 'Source Serif 4', Georgia, serif; }

.boot-splash { padding: 4rem; text-align: center; color: var(--muted); }
.loading, .muted { color: var(--muted); }
.forbidden { padding: 3rem; text-align: center; color: var(--muted); }
.no-access {
  max-width: 420px; margin: 4rem auto; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2.2rem 2rem;
}
.no-access-icon { font-size: 2.2rem; margin-bottom: .6rem; }
.no-access h2 { margin: 0 0 .5rem; }
.no-access p { color: var(--muted); font-size: .92rem; margin: 0 0 1.2rem; }
.error { color: var(--red); font-size: .85rem; }
.spacer { flex: 1; }

/* header */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  display: flex; align-items: center; gap: 2rem;
  padding: .9rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-badge {
  width: 40px; height: 40px; border-radius: 9px; background: var(--primary);
  color: #fff; font-weight: 700; display: grid; place-items: center;
}
.brand h1 { font-size: 1.05rem; margin: 0; }
.brand-sub { font-size: .75rem; color: var(--muted); }
.tabs { display: flex; gap: .25rem; }
.tabs a {
  padding: .45rem .9rem; border-radius: 999px; text-decoration: none;
  color: var(--ink); font-size: .9rem;
}
.tabs a.active { background: var(--ink); color: #fff; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.user-chip { font-size: .85rem; color: var(--muted); }

.app-main { flex: 1; padding: 1.25rem 1.5rem; }
.page-pad { max-width: 900px; margin: 0 auto; }

/* toolbar */
.toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.search {
  padding: .55rem .9rem; border: 1px solid var(--line); border-radius: 8px;
  min-width: 260px; background: var(--panel);
}
.groupby { display: flex; align-items: center; gap: .35rem; font-size: .75rem; color: var(--muted); }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: .35rem .8rem; font-size: .8rem; cursor: pointer;
}
.chip-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* buttons */
.btn-primary {
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: .55rem 1rem; font-weight: 600; cursor: pointer;
}
.btn-success {
  background: var(--green); color: #fff; border: none; border-radius: 8px;
  padding: .45rem .9rem; font-weight: 600; cursor: pointer;
}
.btn-muted {
  background: #eef0f2; color: var(--ink); border: none; border-radius: 8px;
  padding: .5rem .9rem; cursor: pointer;
}
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: .85rem; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--muted); font-size: .9rem; }

/* board */
.board {
  display: flex; gap: 1rem; align-items: flex-start; overflow-x: auto;
  padding-bottom: 1rem; scroll-snap-type: x proximity;
}
.board-col { min-width: min(290px, 85vw); flex: 1; scroll-snap-align: start; }
.col-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.col-title { font-weight: 600; font-size: .95rem; }
.col-count { color: var(--muted); font-size: .85rem; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid #888;
  border-radius: var(--radius); padding: .8rem .9rem; margin-bottom: .7rem; cursor: pointer;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 3px 12px rgba(31,41,51,.08); }
.card-area { font-size: .65rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); margin-bottom: .3rem; }
.card-title { font-weight: 600; font-size: .92rem; line-height: 1.35; }
.decision-flag {
  margin-top: .5rem; background: #fbeaea; color: var(--red); font-size: .78rem;
  padding: .3rem .55rem; border-radius: 6px; display: block; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-foot { display: flex; align-items: center; margin-top: .6rem; }
.avatars { display: flex; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: .6rem; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--panel); margin-left: -6px;
}
.avatar:first-child { margin-left: 0; }
.card-meta { margin-left: auto; display: flex; gap: .6rem; font-size: .75rem; color: var(--muted); align-items: center; }
.due { background: #f1f0ee; padding: .2rem .5rem; border-radius: 6px; }
.due.overdue { background: #fbeaea; color: var(--red); font-weight: 600; }

/* drawer (issue editor) */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(31,41,51,.25); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); z-index: 50;
  background: var(--panel); box-shadow: -8px 0 30px rgba(31,41,51,.18);
  padding: 1.2rem 1.4rem 5.5rem; overflow-y: auto;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.field-label {
  display: block; font-size: .68rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted); margin: 1rem 0 .35rem;
}
.field {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.seg { display: flex; gap: .35rem; flex-wrap: wrap; }
.seg-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: .45rem .8rem; cursor: pointer; font-size: .85rem;
}
.seg-active { background: var(--primary); color: #fff; border-color: var(--primary); }

.steps-head { display: flex; align-items: center; justify-content: space-between; }
.step-row { display: flex; gap: .45rem; align-items: center; margin-bottom: .45rem; }
.step-text { flex: 2; }
.step-date { max-width: 150px; }
.step-owner { max-width: 130px; }
.step-decision .step-text { border-color: var(--red); }
.decision-add {
  width: 100%; border: 1px dashed var(--red); color: var(--red); background: #fdf7f7;
  border-radius: 8px; padding: .55rem; cursor: pointer; margin-top: .3rem;
}
.confidential { display: flex; align-items: center; gap: .5rem; margin-top: 1.2rem; font-size: .9rem; }
.drawer-foot {
  position: fixed; right: 0; bottom: 0; width: min(520px, 100vw);
  display: flex; gap: .6rem; padding: .9rem 1.4rem; background: var(--panel);
  border-top: 1px solid var(--line);
}

/* staff picker */
.staff-picker {
  position: relative;
  display: flex; flex-wrap: wrap; gap: .4rem; border: 1px solid var(--line);
  border-radius: 8px; padding: .4rem; background: #fff;
}
.staff-chip {
  background: #eef0f6; border-radius: 999px; padding: .25rem .6rem; font-size: .82rem;
  display: inline-flex; align-items: center; gap: .3rem;
}
.staff-chip-unresolved { background: #fdf3e0; border: 1px dashed #d9a441; }
.chip-x { background: none; border: none; cursor: pointer; color: var(--muted); }
.staff-input { border: none; flex: 1; min-width: 140px; padding: .3rem; }
.staff-input:focus { outline: none; }
.staff-suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  margin: .2rem 0 0; padding: .25rem; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 240px; overflow-y: auto;
}
.staff-suggest-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: .8rem;
  padding: .45rem .6rem; border-radius: 6px; cursor: pointer; font-size: .88rem;
}
.staff-suggest-item.active { background: #eef0f6; }
.suggest-upn { color: var(--muted); font-size: .78rem; }
.staff-nomatch { color: var(--red); font-size: .8rem; margin-top: .3rem; }

/* balloon notifications */
.toast-host {
  position: fixed; top: 1rem; right: 1rem; z-index: 100;
  display: flex; flex-direction: column; gap: .5rem; max-width: 380px;
}
.toast {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .7rem .95rem; border-radius: 10px; font-size: .88rem;
  background: #fff; border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.16); cursor: pointer;
  animation: toast-in .18s ease-out;
}
.toast-icon { font-weight: 700; }
.toast-success { border-left: 4px solid #2f9e63; }
.toast-success .toast-icon { color: #2f9e63; }
.toast-error { border-left: 4px solid var(--red); }
.toast-error .toast-icon { color: var(--red); }
.toast-info { border-left: 4px solid #3b6fb5; }
.toast-info .toast-icon { color: #3b6fb5; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* teams import */
.import-pickers {
  display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin: 1rem 0;
}
.import-pickers > div { min-width: 200px; }
.import-scan { display: flex; align-items: flex-end; }
.import-create {
  display: flex; gap: 1rem; align-items: flex-end; margin: 1rem 0;
  padding: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.import-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 2rem; }
.import-row {
  display: flex; gap: .7rem; align-items: flex-start; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .9rem;
}
.import-row.imported { opacity: .55; }
.import-row input[type="checkbox"] { margin-top: .25rem; }
.import-body { flex: 1; }
.import-meta {
  display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; font-size: .84rem; margin-bottom: .25rem;
}
.import-tag {
  background: #eef0f6; border-radius: 999px; padding: .1rem .5rem; font-size: .74rem;
}
.imported-tag { background: #e5f3ec; color: #2f9e63; }
.import-text { font-size: .9rem; white-space: pre-wrap; }

/* calendar */
.cal-toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cal-nav { display: flex; gap: .3rem; }
.cal-toggle { margin-left: auto; display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 2rem;
}
.cal-dow {
  background: var(--panel); padding: .45rem; text-align: center;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; color: var(--muted);
}
.cal-cell {
  background: #fff; min-height: 112px; padding: .35rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.cal-out { background: #fafbfc; }
.cal-out .cal-daynum { color: var(--muted); }
.cal-today { outline: 2px solid #3b6fb5; outline-offset: -2px; }
.cal-daynum { font-size: .78rem; font-weight: 600; }
.cal-chip {
  border: 1px solid var(--line); border-left: 3px solid #888; border-radius: 6px;
  background: var(--panel); padding: .25rem .45rem; font-size: .75rem; cursor: pointer;
  display: flex; flex-direction: column; overflow: hidden;
}
.cal-chip:hover { background: #eef0f6; }
.cal-chip-text {
  font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-chip-issue {
  color: var(--muted); font-size: .68rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-overdue .cal-chip-text { color: var(--red); }
.cal-done { opacity: .55; }
.cal-done .cal-chip-text { text-decoration: line-through; }
.cal-view { max-width: 130px; }
.toggle-label {
  display: flex; align-items: center; gap: .4rem;
  font-size: .85rem; color: var(--muted); white-space: nowrap;
}
.cal-grid-week .cal-cell { min-height: 320px; }

/* agenda view */
.agenda-day { margin-bottom: 1.1rem; }
.agenda-date {
  font-size: .8rem; font-weight: 600; text-transform: uppercase; color: var(--muted);
  margin-bottom: .35rem; display: flex; align-items: center; gap: .5rem;
}
.agenda-overdue-tag {
  background: #fbeaea; color: var(--red); border-radius: 999px;
  padding: .1rem .5rem; font-size: .72rem; text-transform: none; font-weight: 500;
}
.agenda-row {
  display: flex; gap: 1rem; align-items: baseline; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid #888;
  border-radius: 8px; padding: .5rem .8rem; margin-bottom: .35rem; font-size: .9rem;
}
.agenda-row:hover { background: #eef0f6; }
.agenda-step { font-weight: 500; }
.agenda-issue { color: var(--muted); font-size: .82rem; flex: 1; }
.agenda-area { font-size: .78rem; white-space: nowrap; }
.cal-overdue-text { color: var(--red); }
.cal-done-text { text-decoration: line-through; opacity: .6; }

/* decisions page */
.decision-card {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--red);
  border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: .8rem;
}
.decision-top { display: flex; align-items: center; gap: .7rem; }
.decision-q { margin: .5rem 0; }
.decision-bottom { display: flex; align-items: center; font-size: .88rem; }

/* reports */
.report { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem 2.4rem; }
.report-head { border-bottom: 2px solid var(--ink); padding-bottom: .8rem; margin-bottom: 1.2rem; }
.report-head h2 { margin: 0; }
.report h3 { margin: 1.4rem 0 .6rem; font-size: 1rem; }
.report-row {
  display: flex; gap: 1rem; align-items: baseline; padding: .5rem 0;
  border-bottom: 1px solid var(--line); font-size: .92rem;
}
.status-pill {
  background: #eef0f2; border-radius: 999px; padding: .15rem .6rem; font-size: .72rem; white-space: nowrap;
}

/* ── mobile ── */
@media (max-width: 640px) {
  /* header: wrap, scrollable tabs, trim identity chrome */
  .app-header { flex-wrap: wrap; gap: .6rem .9rem; padding: .7rem .9rem; }
  .brand-sub, .user-chip { display: none; }
  .brand-badge { width: 32px; height: 32px; }
  .brand h1 { font-size: .95rem; }
  .tabs {
    order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; }
  .header-right { margin-left: auto; }

  .app-main { padding: .9rem .8rem; }

  /* toolbars wrap; search takes the full row */
  .toolbar { flex-wrap: wrap; gap: .6rem; }
  .search { min-width: 0; flex-basis: 100%; }

  /* issue editor */
  .drawer { padding: 1rem .9rem 6.5rem; }
  .drawer-foot { padding: .7rem .9rem; flex-wrap: wrap; }
  .field-row { grid-template-columns: 1fr; }
  .step-row { flex-wrap: wrap; }
  .step-text { flex: 1 1 100%; }

  /* calendar: weekly becomes a stacked day list */
  .cal-grid-week { grid-template-columns: 1fr; }
  .cal-grid-week .cal-dow { display: none; }
  .cal-grid-week .cal-cell { min-height: 56px; }
  /* monthly: compress cells, keep just the step text */
  .cal-cell { min-height: 64px; padding: .2rem; }
  .cal-daynum { font-size: .68rem; }
  .cal-chip { padding: .15rem .3rem; font-size: .66rem; }
  .cal-chip-issue { display: none; }
  .cal-toggle { margin-left: 0; }

  /* agenda rows stack their columns */
  .agenda-row { flex-wrap: wrap; gap: .15rem .6rem; }
  .agenda-issue { flex-basis: 100%; }

  /* reports */
  .report { padding: 1.2rem 1rem; }
}

@media (max-width: 480px) {
  .toast-host { left: 1rem; right: 1rem; max-width: none; }
}

/* bigger touch targets on touch devices */
@media (pointer: coarse) {
  .chip, .seg-btn { padding: .5rem 1rem; }
  .btn-icon, .chip-x { padding: .4rem; }
  .cal-nav .btn-muted { padding: .5rem .95rem; }
}

@media print {
  .app-header, .toolbar { display: none; }
  .report { border: none; padding: 0; }
}
