:root {
    --paper: #efeee9;
    --light-paper: #f8f7f2;
    --soft-grey: #e4e2dc;
    --ink: #11110f;
    --muted: rgba(17, 17, 15, 0.4);
    --faint: rgba(17, 17, 15, 0.08);
    --divider: rgba(17, 17, 15, 0.03);
    --red: #d22d20;
    --dark-red: #b91f17;
    --blue: #80b3ce;
    --mono: "Courier New", Courier, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: "Roboto", Arial, sans-serif;
    font-size: 16px;
    font-weight: 400;
}

body {
    min-height: 100vh;
    background: var(--paper);
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 3px;
}

button {
    border-radius: 0;
}

a {
    color: var(--ink);
    font-weight: 500;
    text-decoration-color: var(--red);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--red);
}

.hidden {
    display: none;
}

.logo {
    color: var(--ink);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.055em;
    line-height: 1;
}

.record-kicker,
label > span,
.boot-screen,
.record-add-files-title {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.075em;
    line-height: 1.35;
    text-transform: uppercase;
}

.working-screen {
    display: none;
    min-height: 100vh;
}

.panel-container {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: 76px auto;
    column-gap: clamp(20px, 2.5vw, 40px);
    width: 100%;
    max-width: 1000px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 clamp(20px, 4vw, 64px) 48px;
}

.panel-header {
    position: sticky;
    top: 0;
    z-index: 10;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: clamp(20px, 2.5vw, 40px);
    min-height: 76px;
    background: rgba(239, 238, 233, 0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.panel-logo {
    grid-column: 1 / 4;
    display: flex;
    align-items: center;
    gap: 16px;
}

.panel-top {
    grid-column: 4 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 24px;
}

.qr-code-icon,
.user {
    border: 0;
    background: transparent;
    cursor: pointer;
}

.qr-code-icon {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.075em;
}

.qr-code-icon:hover,
.user:hover {
    color: var(--red);
}

.user {
    border-bottom: 1px solid var(--ink);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    line-height: 1.5;
    text-transform: uppercase;
}

.panel-left {
    grid-column: 1 / 4;
    min-width: 0;
    padding-top: 30px;
}

.panel-right {
    grid-column: 4 / -1;
    min-width: 0;
    overflow: hidden;
    background: var(--light-paper);
}

#pacientInfo {
    --panel-edge-fade: clamp(32px, 5vw, 64px);
    border-radius: 20px;
    background:
        linear-gradient(
            to bottom,
            var(--paper),
            transparent var(--panel-edge-fade),
            transparent calc(100% - var(--panel-edge-fade)),
            var(--paper)
        ),
        linear-gradient(
            to right,
            var(--paper),
            var(--light-paper) var(--panel-edge-fade),
            var(--light-paper) calc(100% - var(--panel-edge-fade)),
            var(--paper)
        );
}

.right-content {
    width: 100%;
    padding: clamp(28px, 4vw, 60px);
}

.create-med-record {
    --create-edge-fade: clamp(20px, 3vw, 36px);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 138px;
    margin: 26px 5px 34px 0;
    padding: 20px;
    border: 0;
    border-radius: 20px;
    background:
        linear-gradient(
            to bottom,
            var(--paper),
            transparent var(--create-edge-fade),
            transparent calc(100% - var(--create-edge-fade)),
            var(--paper)
        ),
        linear-gradient(
            to right,
            var(--paper),
            var(--light-paper) var(--create-edge-fade),
            var(--light-paper) calc(100% - var(--create-edge-fade)),
            var(--paper)
        );
    box-shadow: 0 7px 18px rgba(17, 17, 15, 0.06);
    cursor: pointer;
    transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.create-med-record::before {
    position: absolute;
    top: 18px;
    left: 20px;
    content: "+  NEW CASE";
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.075em;
}

.create-med-record:hover {
    color: var(--light-paper);
    background: var(--ink);
    box-shadow: 0 9px 22px rgba(17, 17, 15, 0.17);
}

.create-med-record.dragover {
    color: var(--ink);
    background: var(--blue);
    box-shadow: 0 11px 26px rgba(17, 17, 15, 0.2);
}

.create-med-record-title {
    font-size: 19px;
    font-weight: 500;
    letter-spacing: -0.055em;
}

.quick-create-hint {
    margin-top: 7px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.02em;
    line-height: 1.45;
}

.create-med-record:hover .quick-create-hint {
    color: rgba(248, 247, 242, 0.62);
}

.panel-left-item {
    width: 100%;
}

.record-item {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 44px;
    width: 100%;
    padding: 10px 12px 10px 16px;
    border: 0;
    border-bottom: 1px solid var(--divider);
    background: transparent;
    cursor: pointer;
    color: inherit;
    font: inherit;
    font-size: 14px;
    line-height: 1.25;
    text-align: left;
    transition: color 120ms ease, background-color 120ms ease;
}

.record-item::before {
    position: absolute;
    inset: 8px auto 8px 0;
    width: 3px;
    content: "";
    background: transparent;
}

.record-item.selected::before {
    background: var(--red);
}

.record-item.selected {
    font-weight: 500;
}

.record-item:hover {
    color: var(--light-paper);
    background: var(--ink);
}

.record-item.is-dicom-optimizing {
    padding-right: 90px;
}

.record-item.is-dicom-optimizing::after {
    position: absolute;
    right: 10px;
    content: "PROCESSING";
    color: var(--red);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    animation: processing-blink 1.4s steps(2, end) infinite;
}

.record-item:hover.is-dicom-optimizing::after {
    color: var(--blue);
}

@keyframes processing-blink {
    50% {
        opacity: 0.35;
    }
}

.patient-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 18px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.04em;
}

.patient-pagination[hidden] {
    display: none;
}

.patient-pagination button {
    border: 0;
    border-bottom: 1px solid currentColor;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-transform: uppercase;
}

.patient-pagination button:hover:not(:disabled) {
    color: var(--red);
}

.patient-pagination button:disabled {
    color: rgba(17, 17, 15, 0.28);
    cursor: default;
}

.patient-pagination-label {
    color: var(--muted);
    text-align: center;
}

.panel-bottom {
    display: none;
}

.record-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    column-gap: clamp(24px, 4vw, 56px);
    width: 100%;
}

