/* =========================================================================
   允穩工程 監測數據網站 — 全站樣式表
   參考:規格書 §5 設計風格 + 設計稿 PDF(storage/app/design-reference/PDF/)
   ========================================================================= */

/* ---------- 1. 設計 Token(CSS 變數) ---------- */
:root {
    /* 主色（後台預設藍） */
    --brand-primary: #5DA9E1;
    --brand-primary-dark: #3F82B5;
    --brand-primary-light: #A6D2F2;
    --brand-primary-border: var(--brand-primary-dark);
    --brand-primary-border-hover: var(--brand-primary-light);
    --brand-primary-surface: color-mix(in srgb, var(--brand-primary) 10%, transparent);
    --brand-primary-surface-hover: color-mix(in srgb, var(--brand-primary) 5%, transparent);
    --brand-primary-gradient-end: #7fc9f4;
    --brand-primary-focus-ring: rgba(54, 161, 233, 0.15);

    /* 連結 */
    --brand-link: var(--brand-primary);
    --brand-link-dark: var(--brand-primary-dark);

    /* 系統色 */
    --brand-success: #198754;
    --brand-warning: #ECC313;
    --brand-warning-dark: #715B05;
    --brand-danger: #FF5D2F;
    --brand-danger-dark: #7B1E0F;
    --brand-abnormal: #6c6d78; /* 系統異常灰 */

    /* 中性色 */
    --gray-base: #040405;
    --gray-darker: #1c1c21;
    --gray-dark: #2c2c33;
    --text: #4a4b54;
    --text-muted: #6c6d78;
    --text-light: #8d8e99;
    --text-lightt: #c0c1cc;
    --border: #d5d6de;
    --border-light: #e8e9ed;
    --bg-body: #f8f9fc;
    --bg-card: #ffffff;
    --bg-hover: #e6e6e6;      /* 對齊 $table-bg-hover */
    --bg-stripe: #fafafafa;     /* 對齊 $table-bg-accent */

    /* 側邊欄 */
    --sidebar-bg: #ffffff;
    --sidebar-text: var(--text-muted);
    --sidebar-text-hover: var(--brand-primary);
    --sidebar-text-active: var(--brand-primary);
    --sidebar-bg-active: var(--brand-primary-surface);
    --sidebar-submenu-bg: #ffffff;
    --sidebar-submenu-text-active: var(--brand-primary);
    --sidebar-divider: var(--border-light);
    --sidebar-shadow: 1px 0 0 var(--border-light);

    /* 表單 / 按鈕 */
    --input-border: var(--border-light);
    --input-bg: #ffffff;
    --input-focus: var(--brand-primary-light);

    /* 尺寸與間距（對齊 Bootstrap SCSS components 設定） */
    --sidebar-width: 240px;
    --topbar-height: 64px;                 /* 對齊 $navbar-height */
    
    --padding-nub-sm: 5px;                     /* 對齊 $padding-small-vertical */
    --padding-nub-md: 10px;                    /* 對齊 $padding-large-vertical */
    --padding-nub-lg: 15px;                    /* 對齊 $alert-padding */
    --padding-xxs: 4px;
    --padding-xs: 8px; 
    --padding-sm: 12px;
    --padding-md: 16px;
    --padding-lg: 24px;
    --content-padding: 16px 64px;               /* 對齊 $grid-gutter-width */
    --card-padding: 16px 16px 32px 16px;        /* 對齊 $panel-body-padding */
    
    --radius-sm: 3px;                      /* 對齊 $border-radius-small */
    --radius-md: 6px;                      /* 對齊 $border-radius-base */
    --radius-lg: 8px;                      /* 對齊 $border-radius-large */
    --radius-pill: 9999px;

    /* 陰影 */
    --shadow-sm: 0 0 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 0px 16px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.08);

    /* 字體與排版 */
    --font-family: "Noto Sans", "微軟正黑體", Arial, "Helvetica Neue", Helvetica, sans-serif;
    --font-size-xs: 0.75rem;    /* 12px */
    --font-size-sm: 0.875rem;   /* 14px */
    --font-size-md: 1rem;       /* 16px */
    --font-size-lg: 1.25rem;    /* 20px */
    --font-size-xl: 1.5rem;     /* 24px */
    --font-size-2xl: 2rem;      /* 32px */
    --line-height: 1.75;
    
    /* 過渡 */
    --transition: 0.2s ease;
    --transition-layout: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 前台主色：綠 */
.app-layout--client {
    --brand-primary: #4F9D5E;
    --brand-primary-dark: #2A7338;
    --brand-primary-light: #B3E5BD;
    --brand-primary-border: var(--brand-primary-dark);
    --brand-primary-border-hover: var(--brand-primary-light);
    --brand-primary-surface: color-mix(in srgb, var(--brand-primary) 10%, transparent);
    --brand-primary-surface-hover: color-mix(in srgb, var(--brand-primary) 5%, transparent);
    --brand-primary-focus-ring: rgba(106, 178, 179, 0.15);

    /* 連結 */
    --brand-link: var(--brand-primary);
    --brand-link-dark: var(--brand-primary-dark);

    /* 側邊欄 */
    --sidebar-bg: #ffffff;
    --sidebar-text: var(--text-muted);
    --sidebar-text-hover: var(--brand-primary);
    --sidebar-text-active: var(--brand-primary);
    --sidebar-bg-active: var(--brand-primary-surface);
    --sidebar-submenu-bg: #ffffff;
    --sidebar-submenu-text-active: var(--brand-primary);
    --sidebar-divider: var(--border-light);
    --sidebar-shadow: 1px 0 0 var(--border-light);

    /* 表單 / 按鈕 */
    --input-border: var(--border-light);
    --input-bg: #ffffff;
    --input-focus: var(--brand-primary-light);
}

