@media (max-width: 768px) {
    header {
        padding: 24px 16px;
    }

    header h1 {
        font-size: 24px;
        margin-bottom: 4px;
    }

    header p {
        font-size: 12px;
    }

    .scheduler-notice {
        margin: 12px 16px 0;
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .night-query-card {
        flex-direction: column;
        align-items: flex-start;
    }

    main {
        grid-template-columns: 1fr;
        padding: 20px 16px 100px;
        gap: 16px;
    }

    main.auth-only {
        padding: 16px 12px;
    }

    aside {
        padding: 16px;
        gap: 12px;
        max-height: 400px;
    }

    .panels-stack {
        gap: 16px;
    }

    .panel {
        padding: 16px;
        gap: 12px;
        border-radius: 16px;
    }

    .panel-header {
        padding-bottom: 12px;
        gap: 8px;
    }

    .panel-header h2 {
        font-size: 16px;
    }

    .history-table {
        font-size: 12px;
        overflow-x: auto;
    }

    .history-table th,
    .history-table td {
        padding: 8px;
        white-space: nowrap;
    }

    .table-wrapper {
        padding: 12px;
        border-radius: 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-controls {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 8px;
        flex-wrap: wrap;
    }

    .detail-toolbar {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .detail-toolbar-group {
        width: 100%;
        justify-content: space-between;
    }

    .page-size-control {
        width: 100%;
        justify-content: space-between;
    }

    .table-pager {
        width: 100%;
        justify-content: space-between;
    }

    .btn {
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 8px;
        min-height: 44px;
        justify-content: center;
    }

    input,
    select,
    textarea {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 14px;
    }

    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 3px rgba(75, 123, 236, 0.1);
    }

    details summary {
        min-height: 44px;
        padding: 8px 12px;
    }

    #detailTablePanel {
        margin-top: 8px !important;
    }

    .table-title {
        font-size: 12px;
    }

    #settingsPanel {
        bottom: max(16px, env(safe-area-inset-bottom, 0px));
        right: max(16px, env(safe-area-inset-right, 0px));
        width: calc(100% - max(32px, env(safe-area-inset-right, 0px) * 2));
        padding: 20px;
    }

    #userSettingsPanel {
        bottom: max(16px, env(safe-area-inset-bottom, 0px));
        right: max(16px, env(safe-area-inset-right, 0px));
        width: calc(100% - max(32px, env(safe-area-inset-right, 0px) * 2));
        padding: 20px;
    }

    #businessLoginPanel {
        bottom: max(16px, env(safe-area-inset-bottom, 0px));
        right: max(16px, env(safe-area-inset-right, 0px));
        width: calc(100% - max(32px, env(safe-area-inset-right, 0px) * 2));
        padding: 20px;
    }

    .floating-buttons-container {
        bottom: max(16px, env(safe-area-inset-bottom, 0px));
        right: max(16px, env(safe-area-inset-right, 0px));
        flex-direction: column-reverse;
        gap: 8px;
    }

    .floating-login-toggle {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* 超小手机适配 (iPhone SE 及以下) */
@media (max-width: 375px) {
    header {
        padding: 12px 8px;
    }

    header h1 {
        font-size: 18px;
        margin-bottom: 2px;
    }

    header p {
        font-size: 10px;
    }

    .scheduler-notice {
        margin: 10px 8px 0;
        padding: 8px 10px;
    }

    .night-query-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    main {
        grid-template-columns: 1fr;
        padding: 12px 8px 70px;
        gap: 10px;
    }

    aside {
        padding: 10px;
        gap: 6px;
        max-height: 300px;
    }

    .sidebar-header h2 {
        font-size: 14px;
    }

    .panels-stack {
        gap: 10px;
    }

    .panel {
        padding: 10px;
        border-radius: 10px;
        gap: 6px;
    }

    .panel-header {
        padding-bottom: 6px;
        gap: 6px;
    }

    .panel-header h2 {
        font-size: 13px;
    }

    .btn {
        padding: 8px 10px;
        font-size: 11px;
        min-height: 44px;
        justify-content: center;
    }

    input,
    select,
    textarea {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 14px;
    }

    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 3px rgba(75, 123, 236, 0.1);
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        min-height: 44px;
    }

    details summary {
        font-size: 13px;
        min-height: 44px;
        padding: 8px 12px;
    }

    .table-wrapper {
        padding: 6px;
    }

    .table-controls {
        gap: 6px;
    }

    .table-pager {
        flex-direction: column;
        gap: 6px;
    }

    .metric {
        font-size: 10px;
    }
}

