* {
    box-sizing: border-box
}

html, body {
    margin: 0;
    width: 100%;
    min-height: 100%;
    font-family: Arial,Roboto,"Segoe UI",sans-serif
}

body {
    background: #edf3fb;
    color: #101a38
}

.board-screen {
    height: 100dvh;
    min-height: 650px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(155deg,#f9fbff 0%,#e9f0fb 100%);
    overflow: hidden
}

.board-header {
    height: clamp(77px,8.3vh,96px);
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: clamp(235px,23vw,385px) minmax(0,1fr) clamp(225px,20vw,340px);
    align-items: stretch;
    background: #142f80;
    color: #fff;
    border-bottom: 4px solid #efbd30;
    box-shadow: 0 3px 12px #072c6533
}

.hospital-identity {
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8px 15px
}

    .hospital-identity:after {
        content: "";
        position: absolute;
        right: -18px;
        top: 0;
        bottom: 0;
        width: 30px;
        background: #fff;
        transform: skewX(-18deg);
        z-index: 1;
        border-right: 5px solid #e7b32c
    }

.hospital-logo {
    display: block;
    width: min(94%,290px);
    height: 61px;
    object-fit: contain
}

.board-title {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: clamp(23px,2.45vw,48px);
    line-height: 1.08;
    letter-spacing: .02em;
    font-weight: 900;
    padding: 0 22px 0 38px;
    white-space: nowrap
}

.board-clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-left: 1px solid #ffffff5c;
    gap: 4px;
    padding: 0 8px
}

.clock-date {
    font-size: clamp(14px,1.16vw,23px);
    font-weight: 600;
    text-transform: capitalize
}

.clock-time {
    font-size: clamp(23px,2vw,38px);
    font-weight: 800;
    font-variant-numeric: tabular-nums
}

.fixed-zone {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(0,1fr);
    gap: clamp(12px,1vw,22px);
    padding: clamp(12px,1.4vh,20px) clamp(12px,1vw,22px)
}

.customer-panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px 8px 7px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 5px 20px #15316c22;
    border: 1px solid #c9d5e7;
    overflow: hidden
}

.customer-table-head, .customer-row {
    display: grid;
    grid-template-columns: clamp(69px,6.6vw,128px) minmax(0,1.7fr) minmax(105px,.87fr) minmax(90px,.73fr);
    align-items: center;
    gap: 6px
}

.customer-table-head {
    flex: 0 0 clamp(42px,5.1vh,62px);
    background: #12327e;
    color: #fff;
    border-radius: 11px;
    font-size: clamp(13px,1.28vw,24px);
    font-weight: 800;
    text-align: center
}

    .customer-table-head span:nth-child(2) {
        text-align: left;
        padding-left: 4px
    }

.customer-row {
    min-height: 0;
    flex: 1;
    border-bottom: 1px solid #dde4ef;
    padding: 0 5px;
    font-size: clamp(13px,1.32vw,26px)
}

    .customer-row:nth-child(even) {
        background: #f0f5fd
    }

    .customer-row:last-child {
        border-bottom: 0
    }

.number-wrap {
    text-align: center
}

.number-badge, .ticker-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f9c828;
    color: #111f40;
    border-radius: 10px;
    font-weight: 900;
    font-variant-numeric: tabular-nums
}

.number-badge {
    width: clamp(52px,5vw,97px);
    height: clamp(30px,3.7vh,50px);
    font-size: clamp(17px,1.7vw,32px)
}

.customer-name {
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #101e49
}

.birth-date {
    white-space: nowrap;
    font-variant-numeric: tabular-nums
}

.gender {
    text-align: center
}

.gender-pill {
    display: inline-block;
    border-radius: 100px;
    min-width: 70px;
    padding: 3px 8px;
    white-space: nowrap;
    font-weight: 700
}

    .gender-pill.male {
        background: #e2eefd;
        color: #1359b0
    }

    .gender-pill.female {
        background: #fce4ef;
        color: #ba2f6f
    }

.ticker-zone {
    display: flex;
    align-items: stretch;
    flex: 0 0 clamp(88px,12vh,138px);
    padding: 8px 12px 12px;
    gap: 0
}

