/* ========================================
   YC 租屋管理系統 - 現代化設計系統
   ======================================== */

/* ========== CSS 變數定義 ========== */
:root {
    /* 主色調 */
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #818cf8;
    --on-primary: #ffffff;

    /* 功能色：底色與前景配對皆至少符合 4.5:1 小字對比。 */
    --success: #047857;
    --success-dark: #065f46;
    --on-success: #ffffff;
    --warning: #b45309;
    --warning-dark: #92400e;
    --on-warning: #ffffff;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --on-danger: #ffffff;
    --info: #2563eb;
    --info-dark: #1d4ed8;
    --on-info: #ffffff;

    /* 中性色 */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* 側邊欄 */
    --sidebar-width: 260px;
    --sidebar-bg: linear-gradient(180deg, #1e1e2e 0%, #2d2d3f 100%);

    /* 陰影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* 圓角 */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* 過渡 */
    --transition: all 0.2s ease;
}

/* ========== 基礎重置 ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
}

.skip-link {
    position: fixed;
    z-index: 1000000;
    top: 8px;
    left: 8px;
    padding: 10px 16px;
    border: 2px solid #ffffff;
    border-radius: 8px;
    color: #ffffff;
    background: #111827;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .3);
    font-weight: 800;
    text-decoration: none;
    transform: translateY(calc(-100% - 16px));
    transition: transform .15s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 2px;
    transform: translateY(0);
}

/* ========== 應用容器 ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ========== 側邊欄 ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.sidebar-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
}

.sidebar-nav {
    list-style: none;
    padding: 16px 12px;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 14px;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-nav a.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

/* 選單分區標題 */
.sidebar-nav .nav-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    padding: 16px 16px 8px;
    margin-top: 8px;
    font-weight: 600;
}

.sidebar-nav .nav-section:first-child {
    margin-top: 0;
}

.sidebar-logout {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 16px !important;
}

.sidebar-logout a {
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-logout a:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ========== 主內容區 ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

/* ========== 頁面標題 ========== */
.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 15px;
}

.page-time {
    color: var(--gray-400);
    font-size: 13px;
    margin-top: 4px;
}

