/* BriefCycle — application styles
   Design language: light, card-based SaaS. Colour is reserved for workflow
   state (done / current / returned); everything else stays calm and neutral. */
:root {
  --brand: #0f766e;         /* teal 700 */
  --brand-dark: #115e59;
  --brand-soft: #f0fdfa;
  --ink: #1f2937;
  --muted: #6b7280;
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e5e7eb;
  --line-soft: #f1f5f9;

  --done: #10b981;          /* emerald */
  --current: #2563eb;       /* blue */
  --current-soft: #dbeafe;
  --returned: #f59e0b;      /* amber */
  --pending: #e2e8f0;       /* slate 200 */

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- header ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.topbar-inner {
  max-width: 1500px; margin: 0 auto; padding: 0.65rem 1.25rem;
  display: flex; align-items: center; gap: 2rem; flex-wrap: wrap;
}
.brand {
  color: var(--ink); text-decoration: none; font-size: 1.35rem; font-weight: 700;
  letter-spacing: -0.01em; display: flex; align-items: center; gap: 0.6rem;
}
.brand-logo { height: 32px; width: auto; display: block; }
.brand-name { color: var(--brand-dark); }
.footer .powered { color: #94a3b8; }
.mainnav { display: flex; gap: 0.4rem; flex: 1; flex-wrap: wrap; }
.mainnav a {
  color: #374151; text-decoration: none; padding: 0.35rem 0.7rem;
  border-radius: 8px; font-weight: 500; font-size: 0.93rem;
}
.mainnav a:hover, .mainnav a:focus { background: var(--brand-soft); color: var(--brand-dark); }
.userbox { display: flex; align-items: center; gap: 0.75rem; font-size: 0.88rem; color: var(--muted); }
.linklike {
  background: none; border: none; color: var(--brand); cursor: pointer;
  text-decoration: underline; font-size: 0.88rem; padding: 0; font-family: inherit;
}
.linklike:hover { color: var(--brand-dark); }

/* ---------- layout ---------- */
.page { max-width: 1500px; margin: 0 auto; padding: 1.5rem 1.25rem; width: 100%; flex: 1; }
.footer {
  border-top: 1px solid var(--line); color: var(--muted);
  padding: 1.25rem; font-size: 0.85rem; text-align: center; margin-top: 2rem;
  background: var(--card);
}
.page-title { font-size: 1.45rem; font-weight: 650; margin: 0.25rem 0 1.25rem; letter-spacing: -0.01em; }
.breadcrumb {
  font-size: 1.15rem; margin: 0.25rem 0 1.25rem;
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-weight: 600;
}
.breadcrumb span { color: #cbd5e1; font-weight: 400; }
.breadcrumb a { color: var(--brand); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.assigned-note { font-size: 0.85rem; color: var(--muted); font-weight: 400; }

/* ---------- cards & banners ---------- */
.panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 1.1rem; overflow: hidden; background: var(--card);
  box-shadow: var(--shadow);
}
.panel-header {
  padding: 0.65rem 1rem; font-weight: 600; font-size: 0.95rem;
  border-bottom: 1px solid var(--line-soft); background: var(--card);
}
.panel-body { padding: 1rem; }

.banner { padding: 0.65rem 1rem; font-size: 0.93rem; border-left: 4px solid transparent; }
.banner.info { background: #eff6ff; border-left-color: var(--current); color: #1e3a8a; }
.banner.warn, .banner.warning { background: #fffbeb; border-left-color: var(--returned); color: #78350f; }
.banner.error { background: #fef2f2; border-left-color: #dc2626; color: #7f1d1d; }
.banner.success { background: #ecfdf5; border-left-color: var(--done); color: #064e3b; }
main > .banner { border-radius: var(--radius); margin-bottom: 0.9rem; box-shadow: var(--shadow); }

a.banner-link { display: block; text-decoration: none; transition: filter 0.15s ease, transform 0.15s ease; }
a.banner-link:hover { filter: brightness(0.965); transform: translateY(-1px); }

.task-list {
  list-style: none; margin: -0.25rem 0 1rem; padding: 0.25rem 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
}
.task-list li {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.55rem 1rem; align-items: baseline;
}
.task-list li + li { border-top: 1px solid var(--line-soft); }
.task-list a { color: var(--brand-dark); font-weight: 600; text-decoration: none; }
.task-list a:hover { text-decoration: underline; }
.task-list .muted-text { font-size: 0.85rem; }

/* ---------- home ---------- */
.home-links { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; max-width: 860px; }
.home-link {
  display: block; padding: 1.15rem 1.35rem; border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: var(--card); box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.home-link:hover {
  border-color: var(--brand); transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.1);
}
.home-link.muted { opacity: 0.65; }
.home-link-title { display: block; font-size: 1.12rem; font-weight: 650; color: var(--brand-dark); }
.home-link-desc { display: block; color: var(--muted); margin-top: 0.3rem; font-size: 0.93rem; }

/* ---------- filters ---------- */
.filters { padding: 0.85rem 1rem; }
.filter-row { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.filters label.checkbox { flex-direction: row; align-items: center; gap: 0.4rem; padding-bottom: 0.5rem; font-size: 0.88rem; }
.filters input[type="text"], .filters select {
  padding: 0.4rem 0.6rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.9rem; min-width: 10rem; background: var(--card); color: var(--ink);
}
.filters input[type="text"]:focus, .filters select:focus { border-color: var(--brand); }

/* ---------- overview table ---------- */
.table-scroll {
  overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
}
.workflow-table { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
.workflow-table th, .workflow-table td {
  padding: 0.45rem 0.6rem; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}
.workflow-table thead .group-row th {
  background: var(--card); text-align: center; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  border-bottom: none; padding-bottom: 0.1rem;
}
.workflow-table thead tr:nth-child(2) th {
  background: var(--card); font-size: 0.8rem; color: var(--ink);
  border-bottom: 2px solid var(--line);
}
.workflow-table th.grid-col {
  text-align: center; padding: 0.45rem 0.25rem; font-size: 0.72rem;
  color: var(--muted); cursor: help; text-decoration: underline dotted #cbd5e1;
  text-underline-offset: 3px;
}
.workflow-table td.num { text-align: right; }
.workflow-table tbody tr:hover td { background: #fafcff; }
.workflow-table a { color: var(--brand-dark); font-weight: 600; text-decoration: none; }
.workflow-table a:hover { text-decoration: underline; }
.completed-note { color: var(--muted); font-style: italic; text-align: center; }

/* deadline cell in the overview */
.deadline { display: inline-block; padding: 0.1rem 0.4rem; border-radius: 6px; white-space: nowrap; }
.deadline.overdue { background: #fef2f2; color: #b91c1c; font-weight: 600; }
.deadline.due_soon { background: #fffbeb; color: #92400e; font-weight: 600; }
.deadline.ok, .deadline { color: var(--ink); }

/* deadline badge on detail / home / task list */
.deadline-badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; vertical-align: middle;
}
.deadline-badge.overdue { background: #fee2e2; color: #b91c1c; }
.deadline-badge.due_soon { background: #fef3c7; color: #92400e; }

/* progress chips */
td.cell-wrap { text-align: center; padding: 0.3rem 0.15rem; min-width: 2rem; }
.cell {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.45rem; border-radius: 7px;
  font-weight: 700; font-size: 0.8rem; text-decoration: none;
}
a.cell:hover { filter: brightness(0.92); text-decoration: none; }
.cell.done { background: var(--done); color: #fff; }
.cell.returned { background: var(--returned); color: #fff; }
.cell.current {
  background: var(--current-soft); color: var(--current);
  box-shadow: inset 0 0 0 1.5px var(--current);
}
@media (prefers-reduced-motion: no-preference) {
  .cell.current { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse {
    0%, 100% { box-shadow: inset 0 0 0 1.5px var(--current), 0 0 0 0 rgba(37, 99, 235, 0.35); }
    50% { box-shadow: inset 0 0 0 1.5px var(--current), 0 0 0 4px rgba(37, 99, 235, 0); }
  }
}
.cell.pending { background: var(--pending); }
.cell.na {
  background: repeating-linear-gradient(45deg, var(--line-soft) 0 4px, #fff 4px 8px);
  border: 1px solid var(--line-soft);
}

.legend { display: flex; gap: 1.25rem; margin: 0.85rem 0.25rem; font-size: 0.85rem; color: var(--muted); flex-wrap: wrap; }
.legend .sample { margin-right: 0.4rem; vertical-align: middle; font-style: normal; }

/* ---------- detail page ---------- */
.badge {
  display: inline-block; padding: 0.18rem 0.65rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600; vertical-align: middle;
}
.badge.current-step { background: var(--current-soft); color: var(--current); }
.badge.done-step { background: #d1fae5; color: #065f46; }
.badge-returned { background: #fef3c7; color: #92400e; }
.badge-accepted { background: #d1fae5; color: #065f46; }

.details-grid {
  display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 0.65rem 1.5rem;
}
.detail { display: flex; gap: 0.5rem; font-size: 0.9rem; align-items: baseline; }
.detail .k { color: var(--muted); min-width: 7.5rem; }
.detail .v.strong { color: var(--brand-dark); font-weight: 650; }
.detail-wide { grid-column: 1 / -1; }

.doc-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.doc-table th, .doc-table td { border-bottom: 1px solid var(--line-soft); padding: 0.45rem 0.6rem; text-align: left; }
.doc-table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.doc-table a { color: var(--brand-dark); font-weight: 600; }
.doc-table .superseded td { color: var(--muted); }

details > summary { cursor: pointer; color: var(--brand-dark); font-weight: 600; padding: 0.35rem 0; }
details.revisions { margin-top: 0.75rem; }

.history { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.history li { padding: 0.65rem 0; border-bottom: 1px solid var(--line-soft); }
.history li:last-child { border-bottom: none; }
.history-head { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.history-comments {
  margin: 0.45rem 0 0 0.25rem; padding: 0.5rem 0.85rem;
  border-left: 3px solid var(--brand); border-radius: 0 8px 8px 0;
  background: var(--bg); color: var(--ink); font-size: 0.9rem;
}
.history-uploads { font-size: 0.85rem; color: var(--muted); margin-top: 0.35rem; }
.history-uploads a { color: var(--brand-dark); }

/* ---------- document viewer & review workspace ---------- */
.viewer-panel iframe {
  display: block; width: 100%; height: 70vh; border: 0; background: #475569;
}
.viewer-tabs {
  display: flex; gap: 0.35rem; flex-wrap: wrap; padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}
.viewer-tab {
  padding: 0.32rem 0.8rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); cursor: pointer; font-size: 0.85rem; font-family: inherit;
  color: var(--ink);
}
.viewer-tab:hover { border-color: var(--brand); color: var(--brand-dark); }
.viewer-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.viewer-tab.active .muted-text { color: #ccfbf1; }

.workspace {
  display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1.1rem; align-items: start; margin-bottom: 1.1rem;
}
.workspace .panel { margin-bottom: 0; }
.workspace .action-panel { position: sticky; top: 1rem; }
.workspace .review-layout { grid-template-columns: 1fr; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .workspace .action-panel { position: static; }
}

/* ---------- forms ---------- */
.field { margin-bottom: 0.95rem; display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-weight: 600; font-size: 0.88rem; }
.field input[type="text"], .field input[type="number"], .field input[type="date"],
.field input[type="password"], .field select, .field textarea {
  padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.95rem; font-family: inherit; background: var(--card);
  color: var(--ink); max-width: 40rem;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field textarea { width: 100%; max-width: 100%; }
.field input[type="file"] { font-size: 0.9rem; }
.field.has-error input, .field.has-error textarea, .field.has-error select { border-color: #dc2626; }
.field-error { color: #b91c1c; font-size: 0.85rem; }
.help { color: var(--muted); font-size: 0.85rem; }

.review-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
.decision-box {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.85rem 1.1rem; background: var(--bg);
}
.decision-box legend { font-weight: 600; padding: 0 0.4rem; }
.decision-box ul { list-style: none; margin: 0; padding: 0; }
.decision-box li { padding: 0.3rem 0; }
.decision-box label { font-weight: 400; }

.btn {
  display: inline-block; padding: 0.5rem 1.1rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink); cursor: pointer;
  text-decoration: none; font-size: 0.92rem; font-family: inherit; font-weight: 500;
}
.btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.ghost { color: var(--muted); }

.muted-text { color: var(--muted); }

/* ---------- documentation ---------- */
.docs { max-width: 56rem; }
.docs h2 { font-size: 1.15rem; margin: 1.75rem 0 0.6rem; letter-spacing: -0.01em; }
.docs h3 { font-size: 0.98rem; margin: 1.25rem 0 0.5rem; }
.docs p, .docs li { line-height: 1.55; }
.docs .doc-table { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.docs .doc-table th, .docs .doc-table td { padding: 0.5rem 0.75rem; }
.docs-steps { counter-reset: step; list-style: none; margin: 0.75rem 0; padding: 0; }
.docs-steps li {
  position: relative; padding: 0.55rem 0 0.55rem 2.6rem; counter-increment: step;
}
.docs-steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0.55rem;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.docs-steps li + li { border-top: 1px solid var(--line-soft); }
.docs-list { padding-left: 1.2rem; }
.docs-list li { margin-bottom: 0.5rem; }

/* ---------- login ---------- */
.login-card {
  max-width: 24rem; margin: 4rem auto; padding: 1.75rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
}
.login-card h1 { margin-top: 0; font-size: 1.3rem; }
.login-card input { width: 100%; }
.sso-btn { display: block; text-align: center; width: 100%; margin-bottom: 0.5rem; }
.sso-divider {
  display: flex; align-items: center; text-align: center; color: var(--muted);
  font-size: 0.82rem; margin: 1rem 0;
}
.sso-divider::before, .sso-divider::after {
  content: ""; flex: 1; border-bottom: 1px solid var(--line);
}
.sso-divider span { padding: 0 0.6rem; }

@media (max-width: 900px) {
  .details-grid { grid-template-columns: 1fr; }
  .review-layout { grid-template-columns: 1fr; }
}
