@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&display=swap');

:root {
    --navy: #0b2440;
    --navy-soft: #153b5d;
    --teal: #0f9f91;
    --teal-dark: #087d73;
    --sky: #eaf7f5;
    --ink: #172334;
    --muted: #687789;
    --line: #dfe7ed;
    --surface: #ffffff;
    --background: #f3f7f9;
    --shadow: 0 16px 45px rgba(16, 43, 65, .10);
}

* { box-sizing: border-box; }

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

body {
    font-family: "Noto Sans Thai", Tahoma, sans-serif;
    color: var(--ink);
    background: var(--background);
}

.topbar {
    height: 76px;
    padding: 0 clamp(22px, 4vw, 64px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
    width: 42px; height: 42px; display: grid; place-items: center;
    color: #fff; background: var(--teal); border-radius: 13px;
    font-size: 24px; font-weight: 700; box-shadow: 0 8px 18px rgba(15,159,145,.22);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; line-height: 1.25; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 11px; letter-spacing: .04em; }

.display-link {
    color: var(--navy); text-decoration: none; font-size: 14px;
    padding: 10px 15px; border: 1px solid var(--line); border-radius: 10px;
    font-weight: 600; transition: .2s ease;
}
.display-link:hover { border-color: var(--teal); color: var(--teal-dark); background: var(--sky); }

.control-shell { width: min(1180px, calc(100% - 36px)); margin: 38px auto 52px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.eyebrow { color: var(--teal-dark); font-weight: 700; font-size: 13px; }
.page-heading h1 { margin: 5px 0 4px; color: var(--navy); font-size: clamp(28px, 4vw, 40px); line-height: 1.2; }
.page-heading p { margin: 0; color: var(--muted); }
.live-chip {
    display: flex; align-items: center; gap: 8px; padding: 9px 13px;
    color: #15715c; background: #e8f8f3; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.live-chip span { width: 8px; height: 8px; border-radius: 50%; background: #20b786; box-shadow: 0 0 0 4px rgba(32,183,134,.13); }

.save-message {
    display: block; margin-bottom: 18px; padding: 13px 17px; border-radius: 12px;
    color: #126548; background: #e9f8f1; border: 1px solid #c7eadb; font-weight: 600;
}

.editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.editor-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
    padding: 24px; box-shadow: 0 5px 20px rgba(16,43,65,.04);
}
.card-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.room-badge {
    width: 48px; height: 48px; display: grid; place-items: center;
    color: var(--teal-dark); background: var(--sky); border-radius: 14px;
    font-size: 21px; font-weight: 800;
}
.card-heading small { color: var(--muted); font-size: 11px; }
.card-heading h2 { margin: 1px 0 0; color: var(--navy); font-size: 20px; }
.field-label { display: block; margin: 14px 0 7px; color: #425265; font-size: 13px; font-weight: 600; }
.text-input, .select-input {
    width: 100%; min-height: 45px; padding: 10px 13px; color: var(--ink);
    background: #fbfcfd; border: 1px solid #cedae2; border-radius: 10px;
    font: inherit; font-size: 14px; outline: none; transition: .2s ease;
}
.text-input:focus, .select-input:focus {
    border-color: var(--teal); background: #fff; box-shadow: 0 0 0 4px rgba(15,159,145,.1);
}
.action-bar {
    position: sticky; bottom: 18px; z-index: 5; margin-top: 22px; padding: 16px 18px 16px 22px;
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    color: #fff; background: rgba(11,36,64,.96); border-radius: 16px; box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}
.action-bar strong, .action-bar span { display: block; }
.action-bar strong { font-size: 14px; }
.action-bar span { margin-top: 2px; color: #b9cad9; font-size: 12px; }
.save-button {
    min-height: 45px; padding: 10px 21px; border: 0; border-radius: 11px;
    color: #fff; background: var(--teal); font: inherit; font-weight: 700; cursor: pointer;
    box-shadow: 0 8px 20px rgba(15,159,145,.26); transition: .2s ease;
}
.save-button:hover { background: #11aa9b; transform: translateY(-1px); }

.narrow-shell { width: min(920px, calc(100% - 36px)); }
.room-shortcuts {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 22px;
}
.room-shortcuts a {
    padding: 12px; color: var(--teal-dark); background: var(--surface);
    border: 1px solid var(--line); border-radius: 11px; text-align: center;
    text-decoration: none; font-weight: 700;
}
.room-editor {
    margin-bottom: 22px; padding: 24px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 18px;
    box-shadow: 0 5px 20px rgba(16,43,65,.04);
}
.room-editor-head {
    display: flex; align-items: center; justify-content: space-between; gap: 18px;
    padding-bottom: 18px; margin-bottom: 16px; border-bottom: 1px solid var(--line);
}
.room-name-input {
    display: block; width: 180px; margin-top: 4px; padding: 5px 9px;
    color: var(--navy); background: #f6fafb; border: 1px solid #d3e0e6;
    border-radius: 9px; font: inherit; font-size: 24px; font-weight: 800;
}
.entry-list { display: grid; gap: 13px; }
.patient-entry {
    padding: 17px; background: #f8fbfc; border: 1px solid #dfe8ed; border-radius: 14px;
}
.entry-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.entry-title strong { color: var(--navy); }
.remove-entry {
    padding: 5px 10px; color: #b53d47; background: #fff0f1; border: 0;
    border-radius: 8px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.entry-fields { display: grid; grid-template-columns: 1fr 1.5fr .8fr; gap: 12px; align-items: end; }
.entry-fields label { color: #425265; font-size: 12px; font-weight: 600; }
.entry-fields .text-input, .entry-fields .select-input { display: block; margin-top: 6px; }
.add-entry {
    width: 100%; margin-top: 14px; padding: 12px; color: var(--teal-dark);
    background: var(--sky); border: 1px dashed #73c2bb; border-radius: 11px;
    font: inherit; font-weight: 700; cursor: pointer;
}
.add-entry:hover { background: #dcf3f0; }

.display-body {
    min-height: 100vh; color: #fff;
    background:
        radial-gradient(circle at 90% 0%, rgba(20, 151, 141, .25), transparent 32%),
        radial-gradient(circle at 0% 100%, rgba(35, 112, 171, .18), transparent 28%),
        #071a2c;
    overflow-x: hidden;
}
.display-shell {
    min-height: 100vh; padding: clamp(20px, 2.5vw, 38px) clamp(22px, 3.4vw, 56px) 24px;
    display: grid; grid-template-rows: auto 1fr auto; gap: clamp(20px, 2.5vw, 34px);
}
.display-header { display: flex; align-items: center; justify-content: space-between; }
.brand-light .brand-mark { width: 52px; height: 52px; border-radius: 15px; font-size: 29px; }
.brand-light strong { font-size: clamp(20px, 2.2vw, 31px); }
.brand-light small { color: #a9becf; font-size: clamp(11px, 1vw, 14px); }
.display-clock { text-align: right; }
.display-clock span, .display-clock strong { display: block; }
.display-clock span { color: #abc0d0; font-size: clamp(12px, 1.2vw, 16px); }
.display-clock strong { margin-top: 1px; font-size: clamp(25px, 3vw, 42px); line-height: 1.15; }

.room-grid { min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(15px, 2vw, 26px); }
.room-card {
    position: relative; min-height: 250px; padding: clamp(20px, 2vw, 30px);
    display: flex; flex-direction: column; gap: 15px;
    color: var(--ink); background: rgba(255,255,255,.98); border: 1px solid rgba(255,255,255,.28);
    border-radius: clamp(17px, 2vw, 26px); box-shadow: 0 18px 50px rgba(0,0,0,.18); overflow: hidden;
}
.patient-count {
    padding: 7px 11px; color: #316b72; background: #e6f5f3;
    border-radius: 999px; font-size: 12px; font-weight: 700;
}
.display-entry-list { display: grid; gap: 10px; overflow: auto; padding-right: 3px; }
.display-entry {
    position: relative; display: grid; grid-template-columns: .8fr 1.2fr auto;
    gap: 14px; align-items: center; padding: 13px 14px 13px 18px;
    background: #f5f9fa; border: 1px solid #e1e9ed; border-radius: 13px; overflow: hidden;
}
.display-entry::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: #96a3ae; }
.display-entry.waiting::before { background: #e0a02b; }
.display-entry.preparing::before { background: #3d86d4; }
.display-entry.progress::before { background: #8a5bd7; }
.display-entry.done::before { background: #24a778; }
.display-entry-main span, .display-entry-task span { display: block; color: var(--muted); font-size: 10px; font-weight: 600; }
.display-entry-main strong, .display-entry-task strong { display: block; margin-top: 2px; line-height: 1.25; }
.display-entry-main strong { color: var(--navy); font-size: clamp(15px, 1.45vw, 22px); }
.display-entry-task strong { color: var(--teal-dark); font-size: clamp(14px, 1.25vw, 19px); }
.empty-room { padding: 30px; color: var(--muted); background: #f6f9fa; border-radius: 13px; text-align: center; }
.room-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 7px; background: #96a3ae; }
.room-card.waiting::before { background: #e0a02b; }
.room-card.preparing::before { background: #3d86d4; }
.room-card.progress::before { background: #8a5bd7; }
.room-card.done::before { background: #24a778; }
.room-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.room-card-top small { color: var(--muted); font-size: clamp(11px, 1vw, 14px); }
.room-card-top h2 { margin: 2px 0 0; color: var(--navy); font-size: clamp(27px, 3vw, 44px); line-height: 1.1; }
.status-pill {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
    color: #5e6871; background: #eef2f4; border-radius: 999px; white-space: nowrap;
    font-size: clamp(11px, 1vw, 14px); font-weight: 700;
}
.status-pill i { width: 9px; height: 9px; border-radius: 50%; background: #96a3ae; }
.waiting .status-pill { color: #94600b; background: #fff3d8; }
.waiting .status-pill i { background: #e0a02b; }
.preparing .status-pill { color: #2565a7; background: #e8f2fd; }
.preparing .status-pill i { background: #3d86d4; }
.progress .status-pill { color: #6840aa; background: #f0eafd; }
.progress .status-pill i { background: #8a5bd7; }
.done .status-pill { color: #187b57; background: #e4f6ef; }
.done .status-pill i { background: #24a778; }
.patient-block { align-self: center; }
.patient-block span, .task-block span { display: block; color: var(--muted); font-size: clamp(11px, 1vw, 14px); font-weight: 600; }
.patient-block strong { display: block; margin-top: 4px; color: var(--navy); font-size: clamp(24px, 2.8vw, 42px); line-height: 1.25; }
.task-block { padding: 15px 18px; background: #f0f7f7; border-radius: 14px; }
.task-block strong { display: block; margin-top: 3px; color: var(--teal-dark); font-size: clamp(17px, 1.8vw, 27px); line-height: 1.35; }
.display-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; color: #9fb4c5; font-size: clamp(10px, .9vw, 13px); }
.legend { display: flex; flex-wrap: wrap; gap: 15px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.waiting { background: #e0a02b; }
.dot.preparing { background: #3d86d4; }
.dot.progress { background: #8a5bd7; }
.dot.done { background: #24a778; }

.lookup-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 90% 0%, rgba(15, 159, 145, .16), transparent 34%),
        linear-gradient(160deg, #eef8f7 0%, #f5f8fb 52%, #e9f1f7 100%);
}
.lookup-shell {
    width: min(760px, calc(100% - 28px)); min-height: 100vh; margin: 0 auto;
    padding: clamp(18px, 4vw, 42px) 0 24px;
    display: flex; flex-direction: column; justify-content: center;
}
.lookup-header { margin-bottom: 18px; }
.lookup-header .brand { justify-content: center; text-align: left; }
.lookup-header .brand strong { color: var(--navy); font-size: clamp(18px, 3vw, 24px); }
.lookup-header .brand small { font-size: 12px; }
.lookup-card {
    padding: clamp(24px, 5vw, 48px); background: rgba(255,255,255,.97);
    border: 1px solid rgba(210,225,232,.9); border-radius: 26px;
    box-shadow: 0 24px 70px rgba(16,43,65,.13);
}
.lookup-intro { text-align: center; }
.lookup-icon {
    width: 58px; height: 58px; margin: 0 auto 13px; display: grid; place-items: center;
    color: #fff; background: var(--teal); border-radius: 18px; font-size: 38px;
    line-height: 1; box-shadow: 0 10px 24px rgba(15,159,145,.24);
}
.lookup-intro h1 { margin: 5px 0 8px; color: var(--navy); font-size: clamp(28px, 6vw, 42px); }
.lookup-intro p { max-width: 540px; margin: 0 auto; color: var(--muted); line-height: 1.7; }
.lookup-form { margin-top: 28px; }
.lookup-form > label { display: block; margin-bottom: 8px; color: #405267; font-size: 14px; font-weight: 700; }
.lookup-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.lookup-input {
    width: 100%; min-width: 0; min-height: 54px; padding: 12px 16px;
    color: var(--ink); background: #fbfdfe; border: 1px solid #cbd9e2;
    border-radius: 13px; font: inherit; font-size: 16px; outline: none;
}
.lookup-input:focus { background: #fff; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(15,159,145,.11); }
.lookup-button {
    min-height: 54px; padding: 12px 23px; color: #fff; background: var(--teal);
    border: 0; border-radius: 13px; font: inherit; font-weight: 800; cursor: pointer;
    box-shadow: 0 9px 21px rgba(15,159,145,.23);
}
.lookup-button:hover { background: var(--teal-dark); }
.lookup-message { margin-top: 18px; padding: 15px 17px; border-radius: 12px; text-align: center; font-weight: 650; }
.lookup-message.not-found { color: #9a3e46; background: #fff0f1; border: 1px solid #f1cfd2; }
.lookup-message.warning { color: #8a610d; background: #fff7df; border: 1px solid #efdda9; }
.lookup-result {
    position: relative; margin-top: 22px; padding: 22px; background: #f7fafb;
    border: 1px solid #dce6eb; border-radius: 17px; overflow: hidden;
}
.lookup-result::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: #96a3ae; }
.lookup-result.waiting::before { background: #e0a02b; }
.lookup-result.preparing::before { background: #3d86d4; }
.lookup-result.progress::before { background: #8a5bd7; }
.lookup-result.done::before { background: #24a778; }
.result-found { color: #188261; font-size: 13px; font-weight: 800; }
.lookup-result h2 { margin: 5px 0 17px; color: var(--navy); font-size: clamp(23px, 5vw, 32px); }
.result-grid { display: grid; grid-template-columns: .7fr 1.3fr; gap: 12px; }
.result-grid > div, .result-status { padding: 14px; background: #fff; border: 1px solid #e0e9ed; border-radius: 12px; }
.result-grid span, .result-status > span { display: block; color: var(--muted); font-size: 11px; font-weight: 650; }
.result-grid strong { display: block; margin-top: 3px; color: var(--navy); font-size: 17px; line-height: 1.35; }
.result-status { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.result-status strong { display: inline-flex; align-items: center; gap: 8px; color: #596875; }
.result-status i { width: 10px; height: 10px; background: #96a3ae; border-radius: 50%; }
.waiting .result-status strong { color: #94600b; }
.waiting .result-status i { background: #e0a02b; }
.preparing .result-status strong { color: #2565a7; }
.preparing .result-status i { background: #3d86d4; }
.progress .result-status strong { color: #6840aa; }
.progress .result-status i { background: #8a5bd7; }
.done .result-status strong { color: #187b57; }
.done .result-status i { background: #24a778; }
.lookup-result > small { display: block; margin-top: 11px; color: var(--muted); text-align: right; }
.privacy-note {
    margin-top: 22px; padding: 14px 16px; display: flex; align-items: flex-start; gap: 11px;
    color: #587083; background: #eef6f8; border-radius: 12px; font-size: 12px;
}
.privacy-note p { margin: 0; line-height: 1.55; }
.privacy-note strong { color: #36596b; }
.lookup-footer { padding: 18px 12px 0; color: #758899; text-align: center; font-size: 12px; }

@media (max-width: 760px) {
    .editor-grid, .room-grid { grid-template-columns: 1fr; }
    .page-heading { align-items: flex-start; gap: 16px; flex-direction: column; }
    .action-bar { align-items: stretch; flex-direction: column; }
    .save-button { width: 100%; }
    .display-header { align-items: flex-start; }
    .display-clock span { max-width: 150px; }
    .display-footer { align-items: flex-start; flex-direction: column; }
    .room-shortcuts { grid-template-columns: repeat(2, 1fr); }
    .entry-fields { grid-template-columns: 1fr; }
    .room-editor-head { align-items: flex-start; flex-direction: column; }
    .display-entry { grid-template-columns: 1fr; }
    .lookup-shell { justify-content: flex-start; }
    .lookup-row, .result-grid { grid-template-columns: 1fr; }
    .lookup-button { width: 100%; }
    .result-status { align-items: flex-start; flex-direction: column; }
}