/* ---------- 2. 重置與基礎排版 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    font-weight: normal;
    color: var(--text);
    background: var(--bg-body);
    line-height: var(--line-height);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
/* 選擇反白 */
 ::selection {
    background-color: var(--brand-primary);
    color: #ffffff;
 }

a { color: var(--brand-link); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-link-dark); }

/* ---------- 3. App Layout(側邊欄 + 主內容) ---------- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-layout, --transition);
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- 4. Sidebar:Logo 區 ---------- */
.sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--padding-nub-md);
    background: transparent;
    min-height: 80px;
}

.sidebar__brand img,
.sidebar__brand svg {
    max-width: 100%;
    height: auto;
}

/* Brand:色塊式 Logo + 文字標題 */
.brand {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--brand-primary-dark);
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    text-align: center;
}
.brand img {
    flex-shrink: 0;
}
.brand__text {
    color: var(--brand-primary-dark);
    letter-spacing: 1px;
}
/* 預設 brand:水平排版(用於登入頁、error 頁) */
.brand--inline {
    flex-direction: row;
    gap: 10px;
}

/* ---------- 5. Sidebar ---------- */
.sidebar__nav {
    flex: 1;
    padding: var(--padding-xs) 0 64px 0;
    list-style: none;
    margin: 0;
}

.sidebar__nav-item { margin: 0; position: relative; }

.sidebar__nav-link {
    display: flex;
    align-items: center;
    gap: var(--padding-sm);
    padding: var(--padding-sm) var(--padding-md);
    color: var(--sidebar-text);
    font-size: var(--font-size-md);
    text-decoration: none;
    transition: color var(--transition), background var(--transition);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.sidebar__nav-link:hover {
    color: var(--sidebar-text-hover);
    background: var(--bg-body);
}

.sidebar__nav-item.is-active > .sidebar__nav-link {
    color: var(--sidebar-text-active);
    background-color: var(--sidebar-bg-active),0.5;
    font-weight: 500;
}

.sidebar__nav-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.sidebar__nav-text { flex: 1; }

.sidebar__nav-arrow {
    flex-shrink: 0;
    transition: transform var(--transition);
}

.sidebar__nav-item.is-open > .sidebar__nav-link .sidebar__nav-arrow {
    transform: rotate(180deg);
}

/* 子選單 */
.sidebar__submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--sidebar-submenu-bg);
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition);
}

.sidebar__nav-item.is-open > .sidebar__submenu {
    max-height: 600px;
}

.sidebar__submenu-link {
    display: block;
    padding: 8px 20px 8px 51px; /* 對齊主選單 icon 之後 */
    color: var(--sidebar-text);
    font-size: var(--font-size-sm);
    text-decoration: none;
    transition: color var(--transition), background var(--transition);
}

.sidebar__submenu-link:hover {
    color: var(--sidebar-text-hover);
    background: var(--bg-body);
}

.sidebar__submenu-item.is-active > .sidebar__submenu-link {
    color: var(--sidebar-submenu-text-active);
    font-weight: 500;
}

/* Sidebar */
.sidebar__footer {
    position: fixed;
    bottom: 0;
    width: var(--sidebar-width);
    border-top: 1px solid var(--sidebar-divider);
    padding: var(--padding-xs) 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background:#ffffff;
    color: var(--text-lightt);
    font-weight: 700;
}

.sidebar__user-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
    text-align: center;
}

.sidebar__user {
    display: flex;
    align-items: center;
    color: var(--brand-primary);
    font-size: var(--font-size-md);
    flex: 1;
    /* min-width: 0; */
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}

.sidebar__user:hover,
.sidebar__user.is-active {
    color: var(--text);
}

.sidebar__logout {
    background: transparent;
    border: none;
    width: 48px;
    height: 48px;
    color: var(--text-lightt);
    border-radius: var(--radius-pill);
    transition: all var(--transition);
    cursor: pointer;
    font-size: 20px;
    margin-right: 8px;
}

.sidebar__logout:hover {
    color: var(--brand-danger);
    background: rgba(239, 68, 68, 0.08);
}

/* ---------- 6. Topbar(KMH 風:扁平、無 sticky 陰影,留空間給大標題) ---------- */
.topbar {
    min-height: var(--topbar-height);
    background: transparent;
    display: flex;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-light);
}

.topbar__toggle {
    background: transparent;
    border: none;
    padding: 21px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition);

    i {
        font-size: 22px;
    }
}

.topbar__title {
    font-size: var(--font-size-2xl);
    font-weight: 500;
    color: var(--gray-dark);
    margin: 0;
    line-height: 1.2;
}

.topbar__breadcrumb {
    margin-left: 0;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.topbar__breadcrumb a {
    color: var(--brand-link);
}

.topbar__breadcrumb a { color: var(--brand-link); }
.topbar__breadcrumb-sep {
    color: var(--text-light);
    margin: 0 6px;
}

.topbar__right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* 同一頁同時顯示「標題 + 麵包屑(下方)」的版型 */
.topbar__head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 0;
}

