:root {
    --bg-1: #03060b;
    --bg-2: #08121e;
    --panel: rgba(8, 19, 33, 0.9);
    --panel-head: rgba(15, 34, 56, 0.94);
    --border: #234260;
    --line: rgba(144, 181, 215, 0.25);
    --text: #ebf6ff;
    --text-muted: #9cb5ce;
    --accent: #61d5ff;
    --accent-soft: rgba(97, 213, 255, 0.25);
    --amber: #ffce64;
    --green: #59d37f;
    --red: #ff6b73;
    --row-height: clamp(46px, 6.2vh, 64px);
    --completed-row-height: clamp(30px, 3.8vh, 38px);
    --announcement-row-height: clamp(64px, 8vh, 82px);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 8%, rgba(22, 62, 104, 0.42) 0%, rgba(3, 8, 16, 0) 52%),
        radial-gradient(circle at 86% 24%, rgba(17, 94, 89, 0.28) 0%, rgba(3, 8, 16, 0) 44%),
        linear-gradient(140deg, var(--bg-2), var(--bg-1));
    font-family: "Barlow Condensed", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    overflow: hidden;
}

.board-shell {
    width: 100vw;
    height: 100vh;
    padding: 8px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
}

.board-header {
    border: 2px solid var(--border);
    background: linear-gradient(100deg, rgba(15, 34, 56, 0.96), rgba(10, 22, 36, 0.92));
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.board-title-line {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.board-kicker {
    color: var(--amber);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1.2px;
    white-space: nowrap;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 26px;
    font-weight: 900;
    letter-spacing: 0.8px;
}

.board-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.header-clock {
    color: var(--green);
    font-size: 21px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    font-family: "Roboto Mono", "Consolas", monospace;
}

.board-layout {
    min-height: 0;
    display: grid;
    grid-template-rows: 3fr 2fr 1fr;
    gap: 8px;
}

.production-panel,
.completed-band,
.announcement-panel {
    min-height: 0;
    border: 2px solid var(--border);
    background: var(--panel);
    display: grid;
}

.production-panel {
    grid-template-rows: auto auto minmax(0, 1fr);
}

.completed-band {
    grid-template-rows: auto auto minmax(0, 1fr);
}

.announcement-panel {
    grid-template-rows: auto minmax(0, 1fr);
}

.panel-title,
.announcement-title {
    padding: 5px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-head);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title h2,
.announcement-title h2,
.completed-title h2 {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.5px;
}

.panel-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-meta span {
    color: var(--amber);
    font-size: 16px;
    font-weight: 900;
}

.machine-banner {
    padding: 5px 12px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(95deg, rgba(13, 31, 50, 0.92), rgba(10, 21, 34, 0.86));
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.machine-name {
    color: var(--accent);
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 0.8px;
}

.machine-note {
    margin-top: 0;
    color: var(--text-muted);
    font-size: 14px;
    white-space: nowrap;
}

.timetable {
    min-height: 0;
    display: grid;
    grid-template-rows: 34px minmax(0, 1fr);
}

.timetable-head,
.timetable-row {
    display: grid;
    grid-template-columns: 160px 160px 210px 1fr 156px 94px 102px 104px;
    align-items: center;
    gap: 6px;
}

.timetable-head {
    padding: 0 10px;
    border-bottom: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.8px;
}

.timetable-head > span,
.timetable-row > div {
    min-width: 0;
    padding: 0 8px;
    border-right: 1px solid rgba(144, 181, 215, 0.2);
}

.timetable-head > span:last-child,
.timetable-row > div:last-child {
    border-right: none;
}

.text-right {
    text-align: right;
}

.timetable-body {
    min-height: 0;
    overflow: hidden;
    padding: 0 2px;
    perspective: 1100px;
}

.ticker-viewport {
    height: 100%;
    overflow: hidden;
}

.ticker-track {
    transform: translateY(0);
}

.ticker-track.animating {
    transition: transform 0.74s cubic-bezier(0.2, 0.75, 0.25, 1);
}

.timetable-row {
    position: relative;
    height: var(--row-height);
    padding: 4px 10px 4px 14px;
    border-bottom: 1px solid rgba(144, 181, 215, 0.12);
    background: rgba(255, 255, 255, 0.02);
    transform-origin: 50% 0%;
    will-change: transform, opacity;
}

.timetable-row.row-page-enter {
    animation: rowPageEnter 0.72s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes rowPageEnter {
    0% {
        opacity: 0;
        transform: rotateX(-52deg) translateY(-12px);
        filter: saturate(0.72);
    }
    60% {
        opacity: 1;
        transform: rotateX(8deg) translateY(0);
        filter: saturate(1);
    }
    100% {
        opacity: 1;
        transform: rotateX(0deg) translateY(0);
        filter: saturate(1);
    }
}

.timetable-row::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 5px;
    background: var(--status-color, var(--accent));
    box-shadow: 0 0 16px var(--status-glow, var(--accent-soft));
}

.time-range {
    font-family: "Roboto Mono", "Consolas", monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--amber);
}

.work-number {
    font-family: "Roboto Mono", "Consolas", monospace;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.customer-product,
.operator-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-product {
    font-size: 16px;
    font-weight: 800;
}

.operator-name {
    font-size: 15px;
    color: var(--text-muted);
}

.metric {
    text-align: right;
    font-family: "Roboto Mono", "Consolas", monospace;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}

.status-text {
    font-size: 15px;
    font-weight: 800;
    color: var(--status-color, var(--text));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.completed-band {
    background: linear-gradient(90deg, rgba(11, 27, 44, 0.94), rgba(8, 20, 34, 0.9));
}

.completed-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-head);
}

.completed-title h2 {
    margin: 0;
    white-space: nowrap;
}

.completed-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.completed-meta span {
    color: var(--amber);
    font-size: 14px;
    font-weight: 800;
}

.completed-head,
.completed-row {
    display: grid;
    grid-template-columns: 128px 220px 1fr 140px;
    align-items: center;
    gap: 0;
}

.completed-head {
    padding: 0 8px;
    border-bottom: 1px solid rgba(144, 181, 215, 0.16);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.7px;
}

.completed-head > span,
.completed-row > div {
    min-width: 0;
    padding: 0 8px;
    border-right: 1px solid rgba(144, 181, 215, 0.18);
}

.completed-head > span:last-child,
.completed-row > div:last-child {
    border-right: none;
}

.completed-body {
    min-height: 0;
    overflow: hidden;
    padding: 0 2px;
}

.completed-row {
    height: var(--completed-row-height);
    border-bottom: 1px solid rgba(144, 181, 215, 0.12);
    background: rgba(255, 255, 255, 0.015);
}

.completed-time,
.completed-work-number {
    font-family: "Roboto Mono", "Consolas", monospace;
}

.completed-time {
    color: var(--green);
    font-size: 14px;
    font-weight: 700;
}

.completed-work-number {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.completed-customer,
.completed-machine {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.completed-machine {
    color: var(--text-muted);
    font-weight: 700;
}

.announcement-list {
    min-height: 0;
    overflow: hidden;
}

.announcement-item {
    height: var(--announcement-row-height);
    border-left: 8px solid var(--amber);
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    display: grid;
    grid-template-columns: 280px 1fr;
    align-items: center;
    gap: 12px;
}

.announcement-item h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.announcement-item p {
    margin: 0;
    font-size: 17px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-state,
.error-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 22px;
    font-weight: 700;
}

.error-state {
    color: var(--red);
}

@media (max-width: 1600px) {
    .timetable-head,
    .timetable-row {
        grid-template-columns: 148px 148px 186px 1fr 140px 84px 92px 92px;
    }

    .announcement-item {
        grid-template-columns: 230px 1fr;
    }

    .completed-head,
    .completed-row {
        grid-template-columns: 118px 198px 1fr 126px;
    }
}

@media (max-width: 1280px) {
    .board-shell {
        padding: 8px;
        gap: 8px;
    }

    h1 {
        font-size: 23px;
    }

    .board-kicker {
        font-size: 13px;
        letter-spacing: 1px;
    }

    .machine-name {
        font-size: 21px;
    }

    .timetable-head,
    .timetable-row {
        gap: 6px;
        grid-template-columns: 132px 132px 168px 1fr 130px 82px 88px 84px;
    }

    .time-range,
    .work-number,
    .customer-product,
    .metric,
    .operator-name {
        font-size: 14px;
    }

    .announcement-item p {
        font-size: 15px;
    }

    .completed-title h2 {
        font-size: 16px;
    }

    .completed-head,
    .completed-row {
        grid-template-columns: 112px 174px 1fr 110px;
    }
}
