/* App frame: sidebar, top bar, content column. */
.app { display: flex; min-height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; }

/* Sidebar */
.sidebar {
  flex: none; width: 232px;
  position: sticky; top: 0; height: calc(100vh / var(--zoom)); overflow-y: auto;
  background: var(--surface-side);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex; flex-direction: column; gap: 24px;
}
.brand { display: flex; flex-direction: column; padding: 2px 10px; }
.brand-name { font-family: var(--font-head); font-size: 15px; font-weight: 700; letter-spacing: 0.06em; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 20px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-heading { font-size: 12px; font-weight: 500; color: var(--text-label); padding: 0 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius);
  color: var(--text-2); text-decoration: none;
}
.nav-link .icon { color: var(--text-label); }
.nav-link:hover { background: var(--border-soft); color: var(--text); }
.nav-link[aria-current='page'] { background: var(--navy-tint); color: var(--text); font-weight: 600; }
.nav-link[aria-current='page'] .icon { color: var(--navy); }
.nav-label { flex: 1; }
.nav-count { color: var(--text-label); }
.nav-count--late {
  font-size: 12px; font-weight: 600;
  color: var(--late-fg); background: var(--late-bg);
  border-radius: 999px; padding: 0 7px;
}

.sidebar-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 12px 10px 0;
  border-top: 1px solid var(--border);
}
.sidebar-foot:empty { display: none; }

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 32px; min-height: 57px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-muted); }
.crumb a { color: var(--text-muted); text-decoration: none; }
.crumb a:hover { text-decoration: underline; color: var(--text); }
.crumb-sep { color: #98A2B3; }
.crumb [aria-current='page'] { color: var(--text); font-weight: 500; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }

.search {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  width: 280px; max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-input); border-radius: var(--radius);
  background: var(--surface);
}
.search:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-tint); }
.search .icon { color: var(--text-label); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; }
.search input::placeholder { color: var(--text-label); opacity: 1; }
.search kbd {
  font-family: var(--font-body); font-size: 11px; color: var(--text-label);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 5px;
}
.search-msg {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 10;
  font-size: 12px; color: var(--late-fg); white-space: nowrap;
}

/* Narrow screens: sidebar stacks above the content. */
@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--border); }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
}

/* Plain button, used for Retry. */
.button {
  padding: 6px 12px; border-radius: var(--radius);
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text-2);
  font-weight: 500;
}
.button:hover { background: var(--border-soft); }

/* Quiet text button for secondary actions. */
.link-button {
  padding: 4px 0; border: 0; background: transparent;
  color: var(--text-2);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-input);
}
.link-button:hover { color: var(--text); text-decoration-color: var(--text-label); }

.sidebar-foot { align-items: flex-start; }

.persona { display: flex; flex-direction: column; gap: 4px; align-self: stretch; }
.persona label { font-size: 12px; font-weight: 500; color: var(--text-label); }
.persona select {
  background: var(--surface); border: 1px solid var(--border-input);
  border-radius: var(--radius); padding: 6px 8px;
}

/* Toast: a light card in the same family as the confirmation dialog. The tone sets the
   accent strip, the badge and the countdown bar; the wording still says what happened. */
.toast-area { position: fixed; right: 24px; bottom: 24px; z-index: 200; width: min(400px, calc(100vw - 32px)); }
.toast {
  --tone-fg: var(--navy); --tone-bg: var(--navy-tint);
  position: relative; overflow: hidden;
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: inset 3px 0 0 var(--tone-fg), 0 16px 32px -12px rgba(16, 24, 40, 0.28), 0 2px 6px rgba(16, 24, 40, 0.06);
  padding: 12px 12px 14px 16px;
}
.toast--ok { --tone-fg: var(--done-fg); --tone-bg: var(--done-bg); }
.toast--error { --tone-fg: var(--late-fg); --tone-bg: var(--late-bg); }
.toast-icon {
  flex: none; width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tone-bg); color: var(--tone-fg);
}
.toast-icon .icon { font-size: 18px; }
.toast-text { flex: 1; min-width: 0; font-weight: 500; line-height: 1.45; padding-top: 4px; overflow-wrap: anywhere; }
.toast-dismiss {
  flex: none; padding: 4px; border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-label); display: inline-flex;
}
.toast-dismiss .icon { font-size: 18px; }
.toast-dismiss:hover { color: var(--text); background: var(--border-soft); }
.toast-timer {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: var(--tone-fg); opacity: 0.35; transform-origin: left;
}

/* Confirmation dialog */
.confirm-dialog {
  border: 1px solid var(--border); border-radius: var(--radius-hero);
  background: var(--surface); color: var(--text);
  padding: 0; overflow: hidden;
  max-width: min(440px, calc(100vw - 32px)); width: 100%;
  box-shadow: 0 24px 48px -12px rgba(16, 24, 40, 0.28);
}
.confirm-dialog::backdrop {
  background: rgba(18, 38, 63, 0.45);
  backdrop-filter: blur(2px);
}
.confirm-main { display: flex; gap: 14px; align-items: flex-start; padding: 20px 22px; }
.confirm-badge {
  flex: none; width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy-tint); color: var(--navy);
}
.confirm-badge--danger { background: var(--late-bg); color: var(--late-fg); }
.confirm-copy { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-top: 1px; }
.confirm-title { font-size: 16px; line-height: 1.3; margin: 0; }
.confirm-body { color: var(--text-muted); line-height: 1.5; margin: 0; }
.confirm-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.confirm-fields .field { gap: 4px; }
.confirm-fields select, .confirm-fields textarea { width: 100%; box-sizing: border-box; }
.confirm-fields textarea { resize: vertical; }
.confirm-hint { color: var(--text-muted); font-size: 12px; }
.confirm-error { margin: 0; color: var(--late-fg); font-weight: 600; }
.confirm-error[hidden] { display: none; }
.confirm-actions {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface-head); border-top: 1px solid var(--border);
}