.topbar__head .topbar__breadcrumb {
    margin-left: 0;
}

/* ---------- 7. 內容區 ---------- */
.content {
    flex: 1;
    padding: var(--content-padding);
}

.content__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

/* ---------- 8. Footer ---------- */
.footer {
    text-align: center;
    color: var(--text-light);
    font-size: var(--font-size-sm);
    padding: 16px;
    background: transparent;
}

/* ---------- 9. 卡片(KMH 扁平風:無陰影、淡邊框、小圓角) ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    margin-bottom: 16px;
}

.card--filter {
    padding: var(--padding-xs);
    background: rgba(0, 0, 0, 0.05);
    border: none;
    margin-bottom: 16px;

    .sites-filter-bar {
        display: flex;
        align-items: center;
        gap: var(--padding-xs);
    }
}

.card__title {
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: var(--text);
    padding: var(--padding-md);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .update {
        color: var(--text-light);
        font-size: var(--font-size-sm);;
    }
}

.card__body {
    padding: var(--card-padding);
    border-top: 1px solid var(--border-light);
}

.card__section + .card__section {
    margin-top: 24px;
}

/* KMH 風:section heading,不需卡片但要視覺分區 */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.section-head h3 {
    font-size: var(--font-size-lg);
    font-weight: 500;
    margin: 0;
}

/* ---------- 10. 按鈕 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px var(--padding-sm);
    font-size: var(--font-size-md);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:focus-visible {
    background: var(--brand-primary-dark);
    color: #ffffff;
}

.btn.is-loading {
    position: relative;
}

.btn--primary {
    background-color: var(--brand-link);
    color: #ffffff;
    border-color: var(--brand-link);
}
.btn--primary:hover:not(:disabled) {
    background: var(--brand-link-dark);
    border-color: var(--brand-link-dark);
    color: #ffffff;
}

.btn--success {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
}
.btn--success:hover:not(:disabled) {
    background: var(--brand-primary-dark);
    border-color: var(--brand-primary-dark);
    color: #ffffff;
}

.btn--secondary {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--input-border);
}
.btn--secondary:hover:not(:disabled) {
    background: var(--bg-hover);
}

.btn--danger {
    background: var(--brand-danger);
    color: #ffffff;
    border-color: var(--brand-danger);
}
.btn--danger:hover:not(:disabled) {
    background: #DC2626;
    border-color: #DC2626;
    color: #ffffff;
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
    padding: 6px;
}
.btn--ghost:hover:not(:disabled) {
    color: var(--text);
    background: var(--bg-hover);
}

.btn--operate {
    font-size: var(--font-size-xl);
    padding: 0 var(--padding-xxs);
    color: var(--text-lightt);
}
.btn--operate.edit:hover:not(:disabled) {
    color: var(--brand-primary);
}
.btn--operate.delete:hover:not(:disabled) {
    color: var(--brand-danger);
}

.btn--sm {
    padding: 4px 10px;
    font-size: var(--font-size-sm);
}

.btn--lg {
    padding: 12px 24px;
    font-size: var(--font-size-lg);
}

.btn__icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
}

/* ---------- 11. 表單 ---------- */
.form-group {
    margin-bottom: var(--padding-nub-md);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--padding-nub-lg);
    width: 100%;
    margin-bottom: var(--padding-nub-lg);
}
.form-row .form-group { margin-bottom: 0; }
.form-row--1 { grid-template-columns: 1fr; }
.form-row--2 { grid-template-columns: repeat(2, 1fr); }
.form-row--3 { grid-template-columns: repeat(3, 1fr); }

/* .card > form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
} */

.form-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text);
    margin-bottom: 2px;
    font-weight: 700;
}

.form-label--required::after {
    content: ' *';
    color: var(--brand-danger);
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: var(--padding-xs) var(--padding-sm);
    font-size: var(--font-size-md);
    color: var(--text);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px var(--brand-primary-focus-ring);
}

.form-control::placeholder {
    color: var(--text-light);
}

.form-control--sm {
    padding: 4px 8px;
    font-size: var(--font-size-sm);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-text {
    color: var(--text);
    font-size: var(--font-size-md);
}

.form-error {
    font-size: var(--font-size-sm);
    color: var(--brand-danger);
    margin-top: 4px;
}

.form-help {
    font-size: var(--font-size-xs);
    color: var(--text-light);
    margin-top: 4px;
}

/* 搜尋框 */
.search-box {
    display: inline-flex;
    align-items: stretch;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    
    overflow: hidden;
}
.search-box .form-control {
    height: 40px;
}
.search-box .form-control:focus { box-shadow: none; }
.search-box__btn {
    background: #fff;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    padding: 5px 11px;
    height: 40px;
    color: var(--brand-primary);
    cursor: pointer;
    transition: color var(--transition);

    svg {
        width: 16px;
        height: 16px;
        margin-bottom: 4px;
    }
}
.search-box__btn:hover { 
    border-color: var(--input-focus);
    background-color: var(--bg-hover);
}

/* 功能列 */
.functionbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: var(--padding-md);
}

.functionbar__01 {
    width: 100%;
}

