:root {
  font-family: "DM Sans", sans-serif;
  color: #27382f;
  background: #f5f7f4;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --forest: #293d33;
  --forest-dark: #203229;
  --moss: #77835d;
  --sage: #e8ede5;
  --plum: #79658f;
  --plum-dark: #5e4b72;
  --lavender: #f0ecf4;
  --ink: #26372e;
  --muted: #818a83;
  --line: #e7ebe6;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(440px, 0.9fr); background: #fff; }
.login-art { position: relative; overflow: hidden; min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; padding: 48px clamp(36px, 7vw, 104px); color: #fff; background: radial-gradient(ellipse at 86% 23%, #716080 0, transparent 35%), radial-gradient(ellipse at 12% 83%, #607253 0, transparent 38%), linear-gradient(147deg, #324b3c 0%, #23382e 60%, #1d3028 100%); }
.login-art::before, .login-art::after { position: absolute; content: ""; pointer-events: none; border: 1px solid rgb(255 255 255 / 8%); border-radius: 50%; }
.login-art::before { width: 440px; height: 440px; right: -155px; top: 28%; }
.login-art::after { width: 330px; height: 330px; right: -100px; top: 34%; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-family: Manrope, sans-serif; font-size: 15px; font-weight: 800; letter-spacing: 1.8px; text-decoration: none; }
.brand-mark { width: 31px; height: 31px; display: inline-grid; place-items: center; border-radius: 10px 10px 10px 3px; background: linear-gradient(135deg, #a5b38a 0 54%, #9a84ad 54%); color: #26382c; font-size: 25px; font-weight: 500; line-height: 1; }
.brand-dark { color: var(--forest); margin-bottom: 66px; }
.art-copy { position: relative; z-index: 1; max-width: 490px; margin-top: -50px; }
.eyebrow { color: #85916b; font-size: 10px; font-weight: 700; letter-spacing: 1.55px; }
.art-copy .eyebrow { color: #c1ccad; }
.art-copy h1 { margin: 22px 0 16px; max-width: 480px; font-family: Manrope, sans-serif; font-size: clamp(36px, 4vw, 53px); font-weight: 600; letter-spacing: -2px; line-height: 1.17; }
.art-copy p { max-width: 380px; color: #d0d9ce; font-size: 15px; line-height: 1.8; }
.art-footer { position: relative; z-index: 1; color: #d3ddce; font-size: 12px; }
.art-footer span { margin-right: 9px; color: #aaba8e; }
.login-panel { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 64px clamp(40px, 8vw, 125px); }
.login-form-wrap { width: 100%; max-width: 385px; margin: auto; }
.login-form-wrap .eyebrow { display: block; margin-bottom: 12px; }
.login-form-wrap h2 { margin: 0 0 8px; font-family: Manrope, sans-serif; font-size: 29px; letter-spacing: -.8px; }
.muted { margin: 0 0 34px; color: var(--muted); font-size: 13px; }
.login-form-wrap form { display: flex; flex-direction: column; }
.login-form-wrap label { margin: 0 0 8px; color: #3c4940; font-size: 12px; font-weight: 600; }
.login-form-wrap input { width: 100%; height: 47px; margin-bottom: 21px; padding: 0 13px; border: 1px solid #e4e9e3; border-radius: 7px; outline: 0; color: var(--ink); font-size: 13px; transition: border-color .2s, box-shadow .2s; }
.login-form-wrap input:focus, .field input:focus, .field textarea:focus { border-color: #83916f; box-shadow: 0 0 0 3px rgb(131 145 111 / 12%); }
.login-form-wrap input::placeholder, .field input::placeholder, .field textarea::placeholder { color: #a9b0aa; }
.button { min-height: 43px; padding: 0 18px; border: 0; border-radius: 6px; font-size: 12px; font-weight: 700; transition: background .2s, transform .2s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .7; cursor: wait; }
.button-primary { background: var(--forest); color: #fff; }
.button-primary:hover:not(:disabled) { background: #385243; }
.button-primary span { margin-left: 9px; font-size: 16px; }
.login-button { display: flex; align-items: center; justify-content: center; height: 47px; margin-top: 6px; }
.login-note { margin-top: 19px; color: #969e97; text-align: center; font-size: 11px; }
.form-error { min-height: 16px; color: #a84940; text-align: center; font-size: 12px; line-height: 1.6; }
.login-bottom { margin: auto auto 0; color: #98a099; font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-align: center; }
.login-bottom span { padding: 0 6px; color: #9caa85; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; z-index: 5; top: 0; bottom: 0; left: 0; display: flex; width: 244px; flex-direction: column; padding: 25px 14px 15px; background: var(--forest-dark); color: #fff; }
.sidebar-brand { gap: 10px; padding: 0 11px; color: #fff; font-size: 13px; }
.sidebar-brand .brand-mark { width: 29px; height: 29px; font-size: 22px; }
.sidebar-brand small { display: block; margin-top: 3px; color: #aab8a6; font-family: "DM Sans", sans-serif; font-size: 8px; font-weight: 600; letter-spacing: 1.4px; }
.nav-caption { margin: 38px 11px 12px; color: #9aa798; font-size: 9px; font-weight: 700; letter-spacing: 1.5px; }
#main-nav { min-height: 0; flex: 1; overflow-y: auto; scrollbar-color: #526457 transparent; scrollbar-width: thin; }
.nav-item { position: relative; display: flex; width: 100%; min-height: 38px; align-items: center; gap: 12px; margin: 2px 0; padding: 0 11px; border: 0; border-radius: 5px; background: transparent; color: #cad3c9; text-align: left; font-size: 11px; transition: background .18s, color .18s; }
.nav-item:hover { background: rgb(255 255 255 / 7%); color: #fff; }
.nav-item.active { background: linear-gradient(100deg, #3b5140 0%, #3b5140 78%, #51435f 100%); color: #fff; font-weight: 600; }
.nav-icon { display: inline-grid; width: 16px; place-items: center; color: #aebc9d; font-size: 15px; }
.nav-active-mark { position: absolute; top: 9px; right: 0; width: 2px; height: 20px; border-radius: 3px 0 0 3px; background: #c1a8d7; }
.sidebar-bottom { margin-top: 17px; }
.sidebar-tip { padding: 13px; border: 1px solid rgb(255 255 255 / 10%); border-radius: 7px; background: rgb(255 255 255 / 3%); }
.tip-icon { float: right; color: #c4b0d7; font-size: 17px; }
.sidebar-tip strong { display: block; max-width: 155px; color: #e9eee7; font-size: 10px; }
.sidebar-tip p { margin: 6px 0 0; color: #aeb9ad; font-size: 9px; line-height: 1.6; }
.logout-button { width: 100%; margin-top: 11px; padding: 11px; border: 0; background: transparent; color: #cad3c9; text-align: left; font-size: 11px; }
.logout-button span { margin-right: 8px; font-size: 15px; }
.workspace { width: calc(100% - 244px); min-height: 100vh; margin-left: 244px; }
.topbar { position: sticky; z-index: 4; top: 0; display: flex; height: 57px; align-items: center; justify-content: space-between; padding: 0 36px; border-bottom: 1px solid #eaeee9; background: rgb(255 255 255 / 94%); backdrop-filter: blur(10px); }
.breadcrumbs { color: #99a19a; font-size: 11px; }
.breadcrumbs span { margin: 0 9px; color: #c8cec8; }
.breadcrumbs strong { color: #46534a; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 9px; color: #68746a; font-size: 10px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #8d9c70; }
.avatar { display: grid; width: 27px; height: 27px; margin-left: 5px; place-items: center; border-radius: 50%; background: #e8ede5; color: #536147; font-size: 11px; font-weight: 700; }
.mobile-menu { display: none; border: 0; background: transparent; color: var(--forest); font-size: 19px; }
.page-content { width: min(1050px, 100%); min-height: calc(100vh - 100px); margin: 0 auto; padding: 36px 38px 50px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-heading h1 { margin: 7px 0 5px; color: #293b30; font-family: Manrope, sans-serif; font-size: 25px; letter-spacing: -.7px; }
.page-heading p { margin: 0; color: #89928a; font-size: 12px; }
.heading-stamp { min-width: 100px; padding-left: 16px; border-left: 1px solid #dfe5dc; color: #89927d; font-size: 8px; font-weight: 700; letter-spacing: 1.1px; line-height: 1.8; }
.heading-stamp span { display: block; color: var(--plum); font-size: 19px; }
.content-card { padding: 25px 27px 20px; border: 1px solid #e9ede8; border-radius: 8px; background: #fff; box-shadow: 0 3px 14px rgb(37 55 43 / 3%); }
.form-section-label { display: flex; align-items: center; gap: 9px; margin: 0 0 18px; color: #6f7b70; font-size: 9px; font-weight: 700; letter-spacing: 1.1px; }
.form-section-label > span { display: grid; width: 20px; height: 20px; place-items: center; border-radius: 5px; background: var(--lavender); color: var(--plum-dark); font-size: 9px; }
.section-divider { margin-top: 22px; padding-top: 20px; border-top: 1px solid #edf0ec; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 17px; }
.patient-grid { grid-template-columns: 1.15fr 1fr .8fr 1fr; }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 6px; color: #4a574d; font-size: 10px; font-weight: 600; }
.field label > span { color: #9a8063; }
.field input, .field textarea { display: block; width: 100%; border: 1px solid #e5eae4; border-radius: 5px; outline: 0; background: #fff; color: #34443a; font-size: 11px; transition: border-color .2s, box-shadow .2s; }
.field input { height: 36px; padding: 0 10px; }
.field textarea { min-height: 72px; padding: 9px 10px; resize: vertical; line-height: 1.6; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 21px; padding-top: 16px; border-top: 1px solid #edf0ec; }
.form-hint { color: #9aa19b; font-size: 9px; line-height: 1.6; }
.form-actions .button { min-width: 132px; }
.category-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 16px; }
.category-tab { padding: 8px 12px; border: 1px solid #e5eae3; border-radius: 5px; background: #fff; color: #788279; font-size: 10px; }
.category-tab.selected { border-color: #e0d6ea; background: var(--lavender); color: var(--plum-dark); font-weight: 700; }
.parameter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.note-field { margin-top: 14px; }
.saved-record-hint { display: flex; align-items: flex-start; gap: 12px; margin-top: 15px; padding: 14px 16px; border: 1px solid #e4eadd; border-radius: 7px; background: #f0f3ed; }
.saved-record-hint > span { display: grid; width: 21px; height: 21px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #e5dced; color: var(--plum-dark); font-size: 12px; }
.saved-record-hint strong { color: var(--plum-dark); font-size: 10px; }
.saved-record-hint p { margin: 4px 0 0; color: #818b7d; font-size: 10px; line-height: 1.5; }
.upload-zone { position: relative; display: flex !important; min-height: 135px; flex-direction: column; align-items: center; justify-content: center; margin: 0 !important; border: 1px dashed #cbd4c8; border-radius: 6px; background: #fafbf9; cursor: pointer; }
.upload-zone:hover { border-color: #84936e; background: #f6f8f4; }
.upload-zone .upload-icon { display: grid; width: 30px; height: 30px; margin-bottom: 9px; place-items: center; border-radius: 50%; background: #edf1e9; color: #6d7a58; font-size: 18px; }
.upload-zone strong { color: #526052; font-size: 10px; }
.upload-zone small { margin-top: 5px; color: #9aa29a; font-size: 9px; }
.upload-zone .file-name { margin-top: 5px; color: #667651; font-size: 10px; }
.upload-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.records-section { margin-top: 31px; }
.section-title-row { display: flex; align-items: end; justify-content: space-between; margin-bottom: 12px; }
.section-title-row h2 { margin: 5px 0 0; color: #34443a; font-family: Manrope, sans-serif; font-size: 17px; }
.recent-records { overflow: hidden; border: 1px solid #e9ede8; border-radius: 7px; background: #fff; }
.record-row { display: flex; min-height: 61px; align-items: center; gap: 12px; padding: 11px 15px; border-bottom: 1px solid #edf0ec; }
.record-row:last-child { border-bottom: 0; }
.record-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 7px; background: #edf1e9; color: #71805c; }
.record-row strong { color: #47544a; font-size: 11px; }
.record-row p { margin: 4px 0 0; color: #959d96; font-size: 9px; }
.record-row { flex-wrap: wrap; }
.record-row .record-actions { width: 100%; margin-left: 42px; }
.record-row .record-actions button { flex: 1; }
.record-category { margin-left: auto; padding: 5px 8px; border-radius: 4px; background: #f2f4f1; color: #7d877f; font-size: 9px; }
.record-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 5px; margin-left: auto; }
.record-actions button { padding: 6px 8px; border: 1px solid #e6ebe4; border-radius: 4px; background: #fff; color: #617052; font-size: 9px; font-weight: 600; }
.record-actions button:hover { border-color: #cbd6c3; background: #f4f7f1; }
.record-actions button.record-delete { color: #a45b50; }
.record-actions button.record-delete:hover { border-color: #ead2cd; background: #fcf4f2; }
.image-record .record-actions { flex-wrap: wrap; margin: 10px 0 0; }
.image-record .record-actions button { flex: 1; }
.image-placeholder { display: grid; height: 145px; place-items: center; background: #f1f3ef; color: #89928a; font-size: 10px; }
.record-dialog { width: min(660px, calc(100vw - 32px)); max-height: min(82vh, 800px); padding: 23px; overflow: auto; border: 1px solid #e4e9e2; border-radius: 10px; background: #fff; color: var(--ink); box-shadow: 0 20px 70px rgb(21 34 25 / 25%); }
.record-dialog::backdrop { background: rgb(25 38 29 / 54%); backdrop-filter: blur(2px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.dialog-heading h2 { margin: 5px 0 0; font-family: Manrope, sans-serif; font-size: 20px; }
.dialog-close { width: 32px; height: 32px; border: 1px solid #e6ebe4; border-radius: 50%; background: #fff; color: #617052; font-size: 21px; line-height: 1; }
.dialog-image { display: block; max-width: 100%; max-height: 340px; margin: 0 auto 17px; border-radius: 6px; object-fit: contain; }
.record-details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.detail-item { padding: 11px 12px; border: 1px solid #edf0ec; border-radius: 5px; background: #fbfcfa; }
.detail-item strong { color: #77835d; font-size: 9px; letter-spacing: .3px; text-transform: uppercase; }
.detail-item p { margin: 6px 0 0; color: #46534a; font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
.saved-record-button { width: 100%; border: 0; background: #fff; text-align: left; cursor: pointer; }
.saved-record-button:hover { background: #f8faf7; }
.saved-record-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; }
.saved-record-copy strong { overflow: hidden; color: #47544a; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.saved-record-copy > span { overflow: hidden; color: #959d96; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.parameter-identity-grid { max-width: 570px; }
.empty-state, .loading-line { padding: 18px; color: #8b948c; font-size: 10px; text-align: center; }
.retry-button { margin-top: 10px; padding: 7px 11px; border: 1px solid #dfe6dc; border-radius: 5px; background: #fff; color: #60704f; font-size: 10px; font-weight: 600; }
.retry-button:hover { background: #f1f5ee; }
.image-record-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 13px; }
.image-record { overflow: hidden; border: 1px solid #e9ede8; border-radius: 6px; }
.image-record img { display: block; width: 100%; height: 145px; object-fit: cover; background: #f1f3ef; }
.image-record > div { padding: 10px; }
.image-record .eyebrow { font-size: 8px; }
.image-record p { margin: 6px 0 0; color: #67736a; font-size: 10px; line-height: 1.6; }
.app-footer { padding: 13px 38px; border-top: 1px solid #e9ede8; color: #9aa29b; font-size: 9px; letter-spacing: .4px; }
.app-footer span { color: #9aa886; }
.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px)); padding: 13px 17px; border: 1px solid #dce5d8; border-radius: 7px; background: #fff; box-shadow: 0 8px 30px rgb(34 49 37 / 13%); color: #475942; font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.toast-error { border-color: #ecd8d2; color: #934d40; }
.spinner { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border: 2px solid rgb(255 255 255 / 40%); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 920px) {
  .login-screen { grid-template-columns: .85fr 1fr; }
  .login-art { padding: 36px; }
  .login-panel { padding: 45px; }
  .sidebar { width: 218px; }
  .workspace { width: calc(100% - 218px); margin-left: 218px; }
  .page-content { padding-right: 25px; padding-left: 25px; }
  .patient-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .login-screen { display: block; }
  .login-art { min-height: 265px; padding: 25px 27px; }
  .art-copy { margin: 35px 0 0; }
  .art-copy h1 { max-width: 380px; margin: 12px 0 7px; font-size: 29px; letter-spacing: -1px; }
  .art-copy p { margin: 0; font-size: 12px; }
  .art-footer { display: none; }
  .login-panel { min-height: calc(100vh - 265px); padding: 33px 28px 20px; }
  .brand-dark { margin-bottom: 36px; }
  .login-bottom { margin-top: 24px; }
  .sidebar { width: 250px; transform: translateX(-100%); transition: transform .22s; box-shadow: 8px 0 20px rgb(0 0 0 / 10%); }
  .sidebar.sidebar-open { transform: translateX(0); }
  .workspace { width: 100%; margin-left: 0; }
  .topbar { height: 53px; padding: 0 15px; }
  .mobile-menu { display: block; }
  .topbar-user { gap: 6px; font-size: 9px; }
  .breadcrumbs { display: none; }
  .page-content { min-height: calc(100vh - 93px); padding: 26px 15px 34px; }
  .page-heading h1 { font-size: 22px; }
  .page-heading p { max-width: 280px; font-size: 11px; line-height: 1.6; }
  .heading-stamp { min-width: auto; padding-left: 11px; font-size: 7px; }
  .content-card { padding: 19px 15px 15px; }
  .patient-grid, .field-grid, .parameter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .patient-grid .field:first-child { grid-column: 1 / -1; }
  .parameter-grid .field { grid-column: auto; }
  .form-actions { align-items: flex-start; flex-direction: column; }
  .form-actions .button { width: 100%; }
  .image-record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .image-record img { height: 120px; }
  .image-placeholder { height: 120px; }
  .record-details-grid { grid-template-columns: 1fr; }
  .record-dialog { padding: 17px; }
  .app-footer { padding-right: 15px; padding-left: 15px; }
}
@media (max-width: 390px) {
  .patient-grid, .field-grid, .parameter-grid { grid-template-columns: 1fr; }
  .field-wide, .patient-grid .field:first-child { grid-column: auto; }
  .image-record-grid { grid-template-columns: 1fr; }
}
