:root {
  --ink: #172c27;
  --muted: #6b7c77;
  --line: #dfe6e2;
  --paper: #fffefb;
  --green-900: #173f36;
  --green-800: #205346;
  --green-700: #2f6b5b;
  --green-100: #e3eee9;
  --amber: #c9872b;
  --red: #b75449;
  --blue: #486b82;
  --shadow: 0 14px 40px rgba(29, 62, 53, .09);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 8% 8%, rgba(56,112,94,.08), transparent 26rem), linear-gradient(180deg,#f8f7f3,#eef1ed); font-family: "Noto Sans SC",system-ui,sans-serif; }
button,input,select { font: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.app-shell { min-height: 100vh; }

.topbar { height: 76px; display: grid; grid-template-columns: 270px minmax(280px,680px) 270px; justify-content: space-between; align-items: center; gap: 28px; padding: 0 max(28px,calc((100vw - 1460px)/2)); color: white; background: linear-gradient(110deg,#12372f,#1e4e42 56%,#183d34); box-shadow: 0 5px 20px rgba(17,50,42,.18); }
.brand-area { display: flex; align-items: center; min-width: 0; }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 12px; background: rgba(255,255,255,.09); }
.brand-mark svg { width: 25px; color: #d9e7ce; }
.brand strong { display: block; font: 700 19px/1.15 "Noto Serif SC",serif; letter-spacing: .13em; }
.brand small { display: block; opacity: .62; font-size: 8px; letter-spacing: .22em; margin-top: 4px; }
.search-wrap { position: relative; z-index: 40; display: block; width: 100%; }
.search-wrap > svg { position: absolute; left: 17px; top: 50%; width: 19px; transform: translateY(-50%); color: rgba(255,255,255,.68); }
.search-wrap input { width: 100%; height: 44px; padding: 0 75px 0 47px; color: white; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; outline: 0; background: rgba(255,255,255,.095); transition: .2s; }
.search-wrap input::placeholder { color: rgba(255,255,255,.55); }
.search-wrap input:focus { border-color: rgba(226,235,211,.7); background: rgba(255,255,255,.14); box-shadow: 0 0 0 3px rgba(255,255,255,.07); }
.search-wrap kbd { position: absolute; right: 11px; top: 50%; padding: 4px 7px; transform: translateY(-50%); color: rgba(255,255,255,.54); border: 1px solid rgba(255,255,255,.18); border-radius: 6px; font-size: 10px; }
.search-dropdown { position: absolute; top: calc(100% + 10px); left: 0; right: 0; max-height: min(420px,calc(100vh - 110px)); overflow-y: auto; padding: 7px; color: var(--ink); border: 1px solid #dce4df; border-radius: 13px; background: rgba(255,255,253,.98); box-shadow: 0 18px 48px rgba(12,42,33,.24); backdrop-filter: blur(12px); }
.search-dropdown-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 9px 9px; color: var(--muted); font-size: 10px; }
.search-dropdown-head strong { color: var(--green-700); font-weight: 600; }
.search-result-item { width: 100%; min-height: 66px; display: grid; grid-template-columns: minmax(130px,1fr) minmax(110px,170px) 88px; align-items: center; gap: 12px; padding: 9px 12px; color: var(--ink); border: 0; border-top: 1px solid #edf0ee; border-radius: 9px; text-align: left; background: transparent; transition: .14s; }
.search-result-item:hover,.search-result-item:focus-visible { outline: none; background: #eef5f1; }
.search-result-name { min-width: 0; }
.search-result-name strong { display: block; overflow: hidden; font: 700 16px/1.35 "Noto Serif SC",serif; text-overflow: ellipsis; white-space: nowrap; }
.search-result-name small { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.result-cabinet { min-width: 0; }
.result-cabinet strong { display: block; overflow: hidden; color: #3f5f52; font: 700 15px/1.35 "Noto Serif SC",serif; text-overflow: ellipsis; white-space: nowrap; }
.result-cabinet small { display: block; margin-top: 3px; color: var(--green-700); font-size: 12px; line-height: 1.2; font-weight: 700; }
.result-amount { justify-self: end; color: #ad542f; font-size: 15px; line-height: 1.4; font-weight: 700; text-align: right; white-space: nowrap; }
.search-empty { padding: 24px 12px; color: var(--muted); text-align: center; font-size: 10px; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 9px; }
.medicine-switch { height: 37px; display: inline-flex; align-items: center; padding: 0 12px; color: #edf5f0; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; background: rgba(255,255,255,.08); text-decoration: none; font-size: 11px; font-weight: 600; white-space: nowrap; transition: .16s; }
.medicine-switch:hover { color: white; background: rgba(255,255,255,.15); transform: translateY(-1px); }
.calculator-trigger { width: 37px; height: 37px; justify-self: end; display: grid; place-items: center; padding: 0; color: #dfe9d0; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; background: rgba(255,255,255,.08); transition: .16s; }
.calculator-trigger:hover { color: white; background: rgba(255,255,255,.15); transform: translateY(-1px); }
.calculator-trigger svg { width: 18px; }

main { width: min(1460px,calc(100% - 56px)); margin: 0 auto; padding: 38px 0 28px; }
.intro-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 20px; }
.eyebrow { color: var(--green-700); font-size: 10px; font-weight: 700; letter-spacing: .18em; }
h1 { margin: 5px 0 3px; font: 700 31px/1.25 "Noto Serif SC",serif; letter-spacing: .08em; }
.intro-row p { margin: 0; color: var(--muted); font-size: 12px; }
.summary-cards { display: flex; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.8); box-shadow: 0 8px 25px rgba(29,62,53,.05); }
.summary-cards article { min-width: 118px; padding: 13px 18px; border-left: 1px solid var(--line); }
.summary-cards article:first-child { border-left: 0; }
.summary-cards span { display: block; color: var(--muted); font-size: 9px; }
.summary-cards strong { margin-right: 3px; color: var(--green-800); font-size: 22px; }
.summary-cards small { color: var(--muted); font-size: 9px; }
.summary-cards .warning strong { color: var(--amber); }

.workspace-card { position: relative; overflow: visible; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.92); box-shadow: var(--shadow); }
.cabinet-tabs-wrap { min-height: 66px; display: flex; align-items: flex-end; gap: 7px; padding: 15px 20px 0; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--line); background: linear-gradient(180deg,#fbfcfa,#f5f7f5); border-radius: 18px 18px 0 0; scrollbar-width: thin; scrollbar-color: #c8d5cf transparent; }
.cabinet-tabs-wrap::-webkit-scrollbar { height: 4px; }
.cabinet-tabs-wrap::-webkit-scrollbar-thumb { border-radius: 4px; background: #c8d5cf; }
.cabinet-tabs { flex: 0 0 auto; display: flex; align-items: flex-end; gap: 7px; }
.cabinet-tab,.tab-add { height: 42px; flex: 0 0 auto; padding: 0 17px; border: 1px solid #dce3df; border-bottom: 0; border-radius: 10px 10px 0 0; color: #60706b; background: #f1f4f2; font-size: 11px; transition: .16s; }
.cabinet-tab { display: flex; align-items: center; gap: 8px; }
.cabinet-tab small { min-width: 20px; padding: 2px 6px; border-radius: 10px; color: #71817c; background: #e1e7e4; font-size: 8px; }
.cabinet-tab.active { height: 51px; color: var(--green-900); border-color: #cddad4; background: white; font-weight: 700; box-shadow: 0 -4px 13px rgba(30,75,62,.05); }
.cabinet-tab.active small { color: white; background: var(--green-700); }
.cabinet-tab { position: relative; user-select: none; -webkit-user-select: none; }
.cabinet-tab.drag-source { opacity: .25; }
.cabinet-tab.drag-before::before,.cabinet-tab.drag-after::after { content: ""; position: absolute; z-index: 8; top: 4px; bottom: 4px; width: 4px; border-radius: 4px; background: #d39a36; box-shadow: 0 0 0 3px rgba(211,154,54,.18); }
.cabinet-tab.drag-before::before { left: -6px; }
.cabinet-tab.drag-after::after { right: -6px; }
.cabinet-drag-ghost { position: fixed; z-index: 300; display: flex; align-items: center; gap: 8px; margin: 0; padding: 0 17px; pointer-events: none; opacity: .94; color: var(--green-900); border: 1px solid #cddad4; border-radius: 10px; background: white; font-size: 11px; font-weight: 700; transform: rotate(2deg) scale(1.03); box-shadow: 0 14px 32px rgba(10,31,24,.28); }
body.cabinet-dragging { cursor: grabbing; }
body.cabinet-dragging * { cursor: grabbing !important; }
.tab-add { border-style: dashed; border-bottom: 1px dashed #d2dcd7; border-radius: 9px; margin-bottom: 8px; color: var(--green-700); background: #f7faf8; }
.tab-add:hover { background: #eaf2ee; }

.cabinet-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 20px 22px 17px; }
.cabinet-title-line { display: flex; align-items: center; gap: 10px; }
.cabinet-title-line h2 { margin: 0; font: 700 20px/1.35 "Noto Serif SC",serif; }
.cabinet-toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.online-dot { padding: 3px 8px; color: #467561; border-radius: 20px; background: #e5f0e9; font-size: 9px; }
.online-dot::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: #55a477; vertical-align: 1px; }
.online-dot.offline { color: #9b6523; background: #fff1d9; }
.online-dot.offline::before { background: #d18b2a; }
.toolbar-actions { display: flex; gap: 8px; }
.ghost-btn,.secondary-btn,.primary-btn,.cancel-btn,.danger-btn { height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 9px; font-size: 11px; font-weight: 600; }
.ghost-btn { color: #5f716b; border-color: var(--line); background: #f8faf8; }
.secondary-btn { color: var(--green-800); border-color: #ccd9d4; background: white; }
.primary-btn { color: white; background: var(--green-800); box-shadow: 0 5px 12px rgba(32,83,70,.18); }
.danger-btn { color: var(--red); border-color: #efcec9; background: #fff8f7; }
.cancel-btn { color: #53635e; border-color: var(--line); background: white; }
.ghost-btn svg,.secondary-btn svg { width: 14px; margin-right: 5px; vertical-align: -3px; }
.primary-btn:hover { background: var(--green-900); }
.secondary-btn:hover,.ghost-btn:hover { background: #edf4f0; }

.layout-popover { position: absolute; z-index: 20; right: 22px; top: 130px; display: flex; align-items: flex-end; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 16px 40px rgba(25,55,47,.16); animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-5px) scale(.98); } }
.layout-popover label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; }
.stepper { height: 34px; display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; }
.stepper button { width: 28px; color: var(--green-800); border: 0; background: #f6f8f6; }
.stepper input { width: 42px; text-align: center; border: 0; outline: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { display: none; }
.multiply { align-self: center; margin-top: 17px; color: #a5afab; }
.filter-bar { margin: 0 22px 14px; padding: 8px 11px; display: flex; justify-content: space-between; color: var(--green-700); border-radius: 8px; background: #eff6f2; font-size: 10px; }
.filter-bar button { color: inherit; border: 0; background: transparent; font-weight: 700; }

.cabinet-shell { margin: 0 22px 22px; padding: 0 10px 9px; border-radius: 10px 10px 14px 14px; background: linear-gradient(135deg,#66756f,#43544e 36%,#5c6c66); box-shadow: inset 0 0 0 1px rgba(29,48,42,.5),0 8px 18px rgba(35,59,51,.16); }
.cabinet-plaque { height: 34px; display: flex; justify-content: center; align-items: center; gap: 18px; color: #e8f0ec; text-align: center; white-space: nowrap; }
.cabinet-plaque strong { flex: 0 1 auto; font: 600 clamp(8px,1vw,11px)/1 "Noto Serif SC",serif; letter-spacing: 0; text-align: center; white-space: nowrap; }
.cabinet-plaque i { width: 72px; height: 1px; flex: 0 1 72px; background: linear-gradient(90deg,transparent,rgba(235,244,239,.35)); }
.cabinet-plaque i:last-child { transform: rotate(180deg); }
.medicine-grid { min-height: 360px; padding: 10px; overflow-x: auto; overflow-y: hidden; border: 1px solid rgba(255,255,255,.08); background: #34433e; scrollbar-width: thin; scrollbar-color: rgba(218,230,224,.4) transparent; }
.medicine-grid::-webkit-scrollbar { height: 7px; }
.medicine-grid::-webkit-scrollbar-thumb { border-radius: 7px; background: rgba(218,230,224,.4); }
.medicine-row { width: max-content; min-width: 100%; display: flex; gap: 7px; align-items: stretch; margin-bottom: 8px; overflow: visible; white-space: nowrap; }
.medicine-row:last-child { margin-bottom: 0; }
.row-label { width: 72px; min-height: 103px; display: flex; justify-content: center; align-items: center; color: #e8f1ed; border: 1px solid rgba(255,255,255,.11); background: rgba(255,255,255,.06); font: 700 17px/1 "Noto Serif SC",serif; white-space: nowrap; }
.row-cells { min-width: max-content; display: flex; flex-wrap: nowrap; gap: 7px; overflow: visible; }
.medicine-cell { position: relative; width: 154px; min-height: 103px; flex: 0 0 154px; padding: 12px 12px 10px; overflow: hidden; text-align: left; color: #263631; border: 1px solid #d7dfdb; border-radius: 5px; background: linear-gradient(150deg,#fbfcfa,#edf1ee); box-shadow: inset 0 -4px 8px rgba(30,65,54,.04); transition: .15s; }
.medicine-cell:hover { z-index: 2; transform: translateY(-2px); border-color: #9eb7ab; box-shadow: 0 6px 15px rgba(18,45,36,.18); }
.medicine-cell.empty { display: grid; place-items: center; color: #8d9a95; border-style: dashed; background: rgba(239,244,241,.88); }
.medicine-cell.empty span { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 8px; }
.medicine-cell.empty b { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid #b7c3bd; border-radius: 50%; font-size: 16px; font-weight: 400; }
.medicine-cell .cell-name { display: block; padding-right: 18px; overflow-wrap: anywhere; font: 700 15px/1.35 "Noto Serif SC",serif; }
.medicine-cell .cell-spec { display: block; min-height: 15px; margin-top: 4px; overflow: hidden; color: #75847f; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.medicine-cell .cell-amount { display: block; margin-top: 13px; color: #ad542f; font-size: 13px; font-weight: 700; }
.medicine-cell .cell-index { position: absolute; right: 8px; top: 8px; color: #9aa8a2; font-size: 7px; }
.medicine-cell.expiring::after { content: "近效期"; position: absolute; right: 7px; bottom: 7px; padding: 2px 5px; color: white; border-radius: 8px; background: #bd7758; font-size: 7px; }
.medicine-cell.matched { outline: 3px solid #d8b460; outline-offset: -3px; }
.medicine-cell.dimmed { opacity: .2; filter: grayscale(.65); }
.medicine-cell[data-medicine-id] { touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.medicine-cell.drag-source { opacity: .24; }
.medicine-cell.drag-before { z-index: 4; box-shadow: inset 6px 0 #d39a36,0 7px 16px rgba(18,45,36,.2); transform: translateY(-2px); }
.medicine-cell.drag-after { z-index: 4; box-shadow: inset -6px 0 #d39a36,0 7px 16px rgba(18,45,36,.2); transform: translateY(-2px); }
.row-add { position: relative; width: 154px; min-height: 103px; flex: 0 0 154px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--green-700); border: 1px dashed #9fb5aa; border-radius: 5px; background: linear-gradient(150deg,#fbfcfa,#edf1ee); box-shadow: inset 0 -4px 8px rgba(30,65,54,.04); font-size: 14px; font-weight: 700; white-space: nowrap; transition: .15s; }
.row-add b { font-size: 23px; font-weight: 300; line-height: 1; }
.row-add:hover { color: var(--green-900); border-color: #6f9483; transform: translateY(-2px); box-shadow: 0 6px 15px rgba(18,45,36,.18); }
.row-add.drag-row-target,.row-label.drag-row-target { z-index: 4; outline: 3px solid #d8b460; outline-offset: -3px; transform: translateY(-2px); }
.row-add.drag-row-target::before,.row-label.drag-row-target::before { content: "放到本行末尾"; position: absolute; z-index: 6; inset: 0; display: grid; place-items: center; color: #fff; border-radius: 4px; background: rgba(35,75,61,.84); font-size: 12px; font-weight: 700; }
.row-label { position: relative; }
.medicine-drag-ghost { position: fixed; z-index: 300; width: 154px; min-height: 103px; margin: 0; pointer-events: none; opacity: .96; transform: none; transition: none; box-shadow: 0 16px 36px rgba(10,31,24,.34); }
body.medicine-dragging { cursor: grabbing; }
body.medicine-dragging * { cursor: grabbing !important; }
.cabinet-foot { height: 25px; display: flex; justify-content: space-between; align-items: center; padding: 0 12px; color: rgba(237,247,242,.55); font-size: 8px; letter-spacing: .08em; }
.remote-state { min-height: 330px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; color: #e6f0eb; text-align: center; }
.remote-state span { width: 24px; height: 24px; border: 2px solid rgba(255,255,255,.2); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
.remote-state small { max-width: 520px; color: #aebfb7; line-height: 1.7; }

footer { width: min(1460px,calc(100% - 56px)); margin: 0 auto; padding: 0 0 24px; display: flex; justify-content: space-between; color: #8d9a96; font-size: 9px; }
footer b { color: #5d8372; font-weight: 500; }
.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15,32,27,.55); backdrop-filter: blur(4px); }
.calculator-backdrop { z-index: 120; }
.calculator { width: min(370px,100%); overflow: hidden; color: #edf4ef; border: 1px solid rgba(255,255,255,.12); border-radius: 20px; background: linear-gradient(145deg,#173e35,#102d27); box-shadow: 0 30px 90px rgba(7,24,19,.38); animation: modalIn .2s ease-out; }
.calculator-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 21px 12px; }
.calculator-head small { display: block; margin-bottom: 2px; color: #9eb9ac; font-size: 8px; letter-spacing: .16em; }
.calculator-head h2 { margin: 0; font: 700 18px/1.3 "Noto Serif SC",serif; }
.calculator-head .close-btn { color: #c9d9d1; background: rgba(255,255,255,.08); }
.calculator-screen { min-height: 108px; margin: 0 17px 14px; padding: 20px 16px 14px; display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-end; overflow: hidden; border: 1px solid rgba(255,255,255,.08); border-radius: 13px; background: rgba(5,18,15,.32); }
.calculator-screen > span { min-height: 18px; max-width: 100%; overflow: hidden; color: #8fa99e; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.calculator-screen > span.live-result { width: 100%; display: flex; justify-content: flex-end; align-items: baseline; gap: 8px; }
.calculator-screen > span.live-result small { color: #718e82; font-size: 8px; letter-spacing: .08em; }
.calculator-screen > span.live-result b { color: #bed5c7; font-size: 15px; font-weight: 500; }
.calculator-screen strong { width: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden; color: #edf4ef; font-size: 34px; line-height: 1.2; font-weight: 500; letter-spacing: .02em; text-align: right; white-space: nowrap; scrollbar-width: none; }
.calculator-screen strong::-webkit-scrollbar { display: none; }
.calc-operator { display: inline-block; font-style: normal; font-weight: inherit; }
.calc-operator.tight { margin: 0 .04em; }
.calc-operator.wide { margin: 0 .2em; }
.calculator-keys { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; padding: 0 17px; }
.calculator-keys button { height: 52px; color: #edf4ef; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: rgba(255,255,255,.075); font-size: 16px; transition: transform .1s,background .1s; }
.calculator-keys button:hover { background: rgba(255,255,255,.13); }
.calculator-keys button:active { transform: scale(.95); }
.calculator-keys .utility { color: #cfb985; background: rgba(215,183,108,.09); }
.calculator-keys .operator { color: #d9e8d0; background: rgba(112,157,129,.18); font-size: 20px; }
.calculator-keys .equals { color: var(--green-900); background: #dfe9d0; font-size: 21px; font-weight: 700; }
.calculator-hint { margin: 13px 0 16px; color: #718e82; text-align: center; font-size: 8px; }
.modal { width: min(680px,100%); max-height: calc(100vh - 40px); overflow-y: auto; border-radius: 17px; background: var(--paper); box-shadow: 0 28px 90px rgba(8,24,20,.28); animation: modalIn .18s ease-out; }
.modal.compact { width: min(500px,100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-header { padding: 20px 23px 15px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header p { margin: 0 0 3px; color: var(--green-700); font-size: 9px; letter-spacing: .15em; }
.modal-header h2 { margin: 0; font: 700 20px/1.3 "Noto Serif SC",serif; }
.close-btn { width: 32px; height: 32px; color: #75817d; border: 0; border-radius: 8px; background: #f0f2ef; font-size: 23px; }
form { padding: 19px 23px 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field.full { grid-column: 1/-1; }
.field > span { display: block; margin-bottom: 6px; color: #52645f; font-size: 10px; font-weight: 600; }
.field em { color: var(--red); font-style: normal; }
.field input,.field select { width: 100%; height: 40px; padding: 0 11px; border: 1px solid #d9e0dc; border-radius: 8px; outline: 0; background: white; }
.field input:focus,.field select:focus { border-color: #78a08f; box-shadow: 0 0 0 3px rgba(59,112,92,.09); }
.image-field.full { grid-column: 1/-1; }
.medicine-image-list { display: flex; flex-wrap: wrap; gap: 9px; }
.image-add-tile { width: 92px; height: 92px; flex: 0 0 92px; display: grid; place-items: center; color: var(--green-700); border: 1px dashed #9fb8ac; border-radius: 9px; background: #f5f9f7; cursor: pointer; transition: .15s; }
.image-add-tile:hover { border-color: #6f9785; background: #edf5f1; }
.image-add-tile b { font-size: 34px; line-height: 1; font-weight: 300; }
.medicine-image-item { position: relative; min-width: 0; height: 92px; overflow: hidden; border: 1px solid #d9e2dd; border-radius: 9px; background: #eef3f0; }
.medicine-image-item { width: 92px; flex: 0 0 92px; }
.medicine-image-item img { width: 100%; height: 100%; display: block; object-fit: cover; cursor: zoom-in; }
.medicine-image-item button { position: absolute; right: 5px; top: 5px; width: 24px; height: 24px; display: grid; place-items: center; color: white; border: 0; border-radius: 50%; background: rgba(91,42,32,.82); font-size: 16px; line-height: 1; }
.medicine-image-item small { position: absolute; left: 5px; bottom: 5px; max-width: calc(100% - 10px); padding: 2px 5px; overflow: hidden; color: white; border-radius: 5px; background: rgba(21,50,41,.72); font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }
.image-viewer { position: fixed; z-index: 420; inset: 0; display: grid; place-items: center; padding: 34px; background: rgba(7,20,16,.88); backdrop-filter: blur(6px); }
.image-viewer img { max-width: min(1100px,100%); max-height: calc(100vh - 68px); object-fit: contain; border-radius: 8px; box-shadow: 0 24px 90px rgba(0,0,0,.45); }
.image-viewer button { position: fixed; z-index: 2; right: 22px; top: 18px; width: 42px; height: 42px; display: grid; place-items: center; color: white; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; background: rgba(255,255,255,.12); font-size: 28px; line-height: 1; }
.form-actions { display: flex; align-items: center; gap: 9px; margin-top: 21px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-actions > span { flex: 1; }
.operation-loading { position: fixed; z-index: 300; inset: 0; display: grid; place-items: center; background: rgba(14,35,29,.28); backdrop-filter: blur(2px); }
.operation-loading > div { min-width: 220px; padding: 25px 28px 23px; display: flex; flex-direction: column; align-items: center; color: var(--green-900); border: 1px solid #d5e1db; border-radius: 17px; background: #fffffc; box-shadow: 0 22px 70px rgba(9,34,26,.26); }
.operation-loading span { width: 34px; height: 34px; border: 3px solid #dfe9e4; border-top-color: var(--green-700); border-radius: 50%; animation: spin .75s linear infinite; }
.operation-loading strong { margin-top: 14px; font: 700 15px/1.4 "Noto Serif SC",serif; }
.operation-loading small { margin-top: 4px; color: #7b8984; font-size: 9px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 28px; padding: 10px 16px; transform: translate(-50%,20px); color: white; border-radius: 9px; background: #173f36; box-shadow: 0 8px 30px rgba(19,55,47,.25); font-size: 11px; opacity: 0; pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 1050px) {
  .topbar { grid-template-columns: 230px 1fr auto; }
  .intro-row { align-items: flex-start; }
}
@media (max-width: 720px) {
  .topbar { height: auto; grid-template-columns: 1fr auto; padding: 13px 18px; gap: 12px; }
  .search-wrap { grid-column: 1/-1; grid-row: 2; }
  .search-result-item { grid-template-columns: minmax(100px,1fr) minmax(90px,120px) 70px; gap: 8px; }
  .result-cabinet strong { font-size: 13px; }
  .result-amount { font-size: 13px; }
  main,footer { width: calc(100% - 28px); }
  main { padding-top: 24px; }
  .intro-row { display: block; }
  .summary-cards { margin-top: 18px; }
  .summary-cards article { min-width: 0; flex: 1; padding: 11px; }
  .cabinet-toolbar { align-items: flex-start; padding: 16px 13px; }
  .toolbar-actions { flex-direction: column; }
  .toolbar-actions button { width: 38px; padding: 0; font-size: 0; }
  .toolbar-actions button svg { margin: 0; width: 16px; }
  .cabinet-shell { margin: 0 12px 14px; padding-left: 7px; padding-right: 7px; }
  .layout-popover { right: 12px; top: 133px; width: 278px; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-actions { flex-wrap: wrap; }
  .form-actions > span { min-width: 10px; }
  footer { flex-direction: column; gap: 8px; }
}
@media (max-width: 430px) {
  h1 { font-size: 26px; }
  .intro-row p { line-height: 1.7; }
  .summary-cards strong { font-size: 19px; }
  .cabinet-tabs-wrap { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } .remote-state span,.operation-loading span { animation-duration: 1.6s; } }
