:root {
    color-scheme: dark;
    --background: #101111;
    --surface: rgba(5, 7, 7, 0.72);
    --surface-strong: #171919;
    --surface-soft: #202323;
    --border: rgba(255, 255, 255, 0.07);
    --text: #f4f7f7;
    --muted: #929b9b;
    --termic: #58d9d0;
    --green: #34c759;
    --orange: #ff9500;
    --red: #ff453a;
    --blue: #32ade6;
    --pink: #ff2d55;
    --purple: #6e6adb;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-width: 320px;
    background: var(--background);
}

body {
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 8% 0%, rgba(88, 217, 208, 0.08), transparent 28rem),
        var(--background);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 14px 24px 10px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-link {
    display: inline-flex;
    align-items: center;
}

.logo-link img {
    display: block;
    width: auto;
    height: 44px;
}

.page-label {
    padding-left: 15px;
    border-left: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.67rem;
    font-weight: 750;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 18px;
}

.logout-button {
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.035);
    font: inherit;
    font-size: 0.64rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.logout-button:hover,
.logout-button:focus-visible {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
    outline: none;
}

#last-updated {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

#clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 118px;
}

#clock strong {
    color: var(--text);
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
    font-weight: 300;
    letter-spacing: 0.03em;
}

#clock small {
    color: var(--muted);
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(270px, 0.95fr) minmax(360px, 1.15fr) minmax(390px, 1.25fr);
    gap: 8px;
    min-height: calc(100vh - 76px);
    padding: 8px;
}

.card,
.half-card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.16);
}

.card {
    height: calc(100vh - 92px);
    overflow: auto;
    padding: 20px;
}

.card-but-half {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
    overflow: visible;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.half-card {
    min-height: 0;
    overflow: auto;
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    min-height: 45px;
    margin-bottom: 12px;
}

.card-header img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

h2 {
    margin-left: 12px;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 700;
}

h3 {
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.content-slot {
    min-width: 0;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.summary-card {
    min-height: 104px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface-strong);
}

.summary-label {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.summary-value {
    display: block;
    margin-top: 6px;
    color: var(--text);
    font-size: 1.65rem;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.summary-note {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.66rem;
}

.section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0 10px;
}

.section-label span {
    color: var(--muted);
    font-size: 0.67rem;
}

.schedule-list,
.project-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.schedule-item,
.project-item {
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-strong);
}

.item-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}

.item-title {
    overflow: hidden;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    color: var(--muted);
    font-size: 0.67rem;
    line-height: 1.45;
}

.date-pill,
.status-badge,
.type-badge,
.busbar-badge {
    display: inline-flex;
    align-items: center;
    width: max-content;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.61rem;
    font-weight: 750;
    line-height: 1.2;
    white-space: nowrap;
}

.date-pill {
    color: #d9ffff;
    background: rgba(88, 217, 208, 0.14);
}

.status-badge.secured {
    color: #a8f7b9;
    background: rgba(52, 199, 89, 0.16);
}

.status-badge.low {
    color: #ffd08a;
    background: rgba(255, 149, 0, 0.17);
}

.status-badge.empty {
    color: #ffaaa4;
    background: rgba(255, 69, 58, 0.18);
}

.type-badge.kusen {
    color: #c7c5ff;
    background: rgba(110, 106, 219, 0.2);
}

.type-badge.frameless {
    color: #ffd28f;
    background: rgba(255, 149, 0, 0.18);
}

.busbar-badge {
    color: #ffc0cc;
    background: rgba(255, 45, 85, 0.18);
}

#smart-film-bars {
    display: flex;
    flex-direction: column;
    gap: 11px;
    margin-bottom: 18px;
}

.film-row {
    display: flex;
    flex-direction: column;
}

.film-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 0.68rem;
    font-weight: 650;
}

.film-header span:last-child {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.bar-bg {
    width: 100%;
    height: 7px;
    overflow: hidden;
    border-radius: 10px;
    background: #2d3131;
}

.bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.bar-fill.low {
    background: var(--orange);
}

.bar-fill.good {
    background: var(--green);
}

.bar-fill.empty {
    background: var(--red);
}

.table-block {
    margin-top: 4px;
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.68rem;
    text-align: left;
}

th,
td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--muted);
    background: #171919;
    font-size: 0.61rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

td {
    color: #d9dede;
    font-variant-numeric: tabular-nums;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover td {
    background: rgba(255, 255, 255, 0.025);
}

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

.production-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.mini-stat {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-strong);
}

.mini-stat strong {
    display: block;
    margin-bottom: 3px;
    color: var(--text);
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.mini-stat span {
    color: var(--muted);
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.loading,
.empty-state,
.error-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 84px;
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    color: var(--muted);
    font-size: 0.7rem;
    line-height: 1.5;
    text-align: center;
}

.loading::before {
    width: 7px;
    height: 7px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--termic);
    content: "";
    animation: pulse 1.2s infinite ease-in-out;
}

.error-state {
    color: #ffaaa4;
    border-color: rgba(255, 69, 58, 0.28);
}

@keyframes pulse {
    0%,
    100% {
        opacity: 0.25;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #333838;
}

::-webkit-scrollbar-track {
    background: transparent;
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        height: auto;
    }

    .card,
    .card-but-half {
        height: auto;
        max-height: none;
    }

    .card-but-half {
        grid-template-rows: auto;
    }

    .half-card {
        min-height: 260px;
    }
}

@media (max-width: 620px) {
    .topbar {
        align-items: flex-start;
        padding: 14px 15px 8px;
    }

    .logo-link img {
        height: 36px;
    }

    .brand-block {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .page-label {
        padding-left: 0;
        border-left: 0;
        font-size: 0.58rem;
    }

    .header-meta {
        align-items: flex-end;
        flex-direction: column-reverse;
        gap: 2px;
    }

    .logout-button {
        margin-bottom: 3px;
    }

    #last-updated {
        max-width: 150px;
        text-align: right;
    }

    .dashboard-grid {
        padding: 6px;
    }

    .card,
    .half-card {
        padding: 16px;
        border-radius: 19px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .production-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .mini-stat {
        padding: 9px 7px;
    }
}