/* 工地編輯頁：儀器管理工具列（搜尋左、按鈕右） */
/* .sites-filter-bar--instrument {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: nowrap;
}

.sites-filter-bar--instrument .sites-filter-form {
    display: flex;
    align-items: center;
    flex: 0 1 360px;
    min-width: 0;
}

.sites-filter-bar--instrument .search-box {
    width: 100%;
}

.sites-filter-bar--instrument .search-box .form-control {
    width: 100%;
}

.sites-filter-bar--instrument > .btn {
    margin-left: auto;
    flex-shrink: 0;
} */

/* 分頁頁數 */
.pagination--center {
    margin: 16px 0 0;
    display: flex;
    justify-content: center;
}

.main_pagination .pagination {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.main_pagination .pagination a,
.main_pagination .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--brand-primary);
    /* text-decoration: none; */
    background: var(--bg-card);
    font-size: var(--font-size-sm);
}

.main_pagination .pagination li.active span {
    color: #fff;
    background: var(--brand-link);
    border-color: var(--brand-link);
}

.main_pagination .pagination li.disabled span {
    color: var(--text-muted);
    background: var(--bg-hover);
    cursor: not-allowed;
}

.main_pagination .pagination a:hover {
    background: var(--bg-hover);
}

/* Tag 多選 */
.tag-input {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    min-height: 38px;
    align-items: center;
}
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--border-light);
    color: var(--text);
    font-size: var(--font-size-sm);
    border-radius: var(--radius-sm);
}
.tag__remove {
    background: transparent;
    border: none;
    padding: 0 0 0 4px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
}
.tag__remove:hover { color: var(--brand-danger); }

/* ---------- 12. 表格(KMH 線條式:無外框、純列底線分隔,留白多) ---------- */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table thead th {
    font-weight: 700;
    color: var(--text);
    padding: var(--padding-nub-md);
    text-align: center;
    font-size: var(--font-size-md);
    white-space: nowrap;

    &.w-12 {
        width: 12%;
    }
    &.w-20 {
        width: 20%;
    }
}



.table thead th[rowspan] {
    vertical-align: middle;
}

.table thead tr + tr th {
    border-top: none;
}

.table tbody td {
    padding: var(--padding-nub-md);
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    vertical-align: middle;
    word-break: keep-all;
    min-width: 8rem;
    max-width: 30rem;
}

.table--striped tbody tr:nth-child(odd) td {
    background: var(--bg-stripe);
}

.table tbody tr:hover td {
    background: var(--brand-primary-surface-hover);
}

.table--reading td:first-child {
    background: var(--bg-stripe);
    font-weight: 500;
    text-align: center;
    width: 140px;
}

