/* Genetidoc GC Notes. Same structure as Contact Sorter, with the Genetidoc brand palette. */
:root {
  --blue: #3E3E7E; --blue-d: #2e2e63; --blue-l: #eceefc; --blue-m: #c9cdf6; --accent: #5E6CE6;
  --pink: #E84E85; --pink-l: #fdeaf1; --cream: #FFF3E8; --mist: #F7F9FC;
  --ink: #232a3d; --ink-2: #35405B; --ink-3: #7b8794; --line: #e3e8ee; --bg: #f5f7fb; --card: #fff;
  --green: #1b8a5a; --green-l: #e5f5ed; --red: #c62828; --red-l: #fdecec; --amber: #9a5b00; --amber-l: #fff4e0;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
h2 { font-size: 15px; margin: 0; color: var(--blue); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: #f0f2f8; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: #4b58d0; }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef1f7; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 4px 8px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid #d3d9e4; border-radius: 8px; padding: 8px 10px; background: #fff; outline: none; }
textarea.input { resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--blue-l); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; color: var(--ink-2); }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; cursor: pointer; }
.check input { margin-top: 3px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--blue-l) 0%, var(--cream) 100%); }
.login-card { width: 380px; background: #fff; border-radius: 14px; padding: 32px; box-shadow: 0 10px 40px rgba(62,62,126,.14); }
.login-card img { height: 46px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* top bar */
.topbar { height: 58px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; padding: 0 18px; position: sticky; top: 0; z-index: 20; }
.topbar .logo { height: 30px; margin-right: 10px; }
.topbar .spacer { flex: 1; }
.nav a { padding: 7px 11px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: #f0f2f8; }
.nav a.active { background: var(--blue-l); color: var(--blue); }
.page { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; }
.page h1 { font-size: 22px; margin: 0; color: var(--blue); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.empty { text-align: center; padding: 50px 20px; color: var(--ink-3); background: #fff; border: 1px dashed #cfd6e3; border-radius: 12px; margin-top: 14px; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: #eef1f6; color: var(--ink-2); white-space: nowrap; }
.pill.blue { background: var(--blue-l); color: var(--blue); }
.pill.green { background: var(--green-l); color: var(--green); }
.pill.amber { background: var(--amber-l); color: var(--amber); }
.pill.pink { background: var(--pink-l); color: #b8285c; }
.pill.red { background: var(--red-l); color: var(--red); }

/* tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
th { background: #f9fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody.click tr { cursor: pointer; }
tbody.click tr:hover { background: #f7f8ff; }

/* library grid */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 14px; }
.lib-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.lib-card.off { opacity: .55; }
.lib-card .img { aspect-ratio: 2.33; background: var(--mist); display: grid; place-items: center; color: var(--ink-3); font-size: 12px; cursor: zoom-in; }
.lib-card .img img { width: 100%; height: 100%; object-fit: contain; }
.lib-card .body { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.lib-card .name { font-weight: 600; }
.lib-card .desc { font-size: 12.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cat { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--pink); }

/* note editor */
.editor { display: grid; grid-template-columns: 1fr 330px; gap: 16px; align-items: start; }
.picker { position: sticky; top: 74px; max-height: calc(100vh - 90px); display: flex; flex-direction: column; padding: 12px; }
.picker .list { overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.pick { display: grid; grid-template-columns: 74px 1fr auto; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 5px; background: #fff; }
.pick.added { background: var(--mist); }
.pick img, .pick .noimg { width: 74px; height: 32px; object-fit: contain; background: var(--mist); border-radius: 4px; cursor: zoom-in; }
.pick .nm { font-size: 13px; font-weight: 500; line-height: 1.25; }
.patient-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 0 12px; }
.patient-grid .span2 { grid-column: span 2; }
.nblock { display: grid; grid-template-columns: 26px 230px 1fr; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: #fff; }
.nblock.dragging { opacity: .4; }
.nblock.over { border-color: var(--accent); box-shadow: 0 0 0 3px var(--blue-l); }
.nblock .handle { cursor: grab; color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; }
.nblock .num { width: 24px; height: 24px; border-radius: 50%; background: var(--pink); color: #fff; display: grid; place-items: center; font-size: 12px; }
.nblock .thumb { width: 230px; aspect-ratio: 2.33; object-fit: contain; background: var(--mist); border-radius: 6px; cursor: zoom-in; border: 1px solid var(--line); }
.nblock .top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.nblock .top b { flex: 1; }
.nblock textarea { min-height: 76px; }
.reason { font-size: 12px; color: var(--accent); margin-top: 4px; }
.tr-box { background: var(--cream); border-radius: 8px; padding: 8px; margin-top: 8px; }
.tr-box label.field { margin-bottom: 6px; }
.stale { color: var(--amber); font-size: 12px; font-weight: 500; }
.hint.block { display: block; }
.hint { background: var(--amber-l); color: #6b4300; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.savestate { font-size: 12.5px; color: var(--ink-3); }
.consult { white-space: pre-wrap; font-size: 12.5px; max-height: 260px; overflow: auto; background: var(--mist); border-radius: 8px; padding: 10px; border: 1px solid var(--line); }
.preview-big img { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.deid { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; min-height: 300px; }
.sug { display: grid; grid-template-columns: 22px 150px 1fr; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid #eef1f4; }
.sug img { width: 150px; aspect-ratio: 2.33; object-fit: contain; background: var(--mist); border-radius: 4px; }
.draft h3 { margin: 0 0 4px; color: var(--pink); }
.draft pre { white-space: pre-wrap; font: inherit; background: var(--mist); padding: 10px; border-radius: 8px; border: 1px solid var(--line); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--blue-m); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.menu { position: relative; display: inline-block; }
.menu .items { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); min-width: 250px; z-index: 40; padding: 5px; }
.menu .items button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu .items button:hover { background: var(--blue-l); }
.menu .items small { display: block; color: var(--ink-3); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(20,22,45,.45); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 540px; max-width: 100%; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { width: 860px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; align-items: center; position: sticky; bottom: 0; background: #fff; }
.drop { border: 2px dashed #c4cbe6; border-radius: 12px; padding: 26px; text-align: center; cursor: pointer; background: #fafbff; }
.drop.over { border-color: var(--accent); background: var(--blue-l); }
.drop img { max-width: 100%; max-height: 220px; border-radius: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.langs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 10px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 8px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; }
.toast.err { background: var(--red); }

/* tablet */
@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; }
  .picker { position: static; max-height: 420px; }
  .nblock { grid-template-columns: 26px 1fr; }
  .nblock .thumb { width: 100%; max-width: 360px; }
  .nblock > div:last-child { grid-column: 1 / -1; }
  .patient-grid { grid-template-columns: 1fr 1fr; }
  .nav a { padding: 7px 7px; }
}
