:root {
    --bg: #f2f5f4;
    --panel: #ffffff;
    --ink: #17201e;
    --muted: #66736f;
    --line: #dbe2df;
    --brand: #176b57;
    --brand-dark: #0d4d3e;
    --yes: #147a50;
    --yes-soft: #e8f5ef;
    --no: #b64343;
    --no-soft: #faecec;
    --cyan: #21d4e8;
    --magenta: #ff4fa3;
    --yellow: #ffd43b;
    --shadow: 0 18px 50px rgba(26, 47, 41, .09);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 0%, rgba(39, 141, 113, .09), transparent 28rem),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.hidden { display: none !important; }

.topbar {
    min-height: 86px;
    padding: 18px clamp(22px, 4vw, 64px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(118, 137, 131, .2);
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(16px);
}

.topbar h1 { margin: 2px 0 0; font-size: clamp(20px, 2vw, 28px); letter-spacing: -.03em; }
.eyebrow, .step-label { color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

main { width: min(1500px, calc(100% - 32px)); margin: 26px auto 50px; }

.welcome-card {
    width: min(940px, 100%);
    margin: 7vh auto 0;
    padding: clamp(28px, 5vw, 58px);
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.welcome-copy { max-width: 650px; }
.welcome-card h2 { margin: 8px 0 10px; font-size: clamp(28px, 4vw, 44px); letter-spacing: -.04em; }
.welcome-card p { color: var(--muted); font-size: 17px; line-height: 1.6; }

.reviewer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin-top: 32px; }
.reviewer-card {
    min-height: 112px;
    padding: 18px;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fbfcfc;
    cursor: pointer;
    transition: .18s ease;
}
.reviewer-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(23, 107, 87, .1); }
.reviewer-card strong { display: block; font-size: 18px; margin-bottom: 11px; }
.reviewer-card small { color: var(--muted); }
.mini-progress { height: 5px; margin: 10px 0 8px; overflow: hidden; border-radius: 99px; background: #e7ecea; }
.mini-progress i { display: block; height: 100%; background: var(--brand); }
.global-progress { margin-top: 28px; color: var(--muted); font-size: 14px; }

.button, .tool-button, .segment, .details-toggle {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: .15s ease;
}
.button { min-height: 42px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; font-weight: 750; }
.button:hover, .tool-button:hover { border-color: #a9b8b3; }
.button-primary { min-width: 190px; color: #fff; border-color: var(--brand); background: var(--brand); }
.button-primary:hover { background: var(--brand-dark); }
.button-primary:disabled { opacity: .42; cursor: not-allowed; }
.button-secondary { color: var(--brand); border-color: #b9d4cc; background: #edf7f3; }
.button-ghost { color: #485651; background: transparent; }
.reviewer-badge { padding: 9px 13px; border-radius: 999px; color: var(--brand-dark); background: #e8f3ef; font-weight: 750; }

.review-layout { display: grid; grid-template-columns: minmax(560px, 1fr) 430px; gap: 24px; align-items: start; }
.viewer-column, .decision-panel { border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); }
.viewer-column { padding: 18px; }
.decision-panel { position: sticky; top: 20px; overflow: hidden; }

.case-bar { display: flex; align-items: center; justify-content: space-between; min-height: 42px; margin-bottom: 12px; }
.case-bar strong { margin-left: 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.phase-badge { padding: 5px 8px; color: #645415; border-radius: 7px; background: #fff4bf; font-size: 11px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.phase-badge.full { color: #4f5e59; background: #edf1ef; }
.personal-progress { color: var(--muted); font-size: 13px; }

.canvas-shell {
    position: relative;
    width: min(100%, 760px);
    aspect-ratio: 1;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 15px;
    background: #151817;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
    touch-action: none;
}
#reviewCanvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
.loading-overlay { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(10, 15, 13, .72); font-weight: 700; }
.brush-cursor { position: absolute; z-index: 5; pointer-events: none; border: 1px solid white; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.8); }

.viewer-tools { display: flex; align-items: center; gap: 10px; margin-top: 13px; flex-wrap: wrap; }
.zoom-control { flex: 1; min-width: 260px; display: grid; grid-template-columns: auto 1fr 42px; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.zoom-control input { accent-color: var(--brand); }
.tool-button { min-height: 36px; padding: 0 11px; }
.tool-button.active, .segment.active { color: #fff; border-color: var(--brand); background: var(--brand); }
.tool-button.danger { color: var(--no); }
.toggle-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.toggle-control input { accent-color: var(--brand); }
.toggle-control:has(input:disabled) { opacity: .48; }

.legend { display: flex; gap: 18px; margin: 13px 4px 2px; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend-line { width: 24px; height: 3px; border-radius: 2px; background: var(--cyan); }
.legend-line.manual { background: var(--magenta); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 2px #503e00; }
.legend-dot.other { background: transparent; box-shadow: 0 0 0 2px #ff7a59; }

.decision-block { padding: 24px 26px; border-bottom: 1px solid var(--line); }
.decision-block h2 { margin: 7px 0 5px; font-size: 26px; letter-spacing: -.03em; }
.decision-block h3 { margin: 5px 0 0; font-size: 19px; }
.helper { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.answer-button { position: relative; min-height: 94px; padding: 17px 10px; border: 2px solid var(--line); border-radius: 15px; background: #fff; cursor: pointer; }
.answer-button strong { display: block; }
.answer-button.yes:hover, .answer-button.yes.selected { color: var(--yes); border-color: var(--yes); background: var(--yes-soft); }
.answer-button.no:hover, .answer-button.no.selected { color: var(--no); border-color: var(--no); background: var(--no-soft); }
.answer-key { position: absolute; top: 7px; right: 8px; min-width: 21px; padding: 2px 5px; border: 1px solid currentColor; border-radius: 5px; font-size: 10px; opacity: .55; }

.block-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.editor-controls { margin-top: 18px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 11px; background: #edf1ef; }
.segment { min-height: 38px; border-color: transparent; background: transparent; }
.editor-hint { margin: 12px 2px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.edit-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.edit-status { margin-top: 12px; color: var(--muted); font-size: 12px; }
.edit-status.changed { color: var(--magenta); font-weight: 750; }

.details-block { padding-top: 16px; padding-bottom: 16px; }
.details-toggle { width: 100%; padding: 5px 0; text-align: left; color: var(--brand); border: 0; background: transparent; font-weight: 750; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.tag-chip { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; cursor: pointer; font-size: 12px; }
.tag-chip.selected { color: var(--brand-dark); border-color: #8dbdaf; background: #e7f3ef; }
.note-field span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.note-field textarea { width: 100%; resize: vertical; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }

.save-row { display: flex; justify-content: space-between; gap: 10px; padding: 20px 26px 12px; }
.save-secondary-actions { display: flex; gap: 8px; }
.button-postpone { color: #875614; border-color: #e7c98f; background: #fff8e8; }
.button-postpone:hover { border-color: #c89b49; background: #fff2d3; }
.button-postpone:disabled { opacity: .45; cursor: not-allowed; }
.save-error { margin: 14px 26px 0; padding: 11px; color: #8d2d2d; border-radius: 10px; background: var(--no-soft); font-size: 13px; }
.shortcut-help { padding: 0 26px 20px; color: var(--muted); text-align: center; font-size: 11px; }
kbd { padding: 1px 5px; border: 1px solid #cbd3d0; border-bottom-width: 2px; border-radius: 4px; background: #f8faf9; font-family: inherit; }

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

@media (max-width: 700px) {
    main { width: min(100% - 18px, 1500px); margin-top: 10px; }
    .topbar { padding: 13px 14px; }
    .topbar h1 { font-size: 18px; }
    .topbar-actions .button-ghost { padding: 0 10px; font-size: 12px; }
    .reviewer-grid { grid-template-columns: 1fr; }
    .viewer-column { padding: 9px; border-radius: 15px; }
    .answer-grid { grid-template-columns: 1fr; }
    .decision-block { padding: 20px; }
    .save-row { padding-left: 20px; padding-right: 20px; }
    .save-row { align-items: stretch; flex-direction: column; }
    .save-secondary-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .save-row .button-primary { width: 100%; }
    .reviewer-badge { display: none; }
}

/* Imagen CRIC completa */
.original-modal { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 24px; }
.original-backdrop { position: absolute; inset: 0; background: rgba(10, 18, 16, .76); backdrop-filter: blur(4px); }
.original-panel { position: relative; width: min(1460px, 96vw); max-height: calc(100vh - 48px); overflow: hidden; display: flex; flex-direction: column; border-radius: 22px; background: #fff; box-shadow: 0 28px 90px rgba(0, 0, 0, .38); }
.original-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.original-header h2 { margin: 3px 0 2px; font-size: 24px; }
.original-header small { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.original-stage { position: relative; min-height: 260px; overflow: auto; display: grid; place-items: center; padding: 16px; background: #111816; }
.original-stage img { display: block; max-width: 100%; max-height: calc(100vh - 160px); width: auto; height: auto; object-fit: contain; }
.original-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; }

@media (max-width: 600px) {
    .original-modal { padding: 0; }
    .original-panel { width: 100%; min-height: 100vh; max-height: 100vh; border-radius: 0; }
    .original-stage img { max-height: calc(100vh - 125px); }
}

/* Navegador de casos */
.navigator-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.navigator-backdrop { position: absolute; inset: 0; background: rgba(14, 24, 21, .62); backdrop-filter: blur(4px); }
.navigator-panel { position: relative; width: min(1180px, 100%); max-height: calc(100vh - 48px); overflow: hidden; display: flex; flex-direction: column; border-radius: 24px; background: var(--panel); box-shadow: 0 28px 80px rgba(0, 0, 0, .28); }
.navigator-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px 16px; border-bottom: 1px solid var(--line); }
.navigator-header h2 { margin: 5px 0 0; font-size: 28px; letter-spacing: -.035em; }
.navigator-close { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: #fff; cursor: pointer; font-size: 27px; line-height: 1; }
.navigator-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 220px auto; gap: 14px; align-items: end; padding: 16px 26px; border-bottom: 1px solid var(--line); background: #f8faf9; }
.navigator-search span, .navigator-filter span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.navigator-search input, .navigator-filter select { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.navigator-count { min-height: 42px; display: flex; align-items: center; color: var(--muted); font-size: 13px; }
.navigator-loading { padding: 54px; color: var(--muted); text-align: center; }
.navigator-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: max-content; align-content: start; gap: 13px; padding: 20px 26px 28px; }
.case-thumbnail { overflow: hidden; padding: 0; text-align: left; border: 2px solid transparent; border-radius: 14px; background: #f4f7f6; cursor: pointer; transition: .15s ease; }
.case-thumbnail:hover { border-color: #8ebdaf; transform: translateY(-2px); }
.case-thumbnail.current { border-color: var(--yellow); box-shadow: 0 0 0 2px rgba(255, 212, 59, .22); }
.case-thumbnail.completed { background: #edf7f3; }
.case-thumbnail.rejected { background: var(--no-soft); }
.case-thumbnail-image { position: relative; display: block; width: 100%; height: 0; padding-bottom: 100%; overflow: hidden; background: #17201d; }
.case-thumbnail-image img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.case-thumbnail-copy { display: block; padding: 10px 11px 11px; }
.case-thumbnail-id { display: block; overflow: hidden; margin-bottom: 7px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.case-thumbnail-meta { display: flex; align-items: center; justify-content: space-between; gap: 7px; color: var(--muted); font-size: 10px; }
.case-status { padding: 3px 6px; border-radius: 99px; background: #e4eae8; font-weight: 800; }
.case-thumbnail.completed .case-status { color: var(--yes); background: #d9eee6; }
.case-thumbnail.rejected .case-status { color: var(--no); background: #f4d9d5; }
.case-edited { color: var(--magenta); font-weight: 800; }

@media (max-width: 900px) {
    .navigator-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .navigator-modal { padding: 0; }
    .navigator-panel { width: 100%; max-height: 100vh; min-height: 100vh; border-radius: 0; }
    .navigator-toolbar { grid-template-columns: 1fr; }
    .navigator-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; }
}

/* Reviewer management */
.admin-main { width: min(1120px, calc(100% - 32px)); }
.admin-intro {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin: 38px 0 18px;
}
.admin-intro h2 { margin: 7px 0 6px; font-size: 34px; letter-spacing: -.035em; }
.admin-intro p { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.55; }
.admin-card { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); }
.admin-loading { padding: 42px; color: var(--muted); text-align: center; }
.admin-loading.load-error { color: var(--no); }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.admin-total > span { display: block; color: var(--muted); font-size: 12px; }
.admin-total strong span { display: inline; }
.admin-total strong { display: block; margin-top: 4px; font-size: 22px; }
.admin-total strong.invalid-total { color: var(--no); }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { padding: 12px 18px; color: var(--muted); background: #f6f8f7; font-size: 11px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
.admin-table td { padding: 15px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
.admin-table input[type="text"], .admin-table input[type="number"] { width: 100%; min-width: 120px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.admin-table input[type="text"] { min-width: 210px; }
.admin-table input:focus { outline: 2px solid rgba(39, 141, 113, .18); border-color: var(--brand); }
.admin-table input:disabled { color: var(--muted); background: #eef1f0; }
.admin-table small { display: block; margin-top: 5px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.admin-participates { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.admin-participates input { width: 18px; height: 18px; accent-color: var(--brand); }
.number-cell { font-variant-numeric: tabular-nums; }
.admin-help { margin: 20px 24px 0; padding: 15px 17px; border-radius: 12px; color: #43524d; background: #eef6f3; font-size: 13px; }
.admin-help p { margin: 5px 0 0; line-height: 1.5; }
.admin-save-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 24px 24px; }
.admin-change-summary { color: var(--muted); font-size: 13px; }
.admin-success { margin: 16px 24px 0; padding: 11px; color: var(--yes); border-radius: 10px; background: var(--yes-soft); font-size: 13px; }

@media (max-width: 700px) {
    .admin-main { width: min(100% - 18px, 1120px); }
    .admin-intro, .admin-toolbar, .admin-save-row { align-items: stretch; flex-direction: column; }
    .admin-intro { margin-top: 22px; }
    .admin-intro .button, .admin-save-row .button { width: 100%; }
}