/* table-wrapper:扁平版,不再有圓角白卡背景,只負責橫向捲動 */
.table-wrapper {
    overflow-x: auto;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.table-wrapper + .table-wrapper {
    margin-top: var(--padding-nub-lg);
}

/* ---------- 13. Badges / Status / 警戒色 ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--font-size-sm);
    background: var(--border-light);
    color: var(--text);
}

.badge--active { background: rgba(45, 196, 162, 0.15); color: var(--brand-primary-dark); }
.badge--inactive { background: var(--border-light); color: var(--text-muted); }

/* 規格書 §5.4 數值警戒顏色 */
.value--normal { color: var(--text); }
.table tbody td.value--warning { color: var(--brand-warning); font-weight: 500; }
.table tbody td.value--action { color: var(--brand-danger); font-weight: 500; }
.table tbody td.value--abnormal { color: var(--brand-abnormal); }

.value--warning { color: var(--brand-warning); font-weight: 500; }
.value--action { color: var(--brand-danger); font-weight: 500; }
.value--abnormal { color: var(--brand-abnormal); }

/* 圓點圖例(規格書 §5.4) */
.history-legend {
    display: flex;
    gap: var(--padding-md);
    flex-wrap: wrap;
    color: var(--text-light);
    font-size: var(--font-size-sm);
    margin-bottom: var(--padding-md);
}

.legend {
    display: flex;
    align-items: center;
    gap: var(--padding-xxs);
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;

    &.warning {
        background: var(--brand-warning);
    }

    &.action {
        background: var(--brand-danger);
    }
}

.legend-line {
    display: inline-block;
    width: 12px;
    height: 1.5px;
    vertical-align: middle;
    background: var(--brand-abnormal);

    &.abnormal {
        background: var(--brand-abnormal);
    }
}

.history-report-title {
    margin: 0 0 12px;
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.btn--outline {
    background: var(--bg-card);
    color: var(--brand-primary);
    border: 1px solid var(--brand-primary);
}

.btn--outline:hover:not(:disabled) {
    background: var(--brand-primary-surface);
    border-color: var(--brand-primary-dark);
    color: var(--brand-primary-dark);
}

/* 即時監測 */
.realtime-group__title {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.realtime-grid-scroll,
.realtime-matrix-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.realtime-grid__table,
.realtime-matrix__table {
    table-layout: fixed;
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.realtime-grid__col-label,
.realtime-matrix__col-label {
    width: 12%;
}

.realtime-grid__col-data,
.realtime-matrix__col-data {
    width: 20%;
}

/* .realtime-grid__cell,
.realtime-matrix__cell,
.realtime-matrix__row-label {
    padding: 10px 12px;
    text-align: center;
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card, #fff);
    vertical-align: middle;
    font-weight: 400;
} */

.realtime-grid__table tr:last-child > :is(th, td),
.realtime-matrix__table tr:last-child > :is(th, td) {
    border-bottom: none;
}

.realtime-grid__table tr > :is(th, td):last-child,
.realtime-matrix__table tr > :is(th, td):last-child {
    border-right: none;
}

.realtime-grid__cell--corner,
.realtime-grid__cell--row-label,
.realtime-matrix__row-label {
    font-weight: 700;
    text-align: left !important;
    color: var(--text) !important;
}

.realtime-grid__cell--label {
    font-weight: 500;
    background: var(--brand-bg-muted, #f8fafc);
}

.realtime-matrix__title {
    font-weight: 600;
    margin-bottom: 8px;
}

.realtime-matrix__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: var(--padding-nub-md);
    font-weight: 700;
    background: var(--brand-bg-muted, #f8fafc);
    border: 1px solid var(--border-light);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.realtime-matrix__name {
    font-size: var(--font-size-md);
    color: var(--text);
}

.realtime-matrix__update {
    color: var(--text-light);
    font-size: var(--font-size-sm);
    font-weight: 400;
    white-space: nowrap;
}

.realtime-matrix__head + .table-wrapper > .table {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.realtime-matrix__cell {
    word-break: break-word;
}

.realtime-matrix__cell--label {
    font-size: var(--font-size-sm);
    color: var(--text);
}

.status-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-pill);
    padding: 4px 10px;
    font-size: var(--font-size-sm);
    line-height: 1.2;
    border: 1px solid transparent;
}

.status-chip--normal {
    color: #166534;
    background: #DCFCE7;
    border-color: #BBF7D0;
}

.status-chip--warning {
    color: #92400E;
    background: #FEF3C7;
    border-color: #FDE68A;
}

.status-chip--action {
    color: #991B1B;
    background: #FEE2E2;
    border-color: #FECACA;
}

.status-chip--abnormal {
    color: #334155;
    background: #E2E8F0;
    border-color: #CBD5E1;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-pill);
    padding: 2px 10px;
    font-size: var(--font-size-sm);
    line-height: 1.2;
}

.status-pill--normal {
    color: #166534;
    background: #DCFCE7;
}

.status-pill--warning {
    color: #92400E;
    background: #FEF3C7;
}

.status-pill--action {
    color: #991B1B;
    background: #FEE2E2;
}

.status-pill--abnormal {
    color: #334155;
    background: #E2E8F0;
}

/* ---------- 14. Tabs ---------- */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 32px;
}

.tab {
    padding: var(--padding-nub-md) var(--padding-nub-lg);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--font-size-md);
    cursor: pointer;
    border-bottom: 1px solid transparent;
    transition: all var(--transition);
}

.tab:hover { color: var(--text); }

.tab.is-active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
    font-weight: 500;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- 15. Alert(訊息) ---------- */
/* .alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: var(--font-size-md);
} */
/* .alert--success { background: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.alert--info    { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
.alert--warning { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.alert--danger  { background: #FEE2E2; color: #991B1B; border-color: #FECACA; } */

/* ---------- 16. Modal（app-modal-* 避免與 Bootstrap .modal 衝突） ---------- */
.app-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
.app-modal-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.app-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow: auto;
    transform: translateY(20px);
    transition: transform var(--transition);
}
.app-modal-backdrop.is-open .app-modal { transform: translateY(0); }

.app-modal__head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-modal__title {
    font-size: var(--font-size-lg);
    font-weight: 500;
}

.app-modal__body { padding: 20px; }
.app-modal__foot {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---------- 17. 工具類 ---------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text--warning { color: var(--brand-warning); }
.text--danger { color: var(--brand-danger); }
.text--abnormal { color: var(--brand-abnormal); }


.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.hidden { display: none !important; }
.inline-form { display: inline; }

/* .section-tools {
    display: flex;
    justify-content: flex-end;
} */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.dashboard-stat {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    background: var(--bg-body);
}

.dashboard-stat__label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: 4px;
}

.dashboard-stat__value {
    font-size: var(--font-size-lg);
    color: var(--text);
    font-weight: 500;
}

.dashboard-links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.history-chart-wrap {
    position: relative;
    height: 45rem;
    width: 100%;
    border-top: none;
    padding-bottom: 2rem;
}

.chart-tools {
    display: flex;
    justify-content: flex-end;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.gallery-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    background: var(--bg-body);
}

.gallery-card__image-wrap {
    aspect-ratio: 4 / 3;
    background: var(--border-light);
}

.gallery-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-card__meta {
    padding: 10px;
}

.gallery-card__title {
    font-size: var(--font-size-md);
    color: var(--text);
    margin-bottom: 4px;
}

.gallery-card__hint {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.report-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 10px;
}

.report-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.report-item__name {
    font-size: var(--font-size-md);
    color: var(--text);
    word-break: break-word;
}

/* ── 前台：工地資訊 ── */
.site-info-card {
    padding: 0;
    overflow: hidden;
}

.site-info-card .table-wrapper {
    margin: 0;
}

.site-info-table {
    margin-bottom: 0;
}

.site-info-table thead th {
    background: var(--bg-body);
    color: var(--text);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    white-space: nowrap;
}

.site-info-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    word-break: break-word;
}

.site-info-table tbody tr:last-child td {
    border-bottom: none;
}

/* .site-info-table__action-col {
    width: 72px;
    text-align: center;
    white-space: nowrap;
} */

/* .site-info-download-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    text-decoration: none;
}

.site-info-download-link:hover {
    color: var(--primary-dark, #1d4ed8);
}

.site-info-download-link__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
} */

.site-info-empty {
    padding: 24px 16px;
    margin: 0;
}

.site-info-gallery {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--padding-nub-lg);
}