.ticker-heading {
    width: clamp(185px,17vw,330px);
    flex: none;
    border-radius: 14px 0 0 14px;
    background: #153682;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12px 22px;
    gap: 5px;
    font-size: clamp(17px,1.6vw,29px);
    font-weight: 900;
    position: relative;
    z-index: 1;
    white-space: nowrap
}

    .ticker-heading:after {
        content: "";
        position: absolute;
        right: -22px;
        top: 0;
        bottom: 0;
        width: 34px;
        background: #153682;
        transform: skewX(18deg);
        border-right: 8px solid #f9c828;
        z-index: -1
    }

    .ticker-heading small {
        font-size: .76em;
        color: #ffd34e
    }

.ticker-viewport {
    position: relative;
    min-width: 0;
    flex: 1;
    background: #fff;
    border: 1px solid #ccd7e9;
    border-radius: 0 14px 14px 0;
    box-shadow: 0 4px 15px #15316c22;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 0 0 0 20px
}

.ticker-track {
    display: flex;
    width: max-content;
    flex: none;
    will-change: transform;
    animation: marquee var(--ticker-duration,90s) linear infinite
}

.ticker-items {
    display: flex;
    align-items: center;
    width: max-content;
    flex: none
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    white-space: nowrap;
    border-right: 2px solid #c5d0e1;
    font-weight: 800;
    font-size: clamp(16px,1.4vw,27px);
    color: #172850
}

.ticker-number {
    padding: 8px 13px;
    font-size: 1em
}

.ticker-empty {
    margin-left: 28px;
    color: #5f708a
}

@keyframes marquee {
    from {
        transform: translateX(0)
    }

    to {
        transform: translateX(-50%)
    }
}

@media(max-width:1150px) {
    .board-header {
        grid-template-columns: 230px minmax(0,1fr) 200px
    }

    .board-title {
        font-size: 24px
    }

    .customer-row {
        font-size: 14px
    }

    .customer-table-head, .customer-row {
        grid-template-columns: 70px minmax(0,1.5fr) 104px 91px
    }

    .ticker-heading {
        width: 185px;
        font-size: 16px
    }

    .ticker-item {
        font-size: 16px;
        padding: 0 15px
    }
}

@media(max-height:720px) {
    .board-header {
        height: 69px
    }

    .hospital-logo {
        height: 48px
    }

    .fixed-zone {
        padding-block: 9px
    }

    .customer-panel {
        padding: 5px
    }

    .customer-table-head {
        flex-basis: 35px
    }

    .number-badge {
        height: 27px
    }

    .ticker-zone {
        flex-basis: 80px
    }

    .board-title {
        font-size: clamp(21px,2.2vw,36px)
    }
}

@media(prefers-reduced-motion:reduce) {
    .ticker-track {
        animation-duration: var(--ticker-duration,90s)
    }
}

.customer-placeholder {
    opacity: .25
}

/* V4: thu nhỏ chữ riêng vùng KHÁCH TIẾP THEO; bảng 01–20 không đổi */
.ticker-heading {
    font-size: clamp(15px, 1.25vw, 23px);
}

    .ticker-heading small {
        font-size: .72em;
    }

.ticker-item {
    font-size: clamp(14px, 1.12vw, 21px);
    gap: 9px;
    padding: 0 18px;
}

.ticker-number {
    padding: 6px 10px;
    font-size: .95em;
}

@media (max-width: 1150px) {
    .ticker-heading {
        font-size: 15px;
    }

    .ticker-item {
        font-size: 14px;
        padding: 0 12px;
    }
}