/* ========== 卡片 ========== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
    background: var(--gray-50);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.card-body {
    padding: 24px;
}

/* ========== 按鈕 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: var(--on-success);
}

.btn-success:hover {
    background: var(--success-dark);
}

.btn-warning {
    background: var(--warning);
    color: var(--on-warning);
}

.btn-warning:hover {
    background: var(--warning-dark);
}

.btn-danger {
    background: var(--danger);
    color: var(--on-danger);
}

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn-info {
    background: var(--info);
    color: var(--on-info);
}

.btn-info:hover {
    background: var(--info-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* ========== 表單 ========== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: white;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

select.form-control {
    cursor: pointer;
}

.required {
    color: var(--danger);
}

/* ========== 表格 ========== */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.data-table th,
.data-table td {
    padding: 16px 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
    white-space: nowrap;
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

/* 表格內按鈕緊湊排列 */
.data-table .btn {
    padding: 6px 10px;
    font-size: 12px;
    margin: 2px;
}

.data-table .action-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ========== 徽章 ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.badge-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ========== 提示訊息 ========== */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #1e40af;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ========== Grid 系統 ========== */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

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

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ========== 統計卡片 ========== */
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-label {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ========== 空狀態 ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state .message {
    font-size: 18px;
    margin-bottom: 8px;
}

/* ========== 手機選單按鈕 ========== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius);
    background: var(--gray-800);
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    transition: var(--transition);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* ========== 響應式設計 ========== */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .chart-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body.mobile-menu-open {
        overflow: hidden;
    }


    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 80px 16px 24px;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    .app-container {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 20px;
    }

    .page-subtitle {
        font-size: 13px;
    }

    /* 表格響應式容器 */
    .table-responsive,
    .table-wrapper {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 16px;
    }

    .data-table,
    .expense-table,
    .user-table {
        min-width: 600px;
        /* Ensure content forces scroll instead of squishing */
    }

    .data-table th,
    .data-table td,
    .expense-table th,
    .expense-table td {
        padding: 12px 10px;
        /* Slightly more touch-friendly vertical padding */
        font-size: 13px;
        white-space: nowrap;
    }

    /* 統計卡片 */
    .stats-grid,
    .summary-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .stat-box,
    .stat-card,
    .summary-card {
        padding: 14px;
    }

    .stat-box .value,
    .stat-card .stat-value,
    .summary-card .value {
        font-size: 18px;
    }

    .stat-box .label,
    .stat-card .stat-label,
    .summary-card .label {
        font-size: 11px;
    }

    .grid-4 {
        grid-template-columns: 1fr !important;
    }

    /* 圖表 */
    .chart-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .chart-card {
        padding: 16px;
    }

    /* 篩選欄 */
    .filter-bar {
        flex-direction: column;
        padding: 16px;
    }

    .filter-bar form {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .filter-group {
        width: 100%;
    }

    /* 表單 */
    .expense-form {
        padding: 16px;
    }

    .expense-form>div[style*="grid"] {
        grid-template-columns: 1fr !important;
    }

    /* 報表頁面 */
    .report-header {
        flex-direction: column;
        gap: 12px;
    }

    .export-btn {
        width: 100%;
        text-align: center;
    }

    /* 彈出視窗 */
    .modal-content,
    .modal {
        width: 95% !important;
        max-width: none;
        margin: 10px;
    }
}

@media (max-width: 480px) {

    .stats-grid,
    .summary-grid,
    .grid-4 {
        grid-template-columns: 1fr !important;
    }

    .stat-box .value,
    .stat-card .stat-value,
    .summary-card .value {
        font-size: 16px;
    }

    .main-content {
        padding: 70px 12px 20px;
    }

    .page-title {
        font-size: 18px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ========== 滾動條樣式 ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ========== 實用類別 ========== */
.text-center {
    text-align: center;
}

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

.text-muted {
    color: var(--gray-500);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.mt-0 {
    margin-top: 0;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

/* ========== 帳單卡片 ========== */
.bill-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
}

.bill-card .year-month {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.bill-card .details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.bill-card .detail-item {
    background: var(--gray-50);
    padding: 16px;
    border-radius: var(--radius);
}

.bill-card .detail-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.bill-card .detail-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.bill-card .total {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    text-align: right;
}

@media (max-width: 640px) {
    .admin-bill-card {
        padding: 16px;
        border-radius: 12px;
    }

    .admin-bill-card-header {
        align-items: stretch !important;
        flex-direction: column;
        gap: 10px;
    }

    .admin-bill-card .details {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .admin-bill-card .detail-item {
        padding: 14px;
    }

    .admin-bill-actions,
    .admin-bill-actions > form {
        width: 100%;
    }

    .admin-bill-actions > form,
    .admin-bill-actions > form[style*="display: flex"] {
        align-items: stretch !important;
        flex-direction: column;
    }

    .admin-bill-actions .form-control,
    .admin-bill-actions .btn,
    .admin-bill-actions > a {
        width: 100% !important;
    }
}

/* ========== 公告卡片 ========== */
.announcement-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.announcement-card:hover {
    box-shadow: var(--shadow);
}

.announcement-card .title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

.announcement-card .meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--gray-500);
}

.announcement-card .content {
    margin-top: 12px;
    color: var(--gray-600);
    line-height: 1.7;
}

/* ========== 時間顯示 ========== */
.current-time::before {
    content: '';
}

/* ========== JavaScript 控制的動態樣式 ========== */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== 登入視角橫幅 ========== */
.impersonation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 10000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    font-size: 14px;
}

.impersonation-banner .return-btn {
    background: white;
    color: #7c3aed;
    padding: 6px 16px;
    border-radius: 6px;
    text-decoration: none;
    font: inherit;
    font-weight: 600;
    border: 0;
    cursor: pointer;
    transition: all 0.2s;
}

.impersonation-banner form {
    margin: 0;
}

.impersonation-banner .return-btn:hover {
    transform: scale(1.05);
}

body.impersonating {
    padding-top: 48px !important;
}

/* ========== 管理員導航按鈕狀態 ========== */
@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.nav-btn-pulse {
    animation: pulse-red 2s infinite;
    background: linear-gradient(135deg, #ef4444, #b91c1c) !important;
    color: white !important;
    border: none !important;
    font-weight: bold !important;
}

.nav-btn-dimmed {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f5f9;
    color: #94a3b8;
}

.nav-btn-dimmed:hover {
    background: #f1f5f9 !important;
    color: #94a3b8 !important;
    transform: none !important;
}

/* ========== 全域提醒橫幅 ========== */
@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
    }

    50% {
        box-shadow: 0 2px 20px rgba(245, 158, 11, 0.5);
    }
}

.global-alert-banner {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    animation: slideDown 0.4s ease-out, pulse-glow 2s ease-in-out infinite;
    flex-wrap: wrap;
}

.global-alert-banner.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.global-alert-banner.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    animation: slideDown 0.4s ease-out;
}

.alert-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.alert-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.alert-text {
    font-size: 14px;
    font-weight: 500;
}

.alert-text strong {
    font-weight: 700;
}

.alert-action {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    min-height: 44px;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.alert-action:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .global-alert-banner {
        padding: 12px 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .alert-action {
        text-align: center;
    }
}

/* ========== 使用者續約脈搏動畫 ========== */
@keyframes renewalPulse {

    0%,
    100% {
        background: linear-gradient(135deg, var(--success), var(--success-dark));
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    50% {
        background: linear-gradient(135deg, var(--success-dark), var(--success));
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
}

.renewal-pulse {
    animation: renewalPulse 1.5s ease-in-out infinite !important;
    background: linear-gradient(135deg, var(--success), var(--success-dark)) !important;
    color: var(--on-success) !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
}

.renewal-pulse:hover {
    animation: none !important;
    background: linear-gradient(135deg, var(--success-dark), var(--success)) !important;
    transform: scale(1.02);
}

/* ========== 側邊欄特殊連結樣式 ========== */
.sidebar-nav .nav-link-danger:not(.active) {
    color: #fca5a5;
}

.sidebar-nav .nav-link-danger:hover {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.15);
}

.sidebar-nav .nav-link-moveout {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    border-radius: 8px;
    margin: 4px 8px;
    color: white !important;
}

.sidebar-nav .nav-link-moveout:hover {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
    color: white !important;
}

/* ========== 快速連結卡片 (使用者首頁) ========== */
.quick-links {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.quick-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    background: white;
    border-radius: 16px;
    text-decoration: none;
    color: var(--gray-800);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    border: 1px solid var(--gray-100);
}

.quick-link:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.quick-link .icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.quick-link .label {
    font-weight: 600;
    font-size: 14px;
}

@media (max-width: 768px) {
    .quick-links {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .quick-links {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .quick-link {
        padding: 16px 12px;
    }

    .quick-link .icon {
        font-size: 28px;
        margin-bottom: 8px;
    }

    .quick-link .label {
        font-size: 13px;
    }
}

/* ========== 使用者側邊欄主題色 ========== */
.sidebar-user {
    background: linear-gradient(180deg, #164e63 0%, #0e7490 100%);
}

.sidebar-user .sidebar-nav a.active {
    background: #06b6d4;
}

.sidebar-user .sidebar-nav a:hover {
    background: rgba(6, 182, 212, 0.3);
}

.sidebar-user~.mobile-menu-toggle,
.sidebar-user-toggle {
    background: #164e63;
}

/* ========== 統計卡片色彩變體 ========== */
.stat-card-danger {
    border-left-color: var(--danger);
}

.stat-card-danger .stat-value {
    color: var(--danger);
}

.stat-card-success {
    border-left-color: var(--success);
}

.stat-card-success .stat-value {
    color: var(--success);
}

.stat-card-warning {
    border-left-color: var(--warning);
}

.stat-card-warning .stat-value {
    color: var(--warning);
}

.stat-card-primary {
    border-left-color: var(--primary);
}

.stat-card-primary .stat-value {
    color: var(--primary);
}

.stat-card-info {
    border-left-color: var(--info);
}

.stat-card-info .stat-value {
    color: var(--info);
}

.stat-card .stat-action {
    margin-top: 8px;
}

/* ========== 租客任務導向體驗 ========== */
.tenant-app {
    --tenant-ink: #12323a;
    --tenant-muted: #62777d;
    --tenant-border: #dfeaec;
    --tenant-soft: #f2f8f8;
    --tenant-brand: #0e7490;
    --tenant-brand-dark: #164e63;
    --tenant-nav-muted: #536970;
    background: #f5f9f9;
}

.tenant-dashboard {
    width: min(100%, 1440px);
    margin: 0 auto;
}

.tenant-hero {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 32px;
    align-items: center;
    overflow: hidden;
    padding: 38px 40px;
    margin-bottom: 28px;
    color: white;
    border-radius: 24px;
    background:
        radial-gradient(circle at 82% 12%, rgba(103, 232, 249, .22), transparent 34%),
        linear-gradient(135deg, #083344 0%, #155e75 58%, #0e7490 100%);
    box-shadow: 0 18px 50px rgba(8, 51, 68, .18);
}

.tenant-hero::after {
    content: '';
    position: absolute;
    z-index: -1;
    right: -60px;
    bottom: -100px;
    width: 260px;
    height: 260px;
    border: 46px solid rgba(255, 255, 255, .07);
    border-radius: 50%;
}

.tenant-hero-kicker,
.tenant-section-kicker {
    margin: 0 0 7px;
    color: #0e7490;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .08em;
}

.tenant-hero-kicker {
    color: #a5f3fc;
}

.tenant-hero h1 {
    margin: 0 0 10px;
    color: white;
    font-size: clamp(27px, 3vw, 40px);
    line-height: 1.22;
    letter-spacing: -.02em;
}

.tenant-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.tenant-btn-primary {
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid transparent;
    font-weight: 700;
}

.tenant-btn-primary {
    background: white;
    color: #0e596d;
    box-shadow: 0 8px 24px rgba(3, 26, 34, .18);
}

.tenant-btn-primary:hover {
    color: #083344;
    background: #ecfeff;
    transform: translateY(-1px);
}

.tenant-hero-summary {
    min-width: 0;
    padding: 22px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 18px;
    background: rgba(255, 255, 255, .1);
    backdrop-filter: blur(10px);
}

.tenant-hero-summary-label {
    margin-bottom: 8px;
    color: #a5f3fc;
    font-size: 12px;
    font-weight: 700;
}

.tenant-hero-summary strong {
    display: block;
    overflow-wrap: anywhere;
    color: white;
    font-size: 17px;
    line-height: 1.5;
}

.tenant-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.tenant-hero-meta span {
    padding: 4px 9px;
    border-radius: 999px;
    color: rgba(255, 255, 255, .9);
    background: rgba(255, 255, 255, .12);
    font-size: 12px;
}

.tenant-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 370px);
    gap: 28px;
    align-items: start;
}

.tenant-dashboard-main,
.tenant-dashboard-aside {
    min-width: 0;
}

.tenant-dashboard-aside {
    position: sticky;
    top: 24px;
}

.tenant-panel {
    margin-bottom: 24px;
    padding: 24px;
    border: 1px solid var(--tenant-border);
    border-radius: 20px;
    background: white;
    box-shadow: 0 7px 25px rgba(24, 68, 78, .06);
}

.tenant-panel-heading,
.tenant-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.tenant-panel-heading h2,
.tenant-section-heading h2 {
    margin: 0;
    color: var(--tenant-ink);
    font-size: 20px;
    line-height: 1.35;
}

.tenant-count-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 4px 11px;
    border-radius: 999px;
    color: #0e7490;
    background: #ecfeff;
    font-size: 12px;
    font-weight: 750;
}

.tenant-task-list {
    display: grid;
    gap: 11px;
}

.tenant-task {
    --task-color: #0e7490;
    --task-bg: #f0f9fa;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    min-width: 0;
    padding: 15px 16px;
    color: var(--tenant-ink);
    text-decoration: none;
    border: 1px solid #e1ebed;
    border-left: 4px solid var(--task-color);
    border-radius: 15px;
    background: white;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.tenant-task:hover {
    color: var(--tenant-ink);
    border-color: color-mix(in srgb, var(--task-color) 42%, white);
    box-shadow: 0 9px 25px rgba(24, 68, 78, .09);
    transform: translateY(-1px);
}

.tenant-task--danger { --task-color: #dc2626; --task-bg: #fef2f2; }
.tenant-task--warning { --task-color: #d97706; --task-bg: #fffbeb; }
.tenant-task--success { --task-color: #059669; --task-bg: #ecfdf5; }
.tenant-task--info { --task-color: #2563eb; --task-bg: #eff6ff; }
.tenant-task--primary { --task-color: #0e7490; --task-bg: #ecfeff; }

.tenant-task-icon {
    display: grid;
    place-items: center;
    width: 43px;
    height: 43px;
    border-radius: 13px;
    color: var(--task-color);
    background: var(--task-bg);
    font-size: 20px;
}

.tenant-task-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.tenant-task-copy strong {
    overflow-wrap: anywhere;
    color: var(--tenant-ink);
    font-size: 15px;
    line-height: 1.45;
}

.tenant-task-copy > span:last-child {
    margin-top: 2px;
    color: var(--tenant-muted);
    font-size: 12px;
}

.tenant-task-eyebrow {
    color: var(--task-color);
    font-size: 11px;
    font-weight: 750;
}

.tenant-task-action {
    color: var(--task-color);
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.tenant-all-clear {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    border: 1px solid #bbf7d0;
    border-radius: 15px;
    color: #14532d;
    background: #f0fdf4;
}

.tenant-all-clear-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 50%;
    color: white;
    background: #16a34a;
    font-size: 20px;
    font-weight: 800;
}

.tenant-all-clear p {
    margin: 2px 0 0;
    color: #4b7b5b;
    font-size: 13px;
}

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

.tenant-service-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 13px;
    align-items: center;
    min-width: 0;
    min-height: 88px;
    padding: 15px;
    color: var(--tenant-ink);
    text-decoration: none;
    border: 1px solid var(--tenant-border);
    border-radius: 16px;
    background: white;
    box-shadow: 0 4px 16px rgba(24, 68, 78, .04);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.tenant-service-card:hover {
    color: var(--tenant-ink);
    border-color: #9fd4dc;
    box-shadow: 0 9px 24px rgba(24, 68, 78, .08);
    transform: translateY(-2px);
}

.tenant-service-card > span:nth-child(2) {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.tenant-service-card strong {
    font-size: 14px;
}

.tenant-service-card small {
    overflow-wrap: anywhere;
    margin-top: 2px;
    color: var(--tenant-muted);
    font-size: 11px;
    line-height: 1.45;
}

.tenant-service-card > span:last-child {
    color: #91a8ad;
}

.tenant-service-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    font-size: 14px;
    font-weight: 800;
}

.tenant-service-icon--cyan { color: #0e7490; background: #ecfeff; }
.tenant-service-icon--amber { color: #b45309; background: #fffbeb; }
.tenant-service-icon--rose { color: #be123c; background: #fff1f2; }
.tenant-service-icon--blue { color: #1d4ed8; background: #eff6ff; }
.tenant-service-icon--violet { color: #6d28d9; background: #f5f3ff; }
.tenant-service-icon--green { color: #047857; background: #ecfdf5; }

.tenant-more-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 16px 2px 0;
}

.tenant-more-links a,
.tenant-text-link {
    color: #0e7490;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.tenant-more-links a:hover,
.tenant-text-link:hover {
    color: #155e75;
    text-decoration: underline;
}

.tenant-home-details {
    display: grid;
    gap: 0;
}

.tenant-home-details > div {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 12px;
    padding: 13px 0;
    border-top: 1px solid #edf2f3;
}

.tenant-home-details dt {
    color: var(--tenant-muted);
    font-size: 12px;
}

.tenant-home-details dd {
    overflow-wrap: anywhere;
    color: var(--tenant-ink);
    font-size: 13px;
    font-weight: 650;
    text-align: right;
}

.tenant-news-list {
    display: grid;
}

.tenant-news-item {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: 14px 0;
    color: var(--tenant-ink);
    text-decoration: none;
    border-top: 1px solid #edf2f3;
}

.tenant-news-item:hover strong {
    color: #0e7490;
}

.tenant-news-item strong {
    overflow-wrap: anywhere;
    margin: 3px 0;
    font-size: 14px;
    line-height: 1.45;
}

.tenant-news-item > span:last-child {
    display: -webkit-box;
    overflow: hidden;
    color: var(--tenant-muted);
    font-size: 12px;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.tenant-news-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #8a9ca0;
    font-size: 11px;
}

.tenant-pin {
    padding: 2px 6px;
    color: #b45309;
    border-radius: 999px;
    background: #fef3c7;
    font-size: 10px;
    font-weight: 800;
}

.tenant-empty-copy {
    padding: 18px 0 4px;
    color: var(--tenant-muted);
    font-size: 13px;
}

.tenant-mobile-app-bar,
.tenant-bottom-nav {
    display: none;
}

@media (max-width: 1120px) {
    .tenant-dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .tenant-dashboard-aside {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px;
    }

    .tenant-dashboard-aside .tenant-panel {
        margin-bottom: 0;
    }
}

@media (max-width: 768px) {
    .tenant-app .main-content {
        padding-top: 74px;
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    .tenant-app .sidebar-user-toggle {
        top: 11px;
        right: 12px;
        left: auto;
        width: 42px;
        height: 42px;
        border-radius: 12px;
        background: #155e75;
        box-shadow: 0 5px 18px rgba(8, 51, 68, .2);
    }

    .tenant-mobile-app-bar {
        position: fixed;
        z-index: 990;
        top: 0;
        right: 0;
        left: 0;
        display: flex;
        min-height: 64px;
        padding: 9px 68px 9px 16px;
        flex-direction: column;
        justify-content: center;
        border-bottom: 1px solid #dce8ea;
        background: rgba(255, 255, 255, .94);
        box-shadow: 0 4px 18px rgba(24, 68, 78, .06);
        backdrop-filter: blur(14px);
    }

    .tenant-mobile-brand {
        color: #0e7490;
        font-size: 11px;
        font-weight: 800;
        letter-spacing: .06em;
    }

    .tenant-mobile-page {
        overflow: hidden;
        color: var(--tenant-ink);
        font-size: 15px;
        font-weight: 750;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tenant-bottom-nav {
        position: fixed;
        z-index: 990;
        right: 0;
        bottom: 0;
        left: 0;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        min-height: calc(66px + env(safe-area-inset-bottom));
        padding: 5px 5px env(safe-area-inset-bottom);
        border-top: 1px solid #dce8ea;
        background: rgba(255, 255, 255, .97);
        box-shadow: 0 -8px 24px rgba(24, 68, 78, .08);
        backdrop-filter: blur(16px);
    }

    .tenant-bottom-nav a,
    .tenant-bottom-nav button {
        display: flex;
        min-width: 0;
        min-height: 58px;
        padding: 5px 2px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--tenant-nav-muted);
        border: 0;
        border-radius: 12px;
        background: transparent;
        font: inherit;
        font-size: 10px;
        font-weight: 700;
        text-decoration: none;
    }

    .tenant-bottom-nav a.active {
        color: #0e7490;
        background: #ecfeff;
    }

    .tenant-bottom-nav svg {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .tenant-app .site-footer {
        padding-bottom: calc(90px + env(safe-area-inset-bottom));
    }

    .tenant-hero {
        grid-template-columns: minmax(0, 1fr);
        gap: 22px;
        padding: 25px 22px;
        border-radius: 20px;
    }

    .tenant-hero-summary {
        padding: 17px;
    }

    .tenant-dashboard-grid {
        gap: 22px;
    }

    .tenant-dashboard-aside {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .tenant-dashboard-aside .tenant-panel {
        margin-bottom: 20px;
    }

    .tenant-panel {
        padding: 19px;
        border-radius: 17px;
    }

    .tenant-panel-heading h2,
    .tenant-section-heading h2 {
        font-size: 18px;
    }

    .tenant-task {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .tenant-task-action {
        grid-column: 2;
    }
}

@media (max-width: 520px) {
    .tenant-service-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .tenant-hero-actions .btn {
        width: 100%;
    }

    .tenant-task {
        gap: 11px;
        padding: 14px;
    }

    .tenant-task-icon {
        width: 39px;
        height: 39px;
        font-size: 17px;
    }
}

/* 鍵盤操作與減少動態效果偏好 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(6, 182, 212, .42);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ========== 管理端一致化導覽與版面 ========== */
.admin-app {
    --admin-nav-muted: #5c687e;
    background: #f6f8fb;
}

.admin-app .sidebar {
    background: linear-gradient(180deg, #172033 0%, #25334d 100%);
}

.admin-app .sidebar-nav a.active {
    background: #4f46e5;
}

.admin-app .main-content {
    background: #f6f8fb;
}

.admin-app .card,
.admin-app .stat-card {
    border: 1px solid #e5e9f0;
    box-shadow: 0 7px 24px rgba(30, 41, 59, .055);
}

.admin-app .card-header {
    background: #fafbfc;
}

.admin-mobile-app-bar,
.admin-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .admin-app .main-content {
        padding-top: 74px;
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    .admin-app .mobile-menu-toggle {
        top: 11px;
        right: 12px;
        left: auto;
        width: 42px;
        height: 42px;
        border-radius: 12px;
        background: #3730a3;
        box-shadow: 0 5px 18px rgba(30, 27, 75, .2);
    }

    .admin-mobile-app-bar {
        position: fixed;
        z-index: 990;
        top: 0;
        right: 0;
        left: 0;
        display: flex;
        min-height: 64px;
        padding: 9px 68px 9px 16px;
        flex-direction: column;
        justify-content: center;
        border-bottom: 1px solid #e1e5ec;
        background: rgba(255, 255, 255, .95);
        box-shadow: 0 4px 18px rgba(30, 41, 59, .06);
        backdrop-filter: blur(14px);
    }

    .admin-mobile-brand {
        color: #4f46e5;
        font-size: 11px;
        font-weight: 800;
        letter-spacing: .06em;
    }

    .admin-mobile-page {
        overflow: hidden;
        color: #172033;
        font-size: 15px;
        font-weight: 750;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .admin-bottom-nav {
        position: fixed;
        z-index: 990;
        right: 0;
        bottom: 0;
        left: 0;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        min-height: calc(66px + env(safe-area-inset-bottom));
        padding: 5px 5px env(safe-area-inset-bottom);
        border-top: 1px solid #e1e5ec;
        background: rgba(255, 255, 255, .97);
        box-shadow: 0 -8px 24px rgba(30, 41, 59, .08);
        backdrop-filter: blur(16px);
    }

    .admin-bottom-nav a,
    .admin-bottom-nav button {
        display: flex;
        min-width: 0;
        min-height: 58px;
        padding: 5px 2px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--admin-nav-muted);
        border: 0;
        border-radius: 12px;
        background: transparent;
        font: inherit;
        font-size: 10px;
        font-weight: 700;
        text-decoration: none;
    }

    .admin-bottom-nav a.active {
        color: #4f46e5;
        background: #eef2ff;
    }

    .admin-bottom-nav svg {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .admin-app .site-footer {
        padding-bottom: calc(90px + env(safe-area-inset-bottom));
    }
}

/* ========== 卡片標頭 flex 佈局 ========== */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header-flex .card-title {
    margin: 0;
}

/* ========== 置頂徽章 ========== */
.badge-pinned {
    background: #ef4444;
    color: white;
    margin-bottom: 8px;
}

.announcement-pinned {
    border-left-color: #ef4444;
}

/* ========== 側邊欄導航圖示 ========== */
.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-right: 10px;
    opacity: 0.85;
    fill: currentColor;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
}

.sidebar-nav a:hover .nav-icon,
.sidebar-nav a.active .nav-icon {
    opacity: 1;
}

/* ========== 頁面載入淡入 ========== */
.main-content {
    animation: pageEnter 0.35s ease-out;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== 超級管理員工具區 ========== */
.super-admin-section {
    margin-top: 20px;
    border-top: 1px solid #334155;
    padding-top: 20px;
}

.super-admin-section .impersonate-label {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 4px;
    padding: 0 16px;
}

.super-admin-section .impersonate-wrapper {
    padding: 0 20px;
}

/* ========== Toast 自動消失提示 ========== */
.alert-toast {
    position: relative;
    padding-right: 60px;
    animation: slideDown 0.4s ease-out;
    overflow: hidden;
}

.alert-toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.15);
    animation: toastTimer 6s linear forwards;
}

.alert-toast.is-paused::after {
    animation-play-state: paused;
}

.alert-toast-close {
    position: absolute;
    z-index: 1;
    top: 50%;
    right: 10px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: inherit;
    background: rgba(255, 255, 255, .72);
    font: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transform: translateY(-50%);
}

.alert-toast-close:hover,
.alert-toast-close:focus-visible {
    background: rgba(255, 255, 255, .95);
}

@keyframes toastTimer {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

.alert-toast.fade-out {
    animation: toastFadeOut 0.3s ease-in forwards;
}

@keyframes toastFadeOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

/* ========== 租金狀態頁 stat icon ========== */
.stat-box .stat-emoji {
    font-size: 28px;
    margin-bottom: 8px;
    line-height: 1;
}

/* ========== 行動端側邊欄滑動關閉 ========== */
@media (max-width: 768px) {
    .sidebar {
        will-change: transform;
    }

    .sidebar.swiping {
        transition: none !important;
    }
}

/* ========== 可折疊導航群組 ========== */
.nav-group-toggle {
    position: relative;
    cursor: pointer;
}

.nav-group-arrow {
    margin-left: auto;
    transition: transform 0.25s ease;
    opacity: 0.6;
    flex-shrink: 0;
}

.nav-group-toggle.open .nav-group-arrow {
    transform: rotate(180deg);
}

.nav-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-group-items.open {
    max-height: 200px;
}

.nav-group-items a {
    padding: 8px 20px 8px 50px !important;
    font-size: 13px;
    opacity: 0.85;
}

.nav-group-items a:hover,
.nav-group-items a.active {
    opacity: 1;
}

/* ========== Quick Link SVG 圖示 ========== */
.quick-link .icon svg {
    width: 36px;
    height: 36px;
}

@media (max-width: 768px) {
    .quick-link .icon svg {
        width: 28px;
        height: 28px;
    }
}

/* ========== 全站響應式與可及性補強 ========== */
.main-content,
.card,
.card-header,
.card-body,
.grid,
.form-group {
    min-width: 0;
}

img,
video,
canvas {
    max-width: 100%;
    height: auto;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

/* 舊頁面若漏包 table-responsive，仍可在卡片內水平捲動，不撐破版面。 */
.card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.page-title,
.page-subtitle,
.card-title,
.alert,
td,
th {
    overflow-wrap: anywhere;
}

.alert-with-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .main-content {
        padding: 20px 16px;
    }

    .page-header {
        margin-bottom: 20px;
    }

    .page-title {
        font-size: clamp(22px, 7vw, 28px);
        line-height: 1.25;
    }

    .card {
        margin-bottom: 16px;
        border-radius: 10px;
    }

    .card-header,
    .card-body {
        padding: 16px;
    }

    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    form[style*="display: flex"],
    .filter-form,
    .action-group,
    .button-group {
        flex-wrap: wrap;
    }

    form[style*="display: flex"] > *,
    .filter-form > * {
        min-width: min(100%, 220px) !important;
        max-width: 100%;
    }

    .btn,
    button,
    input[type="button"],
    input[type="submit"] {
        min-height: 44px;
    }

    .form-control,
    input,
    select,
    textarea {
        font-size: 16px;
    }

    .modal-content,
    .modal-dialog {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        margin: 12px !important;
        overflow: auto;
    }

    .alert-with-action {
        align-items: stretch;
        flex-direction: column;
    }

    .alert-with-action .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 16px 12px;
    }

    .card-header,
    .card-body {
        padding: 14px;
    }

    .btn {
        white-space: normal;
        text-align: center;
    }
}

/* 可逐頁採用的手機卡片表格：768px 以下統一顯示完整欄位標籤。 */
@media (max-width: 768px) {
    .table-responsive-cards {
        overflow: visible;
    }

    .responsive-card-table,
    .responsive-card-table tbody,
    .responsive-card-table tr,
    .responsive-card-table td {
        display: block;
        width: 100%;
        min-width: 0 !important;
    }

    .responsive-card-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .responsive-card-table tbody {
        display: grid;
        gap: 14px;
    }

    .responsive-card-table tr {
        padding: 6px 14px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
    }

    .responsive-card-table td {
        display: grid;
        grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
        gap: 12px;
        align-items: start;
        max-width: none !important;
        padding: 10px 0 !important;
        border: 0;
        border-bottom: 1px solid #f1f5f9;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .responsive-card-table td:last-child {
        border-bottom: 0;
    }

    .responsive-card-table td::before {
        content: attr(data-label);
        color: #64748b;
        font-size: 13px;
        font-weight: 700;
    }

    .responsive-card-table td > div {
        min-width: 0;
        max-width: 100%;
        white-space: normal !important;
    }
}

/* 雲端硬碟與合約附件：共用、無行內樣式的檔案管理元件。 */
.cloud-drive-page,
.contract-files-page,
.drive-layout,
.attachment-layout,
.drive-primary,
.drive-sidebar,
.attachment-primary,
.attachment-sidebar {
    min-width: 0;
}

.drive-layout,
.attachment-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(270px, 1fr);
    gap: 20px;
}

.drive-card,
.attachment-card {
    min-width: 0;
    margin-bottom: 20px;
    padding: 22px;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #fff;
}

.drive-card h2,
.attachment-card h2 {
    margin: 0 0 12px;
    color: #0f172a;
    font-size: 20px;
}

.drive-toolbar,
.drive-inline-form,
.drive-actions,
.attachment-actions {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.drive-inline-form > div {
    min-width: min(100%, 210px);
}

.drive-items,
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.drive-item {
    min-width: 0;
    padding: 15px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
}

a.drive-item {
    color: inherit;
    text-decoration: none;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

a.drive-item:hover,
a.drive-item:focus-visible {
    border-color: #818cf8;
    box-shadow: 0 8px 24px rgba(79, 70, 229, .12);
    transform: translateY(-1px);
}

a.drive-item:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}

.drive-name {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: #1e293b;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.drive-folder-icon {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    fill: #4f46e5;
}

.drive-meta {
    margin: 7px 0;
    color: #536170;
    font-size: 12px;
    line-height: 1.7;
}

.drive-upload-panel,
.attachment-drop {
    margin-top: 20px;
    padding: 18px;
    border: 2px dashed #93c5fd;
    border-radius: 14px;
    background: #eff6ff;
}

.drive-help,
.drive-state-note,
.attachment-state-note,
.drive-request-summary {
    margin: 7px 0 0;
    color: #536170;
    font-size: 13px;
    line-height: 1.6;
}

.drive-state-note,
.attachment-state-note {
    color: #7c3f00;
}

.drive-submit,
.attachment-submit {
    margin-top: 12px;
}

.storage-status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    margin-top: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
}

.storage-status--available {
    background: #dcfce7;
    color: #166534;
}

.storage-status--pending {
    background: #fef3c7;
    color: #78350f;
}

.storage-status--blocked {
    background: #fee2e2;
    color: #991b1b;
}

.drive-actions {
    align-items: center;
    margin-top: 10px;
}

.drive-actions form,
.attachment-actions form {
    margin: 0;
}

.drive-rename-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    width: 100%;
}

.drive-rename-form .form-control {
    min-width: 0;
}

.drive-empty,
.attachment-empty,
.drive-muted {
    color: #536170;
}

.drive-empty {
    grid-column: 1 / -1;
}

.drive-capacity-value {
    color: #0f172a;
    font-size: 24px;
    font-weight: 900;
}

.drive-capacity-value--unlimited {
    color: #166534;
    font-size: 25px;
}

progress.drive-meter {
    appearance: none;
    display: block;
    width: 100%;
    height: 10px;
    margin: 12px 0;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: #e2e8f0;
}

progress.drive-meter::-webkit-progress-bar {
    border-radius: 999px;
    background: #e2e8f0;
}

progress.drive-meter::-webkit-progress-value {
    border-radius: 999px;
    background: linear-gradient(90deg, #2563eb, #6d28d9);
}

progress.drive-meter::-moz-progress-bar {
    border-radius: 999px;
    background: linear-gradient(90deg, #2563eb, #6d28d9);
}

.drive-copy,
.attachment-copy {
    color: #475569;
    line-height: 1.75;
}

.drive-form-spaced {
    margin-top: 12px;
}

.drive-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.drive-table {
    width: 100%;
    border-collapse: collapse;
}

.drive-table caption.drive-table-caption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.drive-table th,
.drive-table td {
    padding: 11px 9px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

.drive-table th {
    color: #475569;
    font-size: 12px;
}

.drive-table-actions {
    min-width: 260px;
}

.drive-table-note {
    display: block;
    margin-top: 6px;
    color: #536170;
    line-height: 1.5;
}

.drive-stack-form {
    display: grid;
    gap: 7px;
    width: 100%;
    margin-top: 10px;
}

.drive-field-label {
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.drive-narrow-field {
    max-width: 150px;
}

.drive-removed {
    color: #991b1b;
    font-size: 12px;
}

.drive-filter-form {
    align-items: end;
    margin: 0 0 14px;
}

.drive-filter-form .form-label {
    margin: 0;
}

.drive-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    color: #475569;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.drive-pagination > span {
    overflow-wrap: anywhere;
}

.attachment-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.attachment-item {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #fff;
}

.attachment-preview {
    display: grid;
    place-items: center;
    height: 150px;
    background: #f8fafc;
    color: #475569;
}

.attachment-preview img,
.attachment-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-preview-state {
    padding: 12px;
    color: #78350f;
    font-size: 16px;
    font-weight: 800;
    text-align: center;
}

.attachment-document-icon {
    width: 42px;
    height: 42px;
    fill: none;
    stroke: #475569;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.attachment-body {
    padding: 14px;
}

.attachment-name {
    min-height: 42px;
    color: #1e293b;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.attachment-meta {
    margin: 8px 0 12px;
    color: #536170;
    font-size: 12px;
}

.attachment-file-input {
    padding: 12px;
    background: #fff;
}

.attachment-actions {
    align-items: center;
    margin-top: 10px;
}

.attachment-rescan-form {
    display: grid;
    width: 100%;
}

.attachment-capacity {
    color: #166534;
    font-weight: 800;
}

.attachment-back-link {
    width: 100%;
    justify-content: center;
}

@media (max-width: 900px) {
    .drive-layout,
    .attachment-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 768px) {
    .drive-card,
    .attachment-card {
        padding: 16px;
        border-radius: 14px;
    }

    .drive-items,
    .attachment-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .drive-inline-form > div,
    .drive-inline-form > .btn,
    .drive-rename-form,
    .drive-actions > .btn,
    .drive-actions > form,
    .drive-actions > form .btn,
    .attachment-actions > .btn,
    .attachment-actions > form,
    .attachment-actions > form .btn {
        width: 100%;
        max-width: none;
    }

    .drive-rename-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .drive-narrow-field {
        max-width: none;
    }

    .drive-table-actions {
        min-width: 0;
    }

    .drive-filter-form,
    .drive-filter-form > .form-label,
    .drive-filter-form > .form-control,
    .drive-filter-form > .btn {
        width: 100%;
        max-width: none;
    }

    .drive-pagination .btn {
        min-width: 112px;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .drive-upload-panel,
    .attachment-drop {
        padding: 14px;
    }
}

/* 共用本機載入提示，避免正式表單依賴外部彈窗套件。 */
.page-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .58);
    backdrop-filter: blur(3px);
}

.page-loading-overlay[hidden] {
    display: none;
}

.page-loading-card {
    display: grid;
    justify-items: center;
    gap: 8px;
    width: min(100%, 260px);
    padding: 24px;
    border-radius: 14px;
    background: #fff;
    color: #0f172a;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .25);
}

.page-loading-card > span:last-child {
    color: #64748b;
    font-size: 14px;
}

.page-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #cbd5e1;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: pageLoadingSpin .7s linear infinite;
}

@keyframes pageLoadingSpin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .page-loading-spinner { animation-duration: 1.5s; }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
/* 房東介面：清楚文字、大型操作目標與穩定焦點。 */
body.simple-manager-app {
    color: #172033;
    font-size: 18px;
    line-height: 1.65;
}

body.simple-manager-app .sidebar {
    background: #172033;
}

body.simple-manager-app .sidebar-subtitle,
body.simple-manager-app .sidebar-nav .nav-section {
    font-size: 15px;
}

body.simple-manager-app .sidebar-nav a {
    min-height: 56px;
    padding: 14px 18px;
    font-size: 18px;
}

body.simple-manager-app .page-title {
    font-size: clamp(29px, 4vw, 38px);
}

body.simple-manager-app .page-subtitle,
body.simple-manager-app .form-label,
body.simple-manager-app label,
body.simple-manager-app .stat-label {
    font-size: 17px;
}

body.simple-manager-app input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
body.simple-manager-app select,
body.simple-manager-app textarea,
body.simple-manager-app .btn,
body.simple-manager-app button,
body.simple-manager-app .quick-nav-btn {
    min-height: 52px;
    font-size: 18px;
}

body.simple-manager-app .btn,
body.simple-manager-app button,
body.simple-manager-app .quick-nav-btn {
    padding: 12px 18px;
}

body.simple-manager-app .responsive-card-table,
body.simple-manager-app .admin-bill-card {
    font-size: 17px;
}

body.simple-manager-app .tenant-details span,
body.simple-manager-app .paid-info .meta,
body.simple-manager-app .property-info .floor,
body.simple-manager-app .due-date-cell .days,
body.simple-manager-app small,
body.simple-manager-app [role="status"] {
    font-size: 15px !important;
}

body.simple-manager-app a:focus-visible,
body.simple-manager-app button:focus-visible,
body.simple-manager-app input:focus-visible,
body.simple-manager-app select:focus-visible,
body.simple-manager-app textarea:focus-visible {
    outline: 4px solid #f59e0b;
    outline-offset: 3px;
}

body.simple-manager-app .admin-bottom-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

body.simple-manager-app .admin-bottom-nav a {
    min-height: 62px;
    font-size: 15px;
    font-weight: 750;
}

@media (max-width: 768px) {
    body.simple-manager-app .main-content {
        padding-inline: 14px;
    }
}