.site-info-gallery__item {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-card);
    aspect-ratio: 16 / 9;
}

.site-info-gallery__item:hover {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-sm);
}

.site-info-gallery__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── 前台：擋土支撐設計圖 GLightbox（對齊 Figma） ── */
.goverlay {
    background: rgba(0, 0, 0, 0.75) !important;
}

/* 僅調整按鈕與標題，不覆寫 GLightbox 圖片容器尺寸，避免影響點擊放大 */
.site-design-lightbox .gslide-description,
.site-design-lightbox .gnext-label,
.site-design-lightbox .gprev-label {
    display: none !important;
}

.site-design-lightbox .gbtn {
    width: 56px;
    height: 56px;
    background: transparent !important;
    border: none;
    box-shadow: none;
    opacity: 0.85;
}

.site-design-lightbox .gbtn:hover {
    opacity: 1;
    background: transparent;
}

.site-design-lightbox .gbtn svg,
.site-design-lightbox .gbtn path {
    stroke: rgba(255, 255, 255, 0.78);
    fill: none;
}

.site-design-lightbox .gbtn:hover svg,
.site-design-lightbox .gbtn:hover path {
    stroke: #fff;
}

.site-design-lightbox .gbtn.gprev {
    /* left: 24px; */
    top: 50%;
    transform: translateY(-50%);
}

.site-design-lightbox .gbtn.gnext {
    /* right: 24px; */
    top: 50%;
    transform: translateY(-50%);
}

.site-design-lightbox .gbtn.gclose {
    top: auto;
    right: 96px;
    bottom: 32px;
    left: auto;
    width: 40px;
    height: 40px;
    opacity: 1;
}

.site-design-lightbox .gbtn.gclose svg {
    width: 30px;
    height: 30px;
}

.site-design-lightbox__meta {
    position: fixed;
    left: 96px;
    bottom: 32px;
    z-index: 999999;
    color: #fff;
    pointer-events: none;
}

.site-design-lightbox__title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
}

.site-design-lightbox__counter {
    font-size: 14px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.82);
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--padding-nub-sm);
}

.chip-option {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
    overflow: hidden;
}

.chip-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.chip-option > span {
    display: inline-flex;
    align-items: center;
    padding: 6px var(--padding-sm);
    line-height: 1.3;
}