/* V9 Multi-panel: màu cấu hình theo từng PanelID, style classic giữ nguyên V8. */
.board-header {
    background: var(--panel-header, #142f80);
    border-bottom-color: var(--panel-accent, #efbd30);
}

.hospital-identity:after {
    border-right-color: var(--panel-accent, #efbd30);
}

.number-badge, .ticker-number {
    background: var(--panel-accent, #f9c828);
}

.board-theme-dark {
    background: #111827;
    color: #edf3ff;
}

    .board-theme-dark .customer-panel {
        background: #202d42;
        border-color: #42526b;
    }

    .board-theme-dark .customer-row {
        color: #eef3fc;
        border-color: #3e5067;
    }

        .board-theme-dark .customer-row:nth-child(even) {
            background: #29374d;
        }

    .board-theme-dark .customer-name, .board-theme-dark .birth-date {
        color: #f2f6ff;
    }

    .board-theme-dark .ticker-viewport {
        background: #202d42;
        border-color: #42526b;
    }

    .board-theme-dark .ticker-item {
        color: #f2f6ff;
        border-right-color: #42526b;
    }

    .board-theme-dark .customer-table-head, .board-theme-dark .ticker-heading, .board-theme-dark .ticker-heading:after {
        background: var(--panel-header, #142f80);
    }

.board-unavailable {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #f4f7fb;
    color: #203459;
    font: bold 24px Arial,sans-serif;
    padding: 30px;
    text-align: center;
}

/* V10: phòng khám (2 hoặc 4 ô); rotate2/rotate4 chuyển nhóm mỗi 30s */
.room-grid {
    min-height: 0;
    flex: 1;
    display: grid;
    gap: 14px;
    padding: 14px;
    overflow: hidden
}

.room-grid-two {
    grid-template-columns: repeat(2,minmax(0,1fr));
    grid-template-rows: minmax(0,1fr)
}

.room-grid-four {
    grid-template-columns: repeat(2,minmax(0,1fr));
    grid-template-rows: repeat(2,minmax(0,1fr))
}

.room-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: #fff;
    border: 1px solid #cad5e9;
    border-radius: 15px;
    box-shadow: 0 4px 15px #15316c19
}

.room-card-title {
    background: var(--panel-header,#142f80);
    color: #fff;
    padding: 10px 16px;
    font-size: clamp(19px,1.7vw,32px);
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px
}

    .room-card-title small {
        font-size: .7em;
        color: var(--panel-accent,#efbd30)
    }

.room-table-head, .room-row {
    display: grid;
    grid-template-columns: clamp(60px,5.8vw,100px) minmax(0,1fr) clamp(95px,9vw,160px);
    align-items: center;
    gap: 8px;
    padding: 0 14px
}

.room-table-head {
    background: #e9effa;
    color: #254175;
    font-weight: 800;
    min-height: 35px
}

.room-row {
    min-height: 0;
    flex: 1;
    border-bottom: 1px solid #e4eaf2;
    font-size: clamp(16px,1.3vw,24px)
}

    .room-row:nth-child(even) {
        background: #f2f6fc
    }

.room-stt {
    display: inline-flex;
    background: var(--panel-accent,#efbd30);
    padding: 5px 9px;
    border-radius: 8px;
    justify-content: center;
    width: max-content;
    min-width: 48px
}

.room-customer-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.room-empty {
    padding: 24px;
    text-align: center;
    color: #6d7e99;
    font-size: 20px
}

.room-footer {
    text-align: center;
    padding: 4px 12px 12px;
    color: #506482;
    font-size: 16px
}

.board-theme-dark .room-card {
    background: #202d42;
    color: #f2f6ff;
    border-color: #42526b
}

.board-theme-dark .room-table-head {
    background: #29374d;
    color: #edf3ff
}

.board-theme-dark .room-row {
    border-color: #42526b
}

    .board-theme-dark .room-row:nth-child(even) {
        background: #29374d
    }

@media(max-width:900px) {
    .room-grid {
        gap: 8px;
        padding: 8px
    }

    .room-row {
        font-size: 14px;
        padding: 0 6px
    }

    .room-table-head {
        padding: 0 6px
    }

    .room-card-title {
        font-size: 18px
    }
}

/* V13: single-room full-area layout */
.room-grid-one {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}

/* V13.2: 2/4 phòng: mỗi phòng sử dụng bảng 2 cột x 10 khách như giao diện 1 phòng.
   Banner giữ nguyên; các chế độ nhiều phòng không có ticker 21+. */
.board-room-layout {
    gap: clamp(8px, 1vw, 16px);
    padding: clamp(8px, 1vh, 14px);
}

.board-room-card {
    min-height: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.board-room-heading {
    flex: 0 0 auto;
    min-height: clamp(37px, 4.3vh, 54px);
    padding: 4px 14px;
    font-size: clamp(16px, 1.35vw, 27px);
}

.room-customer-columns {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: clamp(5px,.55vw,12px);
    padding: 6px 0 0;
}

.room-customer-panel {
    min-width: 0;
    min-height: 0;
    border-radius: 12px;
    padding: 5px;
}

    .room-customer-panel .customer-table-head,
    .room-customer-panel .customer-row {
        grid-template-columns: clamp(40px,4vw,75px) minmax(0,1.5fr) minmax(76px,.95fr) minmax(62px,.75fr);
        gap: 3px;
    }

    .room-customer-panel .customer-table-head {
        flex-basis: clamp(29px,3.6vh,44px);
        font-size: clamp(10px,.86vw,16px);
    }

    .room-customer-panel .customer-row {
        font-size: clamp(11px,.93vw,18px);
    }

    .room-customer-panel .number-badge {
        width: clamp(34px,3vw,62px);
        height: clamp(23px,2.8vh,36px);
        font-size: clamp(12px,1.13vw,22px);
    }

    .room-customer-panel .gender-pill {
        min-width: 0;
        padding: 2px 4px;
    }

.room-grid-four .board-room-heading {
    min-height: clamp(30px,3.5vh,42px);
    font-size: clamp(15px,1.1vw,22px);
}

.room-grid-four .room-customer-columns {
    padding-top: 4px;
    gap: 6px;
}

.room-grid-four .room-customer-panel .customer-table-head {
    flex-basis: 28px;
    font-size: clamp(9px,.72vw,14px);
}

.room-grid-four .room-customer-panel .customer-row {
    font-size: clamp(10px,.78vw,15px);
}

.room-grid-four .room-customer-panel .number-badge {
    height: clamp(18px,2vh,28px);
    font-size: clamp(11px,.95vw,18px);
}

.board-theme-dark .room-customer-panel {
    background: #202d42;
    border-color: #42526b;
}

    .board-theme-dark .room-customer-panel .customer-row {
        color: #eef3fc;
        border-color: #3e5067;
    }

        .board-theme-dark .room-customer-panel .customer-row:nth-child(even) {
            background: #29374d;
        }

    .board-theme-dark .room-customer-panel .customer-name,
    .board-theme-dark .room-customer-panel .birth-date {
        color: #f2f6ff;
    }

    .board-theme-dark .room-customer-panel .customer-table-head {
        background: var(--panel-header,#142f80);
    }

@media(max-width:1200px) {
    .room-customer-panel .customer-table-head, .room-customer-panel .customer-row {
        grid-template-columns: 38px minmax(0,1fr) 75px 61px;
    }

    .room-grid-four .room-customer-panel .customer-table-head,
    .room-grid-four .room-customer-panel .customer-row {
        grid-template-columns: 31px minmax(0,1fr) 66px 51px;
    }

    .room-grid-four .room-customer-panel .gender-pill {
        font-size: 10px;
    }
}

/* V13.4: 2/4 rooms — one table per room, 10 fixed + 5-row rolling viewport (11–20).
   Shared header is deliberately unchanged from V13.3. */
.board-room-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.room-list-body {
    --room-row-height: clamp(26px,4.55vh,49px);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
    padding: 5px 5px 7px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #cad5e9;
    border-radius: 0 0 12px 12px;
}

.room-list-head, .room-fixed-list .customer-row, .room-next-items .customer-row {
    display: grid;
    grid-template-columns: clamp(47px,5vw,88px) minmax(0,1.5fr) minmax(93px,.9fr) minmax(70px,.72fr);
    gap: 5px;
    align-items: center;
    min-width: 0;
}

.room-list-head {
    flex: none;
    height: clamp(30px,3.8vh,42px);
    font-size: clamp(12px,1vw,18px);
    border-radius: 8px;
}

.room-fixed-list {
    flex: none;
    min-height: 0;
}

    .room-fixed-list .customer-row, .room-next-items .customer-row {
        height: var(--room-row-height);
        min-height: 0;
        flex: none;
        padding: 0 4px;
        font-size: clamp(12px,1.08vw,20px);
    }

.room-list-body .number-badge {
    width: clamp(37px,3.7vw,70px);
    height: calc(var(--room-row-height) - 7px);
    font-size: clamp(14px,1.3vw,25px);
    border-radius: 7px;
}

.room-list-body .gender-pill {
    min-width: 0;
    padding: 2px 4px;
}

.room-next-viewport {
    flex: none;
    position: relative;
    min-width: 0;
    height: calc(var(--room-row-height) * 5);
    overflow: hidden;
    border-top: 3px solid var(--panel-accent,#efbd30);
    background: #f5f8fe;
}

.room-next-track {
    width: 100%;
    will-change: transform;
    animation: room-loop-up var(--room-scroll-duration,30s) linear infinite;
}

.room-next-items {
    width: 100%;
}

    .room-next-items .customer-row:nth-child(even) {
        background: #e9f1fc;
    }

.room-next-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #77849a;
    font-weight: 600;
    font-size: clamp(11px,.95vw,17px);
}

@keyframes room-loop-up {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-50%);
    }
}

.room-grid-four .room-list-body {
    --room-row-height: clamp(16px,2.23vh,25px);
    padding: 3px 4px 4px;
}

.room-grid-four .room-list-head {
    height: clamp(22px,2.8vh,32px);
    font-size: clamp(9px,.77vw,14px);
}

.room-grid-four .room-fixed-list .customer-row, .room-grid-four .room-next-items .customer-row {
    grid-template-columns: clamp(32px,3vw,54px) minmax(0,1.3fr) minmax(68px,.9fr) minmax(50px,.65fr);
    gap: 2px;
    padding: 0 2px;
    font-size: clamp(9px,.76vw,14px);
}

.room-grid-four .room-list-body .number-badge {
    width: clamp(26px,2.5vw,46px);
    height: calc(var(--room-row-height) - 3px);
    font-size: clamp(9px,.86vw,16px);
    border-radius: 5px;
}

.room-grid-four .room-list-body .gender-pill {
    font-size: inherit;
    padding: 0 2px;
}

.board-theme-dark .room-list-body {
    background: #202d42;
    border-color: #42526b;
}

    .board-theme-dark .room-list-body .customer-row {
        color: #eef3fc;
        border-color: #3e5067;
    }

        .board-theme-dark .room-list-body .customer-row:nth-child(even) {
            background: #29374d;
        }

    .board-theme-dark .room-list-body .customer-name, .board-theme-dark .room-list-body .birth-date {
        color: #f2f6ff;
    }

.board-theme-dark .room-next-viewport {
    background: #202d42;
}

@media (max-width:1100px) {
    .room-list-head, .room-fixed-list .customer-row, .room-next-items .customer-row {
        grid-template-columns: 45px minmax(0,1.25fr) 82px 63px;
    }

    .room-grid-four .room-list-head, .room-grid-four .room-fixed-list .customer-row, .room-grid-four .room-next-items .customer-row {
        grid-template-columns: 30px minmax(0,1fr) 62px 46px;
    }
}

@media (prefers-reduced-motion:reduce) {
    .room-next-track {
        animation: none;
    }
}

.board-room-layout .room-list-body {
    display: grid;
    grid-template-rows: auto minmax(0, 2fr) minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
}

.board-room-layout .room-fixed-list {
    display: grid;
    grid-template-rows: repeat(10, minmax(0, 1fr));
    min-height: 0;
    overflow: hidden;
}

    .board-room-layout .room-fixed-list .customer-row {
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

.board-room-layout .room-next-viewport {
    height: auto;
    min-height: 0;
    overflow: hidden;
    container-type: size;
}

.board-room-layout .room-next-items .customer-row {
    height: 20cqh;
    min-height: 0;
    overflow: hidden;
}