.record-header {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: flex-start;
    column-gap: 32px;
    margin-bottom: clamp(28px, 4vw, 52px);
}

.record-title-block {
    display: contents;
}

.record-title-block > .record-kicker {
    grid-column: 1;
    grid-row: 1;
}

.record-kicker {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
}

.record-header-left {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 2;
    align-items: center;
    gap: 18px;
    margin-top: 20px;
    min-width: 0;
}

.record-header-actions {
    display: flex;
    grid-column: 2;
    grid-row: 1;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 2px;
}

.patient-name {
    min-width: 0;
    font-size: 42px;
    font-weight: 500;
    letter-spacing: -0.07em;
    line-height: 0.94;
    box-shadow: 0 5px 0 var(--red);
    word-break: break-word;
}

.remove-record-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 10px;
    line-height: 1.4;
}

.remove-record-icon:hover {
    background: transparent;
    color: var(--red);
}

#date {
    flex: 0 0 auto;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    line-height: 1.4;
    text-align: right;
    text-transform: uppercase;
}

#date::before {
    content: "CREATED / ";
}

.patient-description {
    width: 100%;
}

.patient-description-table {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.patient-description-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: start;
    gap: 0;
    padding: 10px;
}

.patient-description-icon {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 28px;
    height: 28px;
    color: var(--ink);
}

.patient-description-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: square;
    stroke-linejoin: miter;
}

.patient-description-tone-imaging .patient-description-icon,
.patient-description-tone-modality .patient-description-icon {
    justify-content: center;
    background: var(--blue);
    color: var(--ink);
}

.patient-description-tone-alert .patient-description-icon {
    color: var(--red);
}

.patient-description-copy {
    min-width: 0;
}

.patient-description-label {
    margin: 0;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.065em;
    line-height: 1.3;
    text-transform: uppercase;
}