.chip-option input:checked + span,
.chip-option.is-active > span {
    background: var(--brand-primary);
    color: #ffffff;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ---------- 首頁橫幅 ---------- */
.company-banner {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #fff;
}

.company-banner__image {
    width: 100%;
    height: auto;
    display: block;
}

/* ---------- 歷史頁查詢列 ---------- */
.history-filter {
    display: flex;
    flex-wrap: wrap;
    gap: var(--padding-xs);
    width: 100%;
    align-items: flex-start;
}

/* .history-filter-grid--client {
    grid-template-columns: minmax(200px, 0.87fr) minmax(260px, 1.43fr) 42px;
} */

.history-filter-field {
    display: flex;
    flex-wrap: wrap;
    gap: var(--padding-xxs);
    flex: 1 1 120px;
    min-width: 0; /* 關鍵防呆：防止子元素過長撐破排版 */
    
    &.range {
        flex: 2 1 540px;
    }

    &.instrument {
        flex: 1 1 600px;
    }

    .form-label {
        margin: 0;
        padding-top: var(--padding-xs);
        white-space: nowrap; /* 確保「選擇儀器」四個字絕對不會斷行 */
        font-weight: 500;
        color: var(--color-text);
    }
}

.history-filter-control {
    flex: 1;
    min-width: 0; /* 確保裡面的 Select/Input 可以正確收縮 */
    width: 100%;
    flex-wrap: wrap;
    
}

.history-range-row {
    display: flex;
    align-items: center;
    gap: var(--padding-xxs);
    width: 100%;
    
    .form-control {
        flex: 1;
        min-width: 0;
    }

    span {
        color: var(--color-text-light, #8D8E99);
        flex-shrink: 0;
        font-size: var(--font-size-sm);
    }
}

.history-filter-help {
    margin-top: 0px;
}


/* .history-filter-field--instrument .history-filter-control {
    width: 100%;
}

.history-filter-field--instrument .history-filter-control,
.history-filter-field--instrument .history-virtual-select.vscomp-wrapper {
    width: 100%;
    max-width: none;
} */

/* VirtualSelect 預設 .vscomp-ele { max-width: 250px }，需覆寫才能撐滿欄位 */
.history-filter-field--instrument .vscomp-ele,
.history-filter-control .vscomp-ele {
    display: block;
    width: 100%;
    max-width: none;
}

.history-filter-field--instrument .vscomp-wrapper {
    display: flex;
    width: 100%;
    max-width: none;
}

.vscomp-wrapper.focused .vscomp-toggle-button, .vscomp-wrapper:focus .vscomp-toggle-button {
    box-shadow: none !important;
}

.history-filter-control .history-virtual-select.vscomp-wrapper,
.history-filter-control #historyInstrumentSelectAdmin,
.history-filter-control #historyInstrumentSelectClient {
    width: 100%;
}

.history-filter-action {
    display: flex;
    align-items: flex-end;
    min-height: 38px;
}

/* .history-range-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--padding-xxs);
    align-items: center;
} */

.history-search-box {
    width: 100%;
}

.history-search-box .form-control {
    width: 100%;
}

.history-filter-submit {
    height: 38px;
    width: 38px;
    border: 1px solid var(--brand-primary-border);
    border-radius: 4px;
    background: #fff;
    color: var(--brand-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.history-filter-submit:hover {
    background: var(--brand-primary-surface-hover);
    border-color: var(--brand-primary-border-hover);
}

.history-empty-state {
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;

    img {
        width: 15rem;
        height: auto;
    }
}

.history-empty-state__title {
    font-size: var(--font-size-lg);
    color: var(--text);
    margin-bottom: 0px;
}

.history-virtual-select.vscomp-wrapper {
    min-width: 0;
}

.history-virtual-select .vscomp-toggle-button {
    min-height: 40px;
    width: 100%;
    border: 1px solid #dbe7f3;
    border-radius: 4px;
    padding: 5px 34px 5px 10px;
}

.history-virtual-select .vscomp-value {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    max-width: 100%;
    height: auto;
    min-height: 20px;
    white-space: nowrap;
}

.history-virtual-select:not(.has-no-options).focused .vscomp-toggle-button {
    border-color: var(--brand-primary-border-hover);
    box-shadow: 0 0 0 3px var(--brand-primary-focus-ring);
}

/* Virtual Select 內建 has-no-options：展開時會 focus .vscomp-no-options，需覆寫 focus 樣式 */
.history-virtual-select.has-no-options.focused .vscomp-toggle-button,
.history-virtual-select.has-no-options .vscomp-toggle-button:focus,
.history-virtual-select.has-no-options .vscomp-toggle-button:focus-visible,
.history-virtual-select.has-no-options .vscomp-dropbox,
.history-virtual-select.has-no-options .vscomp-dropbox-container,
.history-virtual-select.has-no-options .vscomp-no-options,
.history-virtual-select.has-no-options .vscomp-no-options:focus,
.history-virtual-select.has-no-options .vscomp-no-options:focus-visible,
.history-virtual-select.has-no-options .vscomp-search-input:focus {
    border-color: var(--input-border) !important;
    box-shadow: none !important;
    outline: none !important;
}

.history-virtual-select .vscomp-value-tag {
    background: var(--bg-body);
    border: 1px solid var(--brand-primary);
    border-radius: var(--radius-sm) !important;
    color: var(--text);
    margin-right: 0px !important;
}

.history-virtual-select .vscomp-clear-button {
    color: #94a3b8;
}

.history-virtual-select .vscomp-dropbox {
    border: 1px solid #dbe7f3;
    border-radius: 4px;
}

.history-virtual-select .vscomp-option {
    font-size: var(--font-size-sm);
}

.history-virtual-select .vscomp-option.description .description {
    color: var(--text-muted);
    font-size: 11px;
}

.history-virtual-select .vscomp-option.selected {
    color: #1f2937;
    background: var(--brand-primary-surface);
}

/* Flatpickr：歷史頁日期區間 */
/* .history-range-row .flatpickr-input {
    width: 100%;
    padding: 8px 12px;
    font-size: var(--font-size-md);
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
}

.history-range-row .flatpickr-input:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px var(--brand-primary-focus-ring);
}

.flatpickr-calendar {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-family: var(--font-family);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}

.flatpickr-day:hover,
.flatpickr-day.today:hover {
    background: var(--brand-primary-light);
    border-color: var(--brand-primary-light);
}

.flatpickr-day.today {
    border-color: var(--brand-primary);
} */


/* ---------- 匯入進度 ---------- */
.import-log-box {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--border-light);
    color: var(--text);
    padding: 6px var(--padding-sm);
    line-height: 1.7;
    font-size: var(--font-size-md);
    min-height: 5rem;
    max-height: 15rem;
    overflow-y: auto;
}

.import-log-box--progress .import-log-box__title {
    margin-bottom: 6px;
    font-weight: 500;
}

.import-progress {
    position: relative;
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.import-progress__bar {
    position: absolute;
    top: 0;
    left: -40%;
    width: 35%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand-primary) 0%, var(--brand-primary-gradient-end) 100%);
    opacity: 0;
}

.import-progress.is-active .import-progress__bar {
    opacity: 1;
    animation: import-progress-slide 1.4s linear infinite;
}

.import-progress.is-complete .import-progress__bar {
    left: 0;
    width: 100%;
    opacity: 1;
    animation: none;
}

.import-progress__status {
    margin-top: 8px;
    color: var(--text);
}

.import-progress__hint {
    color: var(--text-muted);
    font-size: 12px;
}

/* 手動匯入頁：讓送出按鈕高度與欄位一致 */
.js-import-progress-form .btn[type="submit"] {
    min-height: 38px;
    padding-top: 8px;
    padding-bottom: 8px;
    align-self: center;
}

@keyframes import-progress-slide {
    0% {
        left: -40%;
    }
    100% {
        left: 105%;
    }
}

/* ---------- 18. 登入頁(Figma:上方 Banner + 中央登入卡) ---------- */
.auth-layout--figma {
    min-height: 100vh;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.auth-hero {
    width: 100%;
    overflow: visible;
    border-bottom: 1px solid var(--border);
}

.auth-hero__banner {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.auth-panel {
    flex: 1;
    margin-top: -24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0 16px 24px;
}

.auth-card--figma {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
    width: 100%;
    max-width: 432px;
    padding: 48px 64px;
    margin: 0 auto;

    .form-login {

        .form-group:nth-of-type(1) {
            margin-bottom: -1px;
            
            .form-control {
                border-bottom-left-radius: 0;
                border-bottom-right-radius: 0;
            }
        }

        .form-group:nth-of-type(2) {
            .form-control {
                border-top-left-radius: 0;
                border-top-right-radius: 0;
            }
        }

        .input-with-icon {
            position: relative;
            width: 100%;

            i {
                display: flex;
                align-items: center;
                justify-content: center;
                position: absolute;
                top: 50%;
                left: 12px;
                transform: translateY(-50%);
                width: 20px;
                height: 20px;
                font-size: 20px;
                color: var(--text-lightt, --text-lightt);
                z-index: 10;
                pointer-events: none;
                transition: color var(--transition);
            }

            .form-control {
                padding: var(--padding-nub-md) var(--padding-md);
                padding-left: 2.5rem;
            }

        }
    }
}

.auth-card__brand--figma {
    text-align: center;
    margin-bottom: 16px;
}

.auth-card__brand--figma img,
.auth-card__brand--figma svg {
    max-height: 92px;
    margin: 0 auto;
}

.auth-login-btn {
    width: 100%;
}

.auth-meta {
    margin-top: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-lg);
    line-height: 1.6;
}

.copyright {
    margin-top: var(--padding-nub-vertical);
    text-align: center;
    color: var(--text-lightt);
    font-size: var(--font-size-md);
}

/* 錯誤頁面 */
.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* ---------- 19. 拖拉上傳 ---------- */
.upload-box {
    border: 1px dashed var(--input-border);
    border-radius: var(--radius-md);
    padding: var(--card-padding);
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    height: 15rem;

}
.upload-box:hover,
.upload-box.is-dragover {
    background: color-mix(in srgb, var(--bg-hover) 20%, transparent);
}
.upload-box__placeholder {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #eeeeee;
        height: 100%;

        i {
            font-size: 5rem;
        }
    }
.upload-box__preview {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        vertical-align: middle;
    }
.upload-box__clear {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    width: 24px;
    height: 24px;
    font-size: var(--font-size-xl);
    cursor: pointer;
    color: var(--text-lightt);
    display: flex;
    align-items: center;
    justify-content: center;
}
.upload-box__remove:hover { color: var(--brand-danger); border-color: var(--brand-danger); }

/* ---------- 20. RWD ---------- */
@media (max-width: 768px) {
    :root {
        --content-padding: 16px;
        --card-padding: 16px;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform var(--transition);
        box-shadow: var(--shadow-lg);
    }

    .sidebar__footer {
            form {
                width: auto;
            }
    }

    .app-layout.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-layout.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.4);
        z-index: 99;
    }

    .topbar__breadcrumb {
        display: none;
    }

    form {
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 100%;
    }
    .search-box .form-control {
        width: 100%;
    }
    .btn {
        width: 100%;
    }
    .functionbar__hide {
        display: none;
    }

    .history-filter-field {
        flex-direction: column;

        .form-label {
            padding-top: 0;
        }
    }

    .search-box__btn {
        width: 100%;
    }

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

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

    .site-info-gallery {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    /* .site-info-table__action-col {
        width: 56px;
    } */

    /* .site-design-lightbox .ginner-container {
        padding: 24px 56px 88px;
    } */

    .site-design-lightbox .gbtn.gprev {
        left: 8px;
    }

    .site-design-lightbox .gbtn.gnext {
        right: 8px;
    }

    .site-design-lightbox .gbtn.gclose,
    .site-design-lightbox__meta {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .site-design-lightbox .gbtn.gclose {
        left: auto;
    }

    .history-filter,
    .history-filter-grid--client {
        grid-template-columns: 1fr;
    }

    .history-filter-action {
        justify-content: flex-end;
    }

    .auth-panel {
        margin-top: -14px;
        padding: 0 12px 20px;
    }

    .auth-card--figma {
        max-width: 100%;
    }

    .report-item {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (min-width: 769px) {
    /* 1. 側邊欄收合 */
    .app-layout.sidebar-collapsed .sidebar {
        /* 將整個側邊欄向左拉出畫面之外 */
        margin-left: calc(-1 * var(--sidebar-width, 250px)); 
        opacity: 0; 
        pointer-events: none; 
        visibility: hidden; 
        box-shadow: none;
    }
}

@media (max-width: 1025px) {
    .form-row,
    .form-row--3,
    .form-row--2,
    .form-row--1 {
        grid-template-columns: 1fr;
        gap: var(--padding-nub-md);
        margin-bottom: var(--padding-nub-md);
    }
}

/* 列印樣式 */
@media print {
    .sidebar, .topbar, .footer, .topbar__toggle { display: none !important; }
    .content { padding: 0; }
    .card { box-shadow: none; }
}