/* 小手机适配 */
@media (max-width: 480px) {
    header {
        padding: 16px 12px;
    }

    header h1 {
        font-size: 20px;
    }

    header p {
        font-size: 11px;
        letter-spacing: 0.06em;
    }

    main {
        padding: 16px 12px 80px;
        gap: 12px;
    }

    main.auth-only {
        padding: 12px 8px;
    }

    aside {
        padding: 12px;
        gap: 8px;
    }

    .sidebar-header h2 {
        font-size: 16px;
    }

    .panels-stack {
        gap: 12px;
    }

    .panel {
        padding: 12px;
        gap: 8px;
        border-radius: 12px;
    }

    .panel-header {
        flex-direction: column;
        gap: 8px;
        padding-bottom: 8px;
    }

    .panel-header h2 {
        font-size: 14px;
    }

    .btn {
        min-height: 44px;
        justify-content: center;
    }

    input,
    select,
    textarea {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 14px;
    }

    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 3px rgba(75, 123, 236, 0.1);
    }

    details summary {
        min-height: 44px;
        padding: 8px 12px;
    }

    /* 表格响应式显示 - 卡片模式 */
    .history-table {
        font-size: 11px;
        width: 100%;
        display: block;
        border: none;
    }

    .history-table thead {
        display: none;
    }

    .history-table tbody {
        display: block;
    }

    .history-table tbody tr {
        display: block;
        border: 1px solid rgba(147, 112, 219, 0.2);
        border-radius: 12px;
        padding: 12px;
        margin-bottom: 10px;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(240, 245, 255, 0.93));
    }

    .history-table tbody tr:hover {
        background: rgba(79, 70, 229, 0.08);
        border-color: rgba(147, 112, 219, 0.35);
        box-shadow: 0 2px 8px rgba(147, 112, 219, 0.1);
    }

    .history-table td {
        display: block;
        padding: 6px 0;
        border: none;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .history-table td:first-child {
        padding-top: 0;
        font-weight: 500;
        color: var(--text-primary);
    }

    .history-table td:last-child {
        padding-bottom: 0;
    }

    .history-table td + td::before {
        content: "";
        display: block;
        height: 1px;
        background: rgba(147, 112, 219, 0.1);
        margin: 2px 0;
    }

    .table-wrapper {
        padding: 8px;
        border-radius: 12px;
    }

    .table-controls {
        flex-direction: column;
        gap: 8px;
    }

    .table-controls label {
        font-size: 11px;
    }

    .table-controls select {
        font-size: 11px;
        padding: 4px;
        border-radius: 6px;
    }

    .table-pager {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .btn {
        padding: 6px 10px;
        font-size: 11px;
        border-radius: 6px;
        flex: 1;
        min-width: 60px;
        min-height: 44px;
        justify-content: center;
    }

    .hint-text {
        font-size: 10px;
    }

    #detailTablePanel {
        margin-top: 8px !important;
    }

    .table-title {
        font-size: 11px;
    }

    #settingsPanel {
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
        right: max(12px, env(safe-area-inset-right, 0px));
        width: calc(100% - max(24px, env(safe-area-inset-right, 0px) * 2));
        padding: 16px;
        border-radius: 16px;
    }

    #userSettingsPanel {
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
        right: max(12px, env(safe-area-inset-right, 0px));
        width: calc(100% - max(24px, env(safe-area-inset-right, 0px) * 2));
        padding: 16px;
        border-radius: 16px;
    }

    #businessLoginPanel {
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
        right: max(12px, env(safe-area-inset-right, 0px));
        width: calc(100% - max(24px, env(safe-area-inset-right, 0px) * 2));
        padding: 16px;
        border-radius: 16px;
    }

    .floating-buttons-container {
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
        right: max(12px, env(safe-area-inset-right, 0px));
        gap: 6px;
    }

    .floating-login-toggle {
        padding: 8px 12px;
        font-size: 12px;
    }

    .metric {
        display: inline-block;
        font-size: 11px;
    }

    details {
        padding: 12px;
        border-radius: 12px;
    }

    details summary {
        font-size: 13px;
    }

    input,
    select,
    textarea {
        font-size: 14px !important; /* 防止iOS自动缩放 */
    }
}