.patient-description-value {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.record-add-files-zone {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    align-items: start;
    gap: 6px;
    min-height: 66px;
    margin-top: 0;
    padding: 12px 14px;
    border: 1px dashed var(--divider);
    background: rgba(239, 238, 233, 0.3);
    cursor: pointer;
    border-radius: 20px;
    transition: border-color 140ms ease, background-color 140ms ease;
}

.record-add-files-zone .quick-create-hint {
    margin: 0;
    font-size: 9px;
    line-height: 1.3;
    text-align: left;
}

.record-add-files-zone:hover {
    border-color: var(--ink);
    background: var(--soft-grey);
}

.record-add-files-zone.dragover {
    border-color: var(--ink);
    background: var(--blue);
}

.files {
    margin-top: clamp(42px, 6vw, 84px);
}

.empty-workspace {
    display: flex;
    align-items: center;
}

.empty-workspace-copy {
    width: min(760px, 100%);
    margin-left: clamp(28px, 8vw, 140px);
    padding: 60px clamp(28px, 4vw, 60px);
}

.empty-workspace h1 {
    max-width: 700px;
    font-size: clamp(48px, 6vw, 84px);
    font-weight: 500;
    letter-spacing: -0.075em;
    line-height: 0.93;
}

.empty-workspace p {
    max-width: 430px;
    margin-top: 28px;
    color: var(--muted);
    font-size: 16px;
    font-weight: 300;
    line-height: 1.55;
}

.boot-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 100vh;
    color: var(--muted);
}

.boot-mark {
    color: var(--ink);
    font-weight: 700;
}

html.app-booting .boot-screen {
    display: flex;
}

html.app-booting .login-screen,
html.app-booting .working-screen {
    display: none;
}

.login-screen {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: clamp(20px, 4vw, 64px);
}

.login-screen-container {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: 1fr;
    width: 100%;
    max-width: 1400px;
    min-height: min(720px, calc(100vh - 80px));
    overflow: hidden;
    border-radius: 24px;
    background: var(--light-paper);
    box-shadow: 0 14px 34px rgba(17, 17, 15, 0.14);
}

.login-brand {
    grid-column: 1 / 5;
    grid-row: 1;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 24px;
}

.login-copy {
    grid-column: 5 / -1;
    grid-row: 1;
    padding: clamp(70px, 10vh, 130px) clamp(24px, 6vw, 90px) 40px;
    background: transparent;
}

.login-copy h1 {
    max-width: 820px;
    font-size: clamp(52px, 6.5vw, 96px);
    font-weight: 500;
    letter-spacing: -0.075em;
    line-height: 0.91;
}

.login-fields {
    grid-column: 7 / 12;
    grid-row: 1;
    z-index: 1;
    align-self: end;
    display: grid;
    gap: 18px;
    margin: 0 0 42px;
    padding: clamp(24px, 3vw, 40px);
    border: 0;
    border-radius: 20px;
    background: var(--light-paper);
    box-shadow: 0 10px 24px rgba(210, 45, 32, 0.24);
}

label {
    display: block;
}

label > span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
}

input,
textarea {
    display: block;
    width: 100%;
    border: 1px solid var(--divider);
    border-radius: 0;
    background: var(--light-paper);
    font-size: 15px;
}

input {
    height: 44px;
    padding: 0 12px;
}

textarea {
    min-height: 120px;
    padding: 12px;
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--red);
    outline: 2px solid var(--red);
    outline-offset: -2px;
}

#loginButton,
#createMedRecordButton {
    min-height: 46px;
    padding: 12px 16px;
    border: 1px solid var(--red);
    border-radius: 12px;
    background: var(--red);
    color: var(--light-paper);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
}

#loginButton {
    border-color: var(--dark-red);
    background: var(--dark-red);
    box-shadow: 0 7px 18px color-mix(in srgb, var(--dark-red) 28%, transparent);
    transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

#loginButton:hover,
#createMedRecordButton:hover {
    border-color: var(--dark-red);
    background: var(--dark-red);
}

#loginButton:hover {
    box-shadow: 0 9px 22px color-mix(in srgb, var(--dark-red) 34%, transparent);
}

#modalOverlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    background: rgba(17, 17, 15, 0.5);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 24px;
}

.modal-content {
    position: relative;
    display: grid;
    gap: 18px;
    width: min(560px, 100%);
    padding: clamp(28px, 4vw, 48px);
    border: 1px solid var(--ink);
    background: var(--light-paper);
    box-shadow: none;
}

