/* ReBuilder Medical — Discovery Workspace */
:root {
    --navy: #1e3a5f;
    --blue: #2563eb;
    --blue-soft: #eaf1fe;
    --amber: #b45309;
    --amber-soft: #fef3e2;
    --bg: #f4f6f9;
    --line: #e2e8f0;
    --text: #1f2937;
    --muted: #6b7280;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* ---- Auth screens ---- */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--navy);
}
.auth-card {
    background: #fff; padding: 32px; border-radius: 12px;
    width: 360px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.auth-card .brand { color: var(--blue); font-weight: 700; font-size: 13px; letter-spacing: .5px; text-transform: uppercase; }
.auth-card h1 { margin: 8px 0 4px; font-size: 22px; }
.auth-card label { display: block; margin: 16px 0 0; font-size: 14px; font-weight: 600; }
.auth-card input { width: 100%; margin-top: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.auth-card button { margin-top: 20px; width: 100%; padding: 11px; background: var(--blue); color: #fff; border: 0; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.auth-card button:hover { background: #1d4ed8; }

.alert { margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: #fde8e8; color: #b91c1c; font-size: 14px; }
.alert.ok { background: #e7f6ec; color: #15803d; }

/* ---- Top bar ---- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--navy); color: #fff; padding: 0 20px; height: 56px;
}
.topbar-brand { font-weight: 700; letter-spacing: .3px; }
.topbar-right { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topbar-right a { color: #cfe0f5; }
.topbar-right .who { color: #cfe0f5; }

/* ---- Layout ---- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 320px; background: #fff; border-right: 1px solid var(--line); padding: 14px 0 40px; overflow-y: auto; }
.main { flex: 1; padding: 24px 28px; max-width: 820px; }

/* ---- Sidebar ---- */
.group-label { padding: 14px 18px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list a {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 9px 18px; color: var(--text); font-size: 14px; border-left: 3px solid transparent;
}
.cat-list a:hover { background: var(--bg); text-decoration: none; }
.cat-list a.active { background: var(--blue-soft); border-left-color: var(--blue); font-weight: 600; }
.cat-name { display: flex; align-items: center; gap: 6px; }
.cat-meta { display: flex; align-items: center; gap: 8px; }
.count { background: var(--navy); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }

.fda { background: var(--amber-soft); color: var(--amber); font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; letter-spacing: .4px; vertical-align: middle; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #cbd5e1; }
.status-open { background: #cbd5e1; }
.status-in_progress { background: #f59e0b; }
.status-understood { background: #22c55e; }
.status-needs_decision { background: #ef4444; }

.add-cat { margin: 18px 18px 0; }
.add-cat summary { cursor: pointer; color: var(--blue); font-size: 14px; }
.add-cat form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.add-cat input { padding: 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.add-cat button { padding: 8px; background: var(--blue); color: #fff; border: 0; border-radius: 6px; cursor: pointer; }

/* ---- Category header ---- */
.cat-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 20px; }
.cat-header h1 { margin: 0 0 2px; font-size: 22px; }
.status-form label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.status-form select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }

/* ---- Notes ---- */
.notes { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.empty { padding: 24px 0; }
.note { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; border-left: 4px solid #cbd5e1; }
.note-eric { border-left-color: var(--blue); }
.note-gail { border-left-color: #8b5cf6; }
.note-head { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.note-head .author { font-weight: 700; }
.note-head .time { color: var(--muted); }
.note-head .del { margin-left: auto; }
.note-head .del button { border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }
.note-head .del button:hover { color: #ef4444; }
.note-body { font-size: 15px; line-height: 1.5; white-space: normal; }

/* ---- Add note ---- */
.add-note { display: flex; flex-direction: column; gap: 10px; }
.add-note textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; font-family: inherit; resize: vertical; }
.add-note button { align-self: flex-start; padding: 10px 20px; background: var(--blue); color: #fff; border: 0; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.add-note button:hover { background: #1d4ed8; }

/* ---- Account page ---- */
.account-wrap { max-width: 560px; margin: 28px auto; padding: 0 20px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; margin-top: 18px; }
.card h2 { margin: 0 0 14px; font-size: 17px; }
.card label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.card input { display: block; width: 100%; margin-top: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.card button { padding: 10px 18px; background: var(--blue); color: #fff; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer; }
.reset-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.reset-row .reset-name { min-width: 160px; font-size: 14px; }
.reset-row input { flex: 1; margin: 0; }

/* ---- Dashboard ---- */
.dash-wrap { max-width: 1040px; margin: 28px auto; padding: 0 24px; }
.dash-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 8px; }
.dash-head h1 { margin: 0; font-size: 24px; }
.dash-stats { color: var(--muted); font-size: 14px; }
.dash-stats strong { color: var(--text); }
.dash-stats .sep { margin: 0 8px; }

.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.dept-card {
    background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px;
    color: var(--text); display: flex; flex-direction: column; gap: 6px;
    transition: box-shadow .15s, transform .15s, border-color .15s;
}
.dept-card:hover { text-decoration: none; box-shadow: 0 8px 24px rgba(30,58,95,.12); transform: translateY(-2px); border-color: #c7d6ec; }
.dept-icon { font-size: 30px; line-height: 1; }
.dept-name { font-weight: 700; font-size: 16px; color: var(--navy); }
.dept-meta { font-size: 13px; color: var(--muted); }
.dept-meta .sep { margin: 0 6px; }
.dept-status { font-size: 13px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 7px; }
.dept-card.unsorted { border-style: dashed; }

/* ---- Dashboard table (minimal) ---- */
.dept-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.dept-table thead th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 12px 16px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.dept-table th.num, .dept-table td.num { text-align: right; }
.dept-table tbody tr { cursor: pointer; transition: background .12s; }
.dept-table tbody tr:hover { background: var(--blue-soft); }
.dept-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.dept-table tbody tr:last-child td { border-bottom: 0; }
.dept-cell { font-weight: 600; }
.dept-cell .ic { margin-right: 9px; }
.dept-cell a { color: var(--navy); }
.dept-cell a:hover { text-decoration: none; }
.dept-table td.num { color: var(--muted); font-variant-numeric: tabular-nums; }
.status-cell { color: var(--muted); white-space: nowrap; }
.unsorted-row td { background: #fffdf5; }

/* ---- Accordion (expand department rows in place) ---- */
.dept-row { cursor: pointer; }
.dept-row:hover td { background: var(--blue-soft); }
.dept-row .chev { display: inline-block; width: 14px; color: var(--muted); font-size: 11px; transition: transform .15s; }
.dept-row.expanded .chev { transform: rotate(90deg); }
.dept-row.expanded td { background: #f3f7fd; }

.wf-row { display: none; cursor: pointer; }
.wf-row.show { display: table-row; }
.wf-row td { background: #fbfcfe; padding-top: 10px; padding-bottom: 10px; }
.wf-row:hover td { background: var(--blue-soft); }
.wf-cell { padding-left: 44px !important; font-weight: 500; color: var(--text); }
.wf-cell .bullet { color: var(--muted); margin-right: 6px; }

/* ---- Detail view (focused, matches dashboard) ---- */
.detail-wrap { max-width: 780px; margin: 24px auto; padding: 0 24px 48px; }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.detail-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.detail-head h1 { margin: 0; font-size: 22px; }
.wf-jump { border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 13px; color: var(--muted); background: #fff; cursor: pointer; max-width: 240px; }

/* Notes as a clean hairline-divided list (no boxes) */
.notelist { margin: 18px 0 24px; border-top: 1px solid var(--line); }
.note-row { padding: 16px 2px; border-bottom: 1px solid var(--line); }
.note-row .empty { padding: 22px 2px; }
.note-meta { display: flex; align-items: center; gap: 9px; font-size: 13px; margin-bottom: 7px; }
.who-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.who-eric { background: var(--blue); }
.who-gail { background: #8b5cf6; }
.who-name { font-weight: 700; color: var(--navy); }
.note-time { color: var(--muted); }
.note-meta .del { margin-left: auto; }
.note-meta .del button { border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.note-meta .del button:hover { color: #ef4444; }
.note-text { font-size: 15px; line-height: 1.55; }
.note-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; }
.note-actions .del { margin-left: 0; }
.edit-btn { border: 0; background: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 0 4px; }
.edit-btn:hover { color: var(--blue); }
.note-edit { margin-top: 8px; }
.note-edit textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; font-family: inherit; line-height: 1.5; resize: vertical; }
.edit-actions { margin-top: 8px; display: flex; gap: 8px; }
.edit-actions button { padding: 7px 14px; border-radius: 7px; border: 0; cursor: pointer; font-weight: 600; font-size: 13px; }
.edit-actions button[type=submit] { background: var(--blue); color: #fff; }
.edit-actions .cancel { background: var(--bg); color: var(--text); border: 1px solid var(--line); }

.add-wf-inline { margin-top: 22px; }
.add-wf-inline summary { cursor: pointer; color: var(--blue); font-size: 13px; }
.add-wf-inline form { display: flex; gap: 8px; margin-top: 10px; }
.add-wf-inline input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; flex: 1; max-width: 320px; }
.add-wf-inline button { padding: 9px 16px; background: var(--blue); color: #fff; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer; }

/* ---- Single-page app: persistent left nav + content ---- */
.app { display: flex; min-height: calc(100vh - 56px); }
.nav { width: 308px; flex: none; background: #fff; border-right: 1px solid var(--line); overflow-y: auto; }
.content { flex: 1; min-width: 0; padding: 26px 34px 48px; max-width: 860px; }

.nav-head { padding: 14px 18px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); border-bottom: 1px solid var(--line); }

.nav-dept-row { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--navy); font-family: inherit; }
.nav-dept-row:hover { background: var(--bg); }
.nav-dept-row .chev { width: 12px; font-size: 10px; color: var(--muted); transition: transform .15s; flex: none; }
.nav-dept.expanded > .nav-dept-row .chev { transform: rotate(90deg); }
.nav-dept-row .ic { flex: none; }
.nav-dept-name { flex: 1; }
.nav-dept-row .dept-count { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--bg); border-radius: 10px; padding: 1px 8px; }

.nav-wf { list-style: none; margin: 0; padding: 0; display: none; background: #fafbfd; }
.nav-wf.show { display: block; }
.nav-wf a { display: flex; align-items: center; gap: 8px; padding: 9px 16px 9px 36px; font-size: 13px; color: var(--text); border-bottom: 1px solid #eef2f7; }
.nav-wf a:hover { background: var(--blue-soft); text-decoration: none; }
.nav-wf a.active { background: var(--blue-soft); color: var(--navy); font-weight: 600; box-shadow: inset 3px 0 0 var(--blue); }
.nav-wf .wf-name { flex: 1; }
.nav-wf .wf-count { color: var(--muted); font-size: 12px; }

.nav-add { padding: 14px 16px; }
.nav-add summary { cursor: pointer; color: var(--blue); font-size: 13px; }
.nav-add form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.nav-add input { padding: 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.nav-add .icon-in { width: 48px; text-align: center; }
.nav-add input[name=name] { flex: 1; min-width: 120px; }
.nav-add button { padding: 8px 14px; background: var(--blue); color: #fff; border: 0; border-radius: 7px; cursor: pointer; }

.detail-eyebrow { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }

.overview { padding-top: 18px; }
.overview h1 { margin: 0 0 6px; }
.overview-stats { display: flex; gap: 30px; margin-top: 26px; }
.overview-stats > div { display: flex; flex-direction: column; }
.overview-stats .big { font-size: 30px; font-weight: 700; color: var(--navy); }
.overview-stats > div > span:last-child { font-size: 13px; color: var(--muted); }

.status-pill { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; font-weight: 600; cursor: pointer; background: #fff; }
.status-sel-open { color: var(--muted); }
.status-sel-in_progress { color: #b45309; border-color: #f4d9a8; background: #fff8ec; }
.status-sel-understood { color: #15803d; border-color: #bfe6cb; background: #f1faf3; }
.status-sel-needs_decision { color: #b91c1c; border-color: #f3c2c2; background: #fef2f2; }

.add-dept { margin: 22px 0 0; }
.add-dept summary { cursor: pointer; color: var(--blue); font-size: 14px; }
.add-dept form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.add-dept input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.add-dept .icon-in { width: 56px; text-align: center; }
.add-dept button { padding: 9px 18px; background: var(--blue); color: #fff; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer; }

/* ---- Breadcrumb ---- */
.breadcrumb { padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--line); font-size: 14px; }
.breadcrumb a { color: var(--blue); }
.crumb-sep { color: var(--muted); margin: 0 8px; }
.crumb-current { font-weight: 600; }