.modal-content h1,
.modal-content h2 {
    font-size: clamp(34px, 4vw, 52px);
    font-weight: 500;
    letter-spacing: -0.065em;
    line-height: 0.98;
}

.modal-content .record-kicker {
    margin-bottom: -6px;
}

.close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
}

.close:hover {
    color: var(--red);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.case-modal-content {
    box-shadow: 8px 8px 0 var(--red);
}

.qr-modal-content {
    width: min(520px, 100%);
}

.progress-modal-content {
    width: min(680px, 100%);
    text-align: left;
}

#progressText {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.04em;
}

#qrcode {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 8px;
    overflow: hidden;
}

#qrcode canvas,
#qrcode img {
    width: min(400px, 100%) !important;
    height: auto !important;
}

.progress-bar {
    width: 100%;
    height: 40px;
    overflow: hidden;
    border: 1px solid var(--ink);
    background: var(--soft-grey);
}

.progress-bar .progress {
    width: 0;
    height: 100%;
    background: var(--red);
    transition: width 300ms ease;
}

.progress-bar .progress.waiting {
    animation: waiting-progress 1s steps(2, end) infinite;
}

@keyframes waiting-progress {
    50% {
        background: var(--blue);
    }
}

#notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: none;
    width: min(360px, calc(100vw - 40px));
    padding: 14px 16px;
    border-left: 4px solid var(--blue);
    background: var(--ink);
    color: var(--light-paper);
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.45;
}

#notification.warning,
#notification.error {
    border-left-color: var(--red);
}

.checklist-container {
    margin-top: 24px;
}

.checklist-container h3 {
    margin: 18px 0 8px;
    font-size: 16px;
    font-weight: 500;
}

.checklist-task,
.checklist-section {
    margin-left: 12px;
}

.check-true,
.check-list-task-ok {
    color: var(--muted);
}

.check-false {
    color: var(--red);
}

@media (max-width: 1100px) {
    .panel-logo,
    .panel-left {
        grid-column: 1 / 5;
    }

    .panel-top,
    .panel-right {
        grid-column: 5 / -1;
    }

    .login-fields {
        grid-column: 6 / 12;
    }
}

@media (max-width: 820px) {
    .panel-container {
        display: block;
        padding-bottom: 30px;
    }

    .panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 68px;
    }

    .panel-logo,
    .panel-top {
        display: flex;
    }

    .panel-top {
        gap: 16px;
    }

    .panel-left {
        padding: 24px 0 38px;
    }

    .right-content {
        padding: 32px 28px 44px;
    }

    .create-med-record {
        max-width: 420px;
    }

    .empty-workspace {
        min-height: 480px;
    }

    .empty-workspace-copy {
        margin-left: 0;
    }

    .login-screen-container {
        display: block;
        min-height: auto;
    }

    .login-brand {
        padding: 22px 22px 36px;
    }

    .login-copy {
        padding: 60px 28px 110px;
    }

    .login-fields {
        width: calc(100% - 40px);
        margin: -70px auto 32px;
    }
}

@media (max-width: 560px) {
    .qr-code-icon span {
        display: none;
    }

    .panel-top {
        gap: 13px;
    }

    .record-header {
        display: block;
    }

    .record-overview {
        grid-template-columns: minmax(0, 1fr);
    }

    .record-header-actions {
        margin-top: 18px;
        justify-content: flex-start;
    }

    .patient-name {
        font-size: 42px;
    }

    .patient-description-table,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .record-add-files-zone {
        display: block;
        margin-top: 28px;
    }

    .record-add-files-zone .quick-create-hint {
        margin-top: 7px;
        text-align: left;
    }

    .login-copy {
        padding: 46px 20px 96px;
    }

    .login-copy h1 {
        font-size: 48px;
    }

    .login-fields {
        width: calc(100% - 24px);
        padding: 22px;
    }

    .modal {
        align-items: flex-start;
        padding: 16px;
    }

    .modal-content {
        margin-top: 20px;
        padding: 34px 22px 26px;
    }

    .case-modal-content {
        box-shadow: 5px 5px 0 var(--red);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
