/**
 * Shared UI: modals, FAB, admin DM panels
 */

/* ── Modals ───────────────────────────────────── */

@keyframes dmBackdropIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dmBackdropOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes dmCardIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes dmCardOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes dmContentIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Page enter — opacity only, no layout shift */
.dm-page-main {
    animation: dmContentIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@media (prefers-reduced-motion: reduce) {
    .dm-page-main {
        animation: none;
    }
}

.dm-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    pointer-events: none;
}

.dm-modal.dm-modal--hidden {
    display: none !important;
    pointer-events: none;
}

.dm-modal.is-open,
.dm-modal.is-closing {
    pointer-events: auto;
}

.dm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 37, 64, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
}

.dm-modal.is-open .dm-modal-backdrop {
    animation: dmBackdropIn 0.3s ease forwards;
}

.dm-modal.is-closing .dm-modal-backdrop {
    animation: dmBackdropOut 0.28s ease forwards;
}

.dm-modal-wrap {
    position: relative;
    width: 100%;
    max-height: 92vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.dm-modal-card {
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 20px;
    border: 1px solid rgba(227, 232, 239, 0.95);
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
    box-shadow:
        0 28px 60px rgba(15, 23, 42, 0.2),
        0 0 0 1px rgba(99, 91, 255, 0.05);
    padding: 24px;
}

.dm-modal:not(.is-open):not(.is-closing) .dm-modal-card {
    opacity: 0;
}

.dm-modal.is-open .dm-modal-card {
    animation: dmCardIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.dm-modal.is-closing .dm-modal-card {
    animation: dmCardOut 0.28s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.dm-modal.is-open .dm-modal-header {
    animation: dmContentIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.dm-modal.is-open .dm-modal-body,
.dm-modal.is-open .dm-modal-body > form {
    animation: dmContentIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}

.dm-modal.is-open .dm-modal-footer {
    animation: dmContentIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) 0.16s both;
}

.dm-modal-card--sm { max-width: 420px; }
.dm-modal-card--md { max-width: 480px; }
.dm-modal-card--lg { max-width: 720px; }

.dm-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border-soft, #f0f4f8);
}

.dm-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-text, #0a2540);
    display: flex;
    align-items: center;
    gap: 10px;
}

.dm-modal-title i {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--color-brand-50, #f0f4ff);
    color: var(--color-brand-500, #635bff);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.dm-modal-subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--color-text-subtle, #8898aa);
}

.dm-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dm-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border-soft, #f0f4f8);
}

.dm-modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 10px;
    background: #fff;
    color: #425466;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.dm-modal-close:hover {
    background: #f7fafc;
    border-color: #d7dee8;
}

.dm-modal-section {
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 14px;
    padding: 16px;
    background: #fff;
}

.dm-modal-section-title {
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    color: #425466;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* folder.html legacy modal */
.modal:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.is-open .modal-content,
.modal.is-closing .modal-content {
    transition:
        transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal:not(.is-open):not(.is-closing) .modal-content {
    opacity: 0;
}

.modal.is-open .modal-content {
    opacity: 1;
}

.modal.is-closing .modal-content {
    opacity: 0;
    transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
}

.modal-content {
    border-radius: 20px !important;
    border: 1px solid rgba(227, 232, 239, 0.9) !important;
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%) !important;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.14) !important;
    padding: 24px !important;
    max-width: 480px;
}

.modal-title {
    font-size: 18px !important;
    font-weight: var(--fw-semibold, 500) !important;
    color: var(--color-text, #0a2540) !important;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-title i {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--color-brand-50, #f0f4ff);
    color: var(--color-brand-500, #635bff);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-close {
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
}

/* ── Buttons & fields ─────────────────────────── */

.dm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    cursor: pointer;
    border: none;
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.dm-btn:active { transform: scale(0.98); }

.dm-btn-primary {
    background: linear-gradient(180deg, var(--color-brand-500, #635bff) 0%, var(--color-brand-600, #4f46e5) 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(99, 91, 255, 0.28);
}

.dm-btn-primary:hover {
    box-shadow: 0 10px 24px rgba(99, 91, 255, 0.34);
}

.dm-btn-secondary {
    background: #fff;
    color: #425466;
    border: 1px solid var(--color-border, #e3e8ef);
}

.dm-btn-secondary:hover { background: #f7fafc; }

.dm-btn-danger {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.22);
}

.dm-btn-success {
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
    color: #fff;
}

.dm-btn-ghost {
    background: #fff;
    border: 1px solid var(--color-border, #e3e8ef);
    color: #425466;
}

.dm-icon-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease;
}

.dm-icon-btn--save {
    border-color: #dbeafe;
    background: #eff6ff;
    color: #2563eb;
}

.dm-icon-btn--save:hover { background: #dbeafe; }

.dm-icon-btn--delete {
    border-color: #fecaca;
    background: #fef2f2;
    color: #dc2626;
}

.dm-icon-btn--delete:hover { background: #fee2e2; }

.dm-field,
.dm-card input:not([type="checkbox"]):not([type="radio"]),
.dm-card select,
.dm-card textarea,
.dm-form input:not([type="checkbox"]):not([type="radio"]),
.dm-form select,
.dm-form textarea {
    display: block;
    width: 100%;
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 12px;
    background: #fff;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--color-text, #0a2540);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dm-field:focus,
.dm-card input:focus,
.dm-card select:focus,
.dm-form input:focus,
.dm-form select:focus {
    border-color: var(--color-brand-500, #635bff);
    box-shadow: 0 0 0 4px rgba(99, 91, 255, 0.12);
}

.dm-label {
    display: block;
    font-size: 12px;
    font-weight: var(--fw-semibold, 500);
    color: #425466;
    margin-bottom: 6px;
}

/* Custom checkbox — same visual as folder file picker */
.dm-check-box {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    vertical-align: middle;
    user-select: none;
}

.dm-check-box--module {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e3e8ef;
    border-radius: 10px;
    background: #f8fafc;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.dm-check-box--module:hover {
    border-color: #c7d2fe;
    background: #f5f7ff;
}

.dm-module-list {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

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

.dm-check-ui {
    position: relative;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1.5px solid #c4cdd6;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.dm-check-ui svg {
    display: block;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.dm-check-box:hover .dm-check-ui {
    border-color: #635bff;
}

.dm-check-input:focus-visible + .dm-check-ui {
    border-color: #635bff;
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.18);
}

.dm-check-input:checked + .dm-check-ui {
    border-color: #635bff;
    background: #635bff;
}

.dm-check-input:checked + .dm-check-ui svg {
    opacity: 1;
    transform: scale(1);
}

.dm-check-input:indeterminate + .dm-check-ui {
    border-color: #635bff;
    background: #635bff;
}

.dm-check-input:indeterminate + .dm-check-ui svg {
    opacity: 0;
}

.dm-check-input:indeterminate + .dm-check-ui::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 1.5px;
    background: #fff;
    border-radius: 1px;
}

.dm-check-label {
    font-size: 13px;
    color: #425466;
    line-height: 1.35;
}

.dm-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 0;
    cursor: pointer;
}

/* ── FAB (add document) ───────────────────────── */

.fm-fab-area {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1900;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
}

.fm-fab-button {
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 18px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #6d65ff 0%, #4f46e5 55%, #4338ca 100%);
    box-shadow:
        0 16px 32px rgba(79, 70, 229, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.12) inset;
    font-size: 26px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-radius 0.2s ease;
}

.fm-fab-button:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 20px 36px rgba(79, 70, 229, 0.42);
}

.fm-fab-button.is-open {
    border-radius: 16px;
    transform: rotate(45deg);
}

.fm-fab-panel {
    width: min(92vw, 340px);
    padding: 0;
    border-radius: 20px;
    border: 1px solid rgba(227, 232, 239, 0.95);
    background: #fff;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.16);
    overflow: hidden;
    display: none;
    transform-origin: bottom right;
}

.fm-fab-panel.active {
    display: block;
    animation: fab-panel-in 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes fab-panel-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fm-fab-panel-head {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 16px 18px;
    background: linear-gradient(180deg, #f8f9ff 0%, #fff 100%);
    border-bottom: 1px solid #f0f4f8;
}

.fm-fab-panel-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(145deg, #6d65ff, #4f46e5);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(99, 91, 255, 0.28);
}

.fm-fab-panel-head strong {
    font-size: 15px;
    font-weight: var(--fw-semibold, 500);
}

.fm-fab-panel-head small {
    font-size: 12px;
    color: var(--color-text-subtle, #8898aa);
}

.fm-fab-panel-body {
    padding: 16px 18px 18px;
}

.fm-fab-period {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 10px;
    margin-bottom: 12px;
}

.fm-fab-field label {
    font-size: 11px;
    font-weight: var(--fw-semibold, 500);
    letter-spacing: 0.05em;
    margin-bottom: 5px;
}

.fm-fab-field input,
.fm-fab-field select {
    border-radius: 12px !important;
    padding: 10px 12px !important;
    border: 1px solid #e3e8ef !important;
    font-size: 13px !important;
}

.fm-fab-actions {
    display: grid;
    gap: 8px;
    margin-top: 0;
}

.fm-fab-subfolder {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.dm-fab-action {
    width: 100%;
    min-height: 46px;
    border-radius: 14px;
    border: 1px solid #e3e8ef;
    background: #fff;
    color: #334155;
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.dm-fab-action i {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #f0f4ff;
    color: #635bff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.dm-fab-action:hover {
    background: #f8faff;
    border-color: #d7dee8;
}

.dm-fab-action--primary {
    border-color: #c7d2fe;
    background: linear-gradient(180deg, #f5f3ff 0%, #eef2ff 100%);
    color: #4338ca;
}

.dm-fab-action--primary i {
    background: #635bff;
    color: #fff;
}

.fm-divider {
    border-top: 1px solid #f0f4f8;
    margin: 14px 0;
}

@media (max-width: 768px) {
    .fm-fab-area {
        left: 16px;
        right: 16px;
        bottom: 16px;
        align-items: stretch;
    }

    .fm-fab-panel {
        width: 100%;
    }

    .fm-fab-button {
        align-self: flex-end;
    }
}

.fm-fab-subfolder input {
    border-radius: 12px !important;
}

.fm-fab-subfolder .dm-btn {
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 14px;
}

/* ── Admin DMRecords / DMItems ────────────────── */

.dm-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 14px 16px;
}

.dm-toolbar--admin-dm {
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr) auto auto;
}

.dm-field-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dm-table-group-row td {
    background: #f8faff;
    color: #635bff;
    font-size: 12px;
    font-weight: var(--fw-semibold, 500);
    letter-spacing: 0.04em;
    padding: 10px 14px;
    border-top: 1px solid #e8edff;
}

.dm-table-group-row td i {
    margin-right: 6px;
}

.dm-table code {
    font-size: 12px;
    background: #f0f4ff;
    color: #4f46e5;
    padding: 2px 6px;
    border-radius: 6px;
}

.dm-card {
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    animation: dm-rise-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes dm-rise-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.dm-card:nth-child(2) { animation-delay: 0.04s; }
.dm-card:nth-child(3) { animation-delay: 0.08s; }
.dm-card:nth-child(4) { animation-delay: 0.12s; }
.dm-card:nth-child(5) { animation-delay: 0.16s; }

.dm-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border-soft, #f0f4f8);
    background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
}

.dm-card-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.dm-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.dm-card-icon--records {
    background: #eef2ff;
    color: #4f46e5;
}

.dm-card-icon--items {
    background: #ecfdf5;
    color: #059669;
}

.dm-card-icon--add {
    background: #f0f4ff;
    color: #635bff;
}

.dm-card-title {
    font-size: 14px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-text, #0a2540);
}

.dm-card-desc {
    font-size: 12px;
    color: var(--color-text-subtle, #8898aa);
    margin-top: 2px;
}

.dm-card-count {
    font-size: 12px;
    font-weight: var(--fw-semibold, 500);
    color: #697386;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 4px 10px;
}

.dm-card-body {
    padding: 16px 18px;
}

.dm-form-grid {
    display: grid;
    gap: 10px;
    align-items: end;
}

.dm-form-grid--record {
    grid-template-columns: 200px minmax(0, 1fr) 200px minmax(0, 1fr) auto;
}

.dm-form-grid--item {
    grid-template-columns: 180px minmax(0, 1fr) 240px minmax(0, 1fr) 90px 120px 160px auto;
}

.dm-modal-grid-2 {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr 1fr;
}

.dm-modal-grid-2--api {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
}

@media (max-width: 640px) {
    .dm-modal-grid-2,
    .dm-modal-grid-2--api {
        grid-template-columns: 1fr;
    }
}

.dm-table-wrap {
    overflow-x: auto;
}

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

.dm-table thead th {
    font-size: 11px;
    font-weight: var(--fw-semibold, 500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-subtle, #8898aa);
    padding: 11px 14px;
    border-bottom: 1px solid var(--color-border, #e3e8ef);
    text-align: left;
    background: #fafbff;
}

.dm-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border-soft, #f0f4f8);
    font-size: 13px;
    color: #425466;
    vertical-align: middle;
}

.dm-table tbody tr:hover {
    background: #f8fafc;
}

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

.dm-table-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.dm-empty {
    padding: 28px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--color-text-subtle, #8898aa);
}

.dm-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #fafbff;
}

.dm-list-item-name {
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-text, #0a2540);
}

.dm-list-empty {
    font-size: 12px;
    color: var(--color-text-subtle, #8898aa);
    padding: 6px 0;
}

@media (max-width: 1100px) {
    .dm-form-grid--record,
    .dm-form-grid--item {
        grid-template-columns: 1fr;
    }

    .dm-toolbar--admin-dm {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .dm-modal-card {
        padding: 18px;
        border-radius: 16px;
    }

    .fm-fab-period {
        grid-template-columns: 1fr;
    }
}

/* ── File preview overlay ─────────────────────── */

.fm-preview-modal.is-open,
.fm-preview-modal.is-closing {
    display: block;
    pointer-events: auto;
}

.fm-preview-modal.is-open {
    animation: dmBackdropIn 0.3s ease forwards;
}

.fm-preview-modal.is-closing {
    animation: dmBackdropOut 0.28s ease forwards;
}

.fm-preview-modal .fm-preview-dialog {
    opacity: 0;
}

.fm-preview-modal.is-open .fm-preview-dialog {
    animation: dmCardIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.fm-preview-modal.is-closing .fm-preview-dialog {
    animation: dmCardOut 0.28s cubic-bezier(0.4, 0, 1, 1) forwards;
}

/* ── Site UI polish ───────────────────────────── */

.dm-page-header {
    margin-bottom: 0;
}

.dm-page-title {
    font-size: 22px;
    font-weight: var(--fw-bold, 600);
    color: var(--color-text, #0a2540);
    margin: 0 0 4px;
    letter-spacing: -0.02em;
}

.dm-page-subtitle {
    font-size: 13px;
    color: var(--color-text-muted, #697386);
    margin: 0;
}

.dm-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 0;
}

.dm-stat-card {
    background: linear-gradient(180deg, #fff 0%, #fafbff 100%);
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    animation: dm-rise-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.dm-stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.dm-stat-label {
    font-size: 11px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-text-subtle, #8898aa);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.dm-stat-value {
    font-size: 30px;
    font-weight: var(--fw-bold, 600);
    color: var(--color-text, #0a2540);
    line-height: 1;
}

.dm-stat-value--brand {
    color: var(--color-brand-500, #635bff);
}

.dm-stat-value--success {
    color: #15803d;
}

.dm-stat-value--danger {
    color: #dc2626;
}

.dm-stat-grid .dm-stat-card:nth-child(1) { animation-delay: 0.03s; }
.dm-stat-grid .dm-stat-card:nth-child(2) { animation-delay: 0.06s; }
.dm-stat-grid .dm-stat-card:nth-child(3) { animation-delay: 0.09s; }
.dm-stat-grid .dm-stat-card:nth-child(4) { animation-delay: 0.12s; }
.dm-stat-grid .dm-stat-card:nth-child(5) { animation-delay: 0.15s; }
.dm-stat-grid .dm-stat-card:nth-child(6) { animation-delay: 0.18s; }

.dm-dashboard-item {
    animation: dm-rise-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
    margin-bottom: 24px;
}

.dm-dashboard-item:last-child {
    margin-bottom: 0;
}

.dm-page-header.dm-dashboard-item { animation-delay: 0s; }
.dm-stat-grid.dm-dashboard-item { animation-delay: 0.04s; }
.dm-panel.dm-dashboard-item:nth-of-type(1) { animation-delay: 0.08s; }
.dm-panel.dm-dashboard-item:nth-of-type(2) { animation-delay: 0.12s; }
.dm-panel.dm-dashboard-item:nth-of-type(3) { animation-delay: 0.16s; }
.dm-empty-state.dm-dashboard-item { animation-delay: 0.08s; }

.dm-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-text-muted, #697386);
    text-decoration: none;
    transition: color 0.12s ease;
}

.dm-back-link:hover {
    color: var(--color-brand-500, #635bff);
}

.dm-stat-pill {
    font-size: 12px;
    color: var(--color-text-subtle, #8898aa);
    white-space: nowrap;
}

.dm-folder-chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 20px;
}

.dm-folder-chip-wrap--inline {
    padding: 0;
    flex: 1;
    min-width: 0;
}

.dm-folder-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid #e3e8ef;
    background: #f8faff;
    color: #425466;
    font-size: 12px;
    font-weight: var(--fw-semibold, 500);
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.dm-folder-chip:hover {
    background: #f0f4ff;
    border-color: #c7d2fe;
    color: #4f46e5;
}

.dm-user-folder-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border-soft, #f0f4f8);
}

.dm-user-folder-row:last-child {
    border-bottom: none;
}

.dm-user-folder-link {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 180px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

.dm-user-folder-link:hover .dm-list-name {
    color: var(--color-brand-500, #635bff);
}

.dm-panel-empty,
.dm-panel-empty-inline {
    padding: 16px 20px;
    font-size: 13px;
    color: var(--color-text-subtle, #8898aa);
}

.dm-panel-empty-inline {
    padding: 0;
}

.dm-list-icon--user {
    background: #f0f4ff;
    color: #635bff;
}

.dm-list-icon--file {
    background: #eff6ff;
    color: #2563eb;
}

@media (max-width: 768px) {
    .dm-user-folder-row {
        flex-direction: column;
    }

    .dm-user-folder-link {
        min-width: 0;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dm-stat-card,
    .dm-dashboard-item {
        animation: none !important;
    }
}

.dm-stats-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px 18px;
    margin-bottom: 0;
    padding: 16px 18px;
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 14px;
    background: linear-gradient(180deg, #fff 0%, #fafbff 100%);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.dm-stats-periods {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dm-stats-period {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e3e8ef;
    background: #fff;
    color: #425466;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.dm-stats-period:hover {
    background: #f8faff;
    border-color: #c7d2fe;
    color: #4f46e5;
}

.dm-stats-period.is-active {
    background: #f0f4ff;
    border-color: #635bff;
    color: #635bff;
}

.dm-stats-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 12px;
}

.dm-stats-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}

.dm-stats-field > span {
    font-size: 11px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-text-subtle, #8898aa);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dm-stats-link {
    font-size: 12px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-brand-500, #635bff);
    text-decoration: none;
}

.dm-stats-link:hover {
    text-decoration: underline;
}

.dm-stats-month-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 14px;
}

.dm-stats-field--month {
    min-width: 200px;
}

.dm-stats-month-select {
    min-width: 200px;
    cursor: pointer;
}

.dm-stats-month-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 2px;
}

.dm-stats-month-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #e3e8ef;
    border-radius: 10px;
    background: #fff;
    color: #425466;
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.dm-stats-month-nav-btn:hover {
    background: #f8faff;
    border-color: #c7d2fe;
    color: #4f46e5;
}

.dm-stats-month-current {
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    color: #425466;
    min-width: 100px;
    text-align: center;
}

@media (max-width: 768px) {
    .dm-stats-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .dm-stats-fields,
    .dm-stats-field {
        width: 100%;
        min-width: 0;
    }
}

.dm-panel {
    background: #fff;
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.dm-panel-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border-soft, #f0f4f8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
}

.dm-panel-title {
    font-size: 14px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-text, #0a2540);
}

.dm-panel-meta {
    font-size: 12px;
    color: var(--color-text-subtle, #8898aa);
}

.dm-list-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border-soft, #f0f4f8);
    text-decoration: none;
    color: inherit;
    transition: background 0.12s ease;
}

.dm-list-row:last-child {
    border-bottom: none;
}

.dm-list-row:hover {
    background: #f8faff;
}

.dm-list-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: #fff8ed;
    color: #f59e0b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.dm-list-main {
    flex: 1;
    min-width: 0;
}

.dm-list-name {
    font-size: 14px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-text, #0a2540);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-list-desc {
    font-size: 12px;
    color: var(--color-text-subtle, #8898aa);
    margin-top: 2px;
}

.dm-presence {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text-subtle, #8898aa);
    white-space: nowrap;
}

.dm-presence--online,
.dm-presence.dm-presence--online {
    color: #16a34a;
}

.dm-presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    flex-shrink: 0;
}

.dm-presence--online .dm-presence-dot,
.dm-page-presence.is-online .dm-presence-dot {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.dm-page-presence {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 14px;
    color: var(--color-text-subtle, #8898aa);
}

.dm-page-presence.is-online {
    color: #16a34a;
}

.dm-session-ip {
    font-size: 12px;
    color: #425466;
    background: #f6f8fa;
    padding: 2px 6px;
    border-radius: 6px;
}

.dm-session-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: var(--fw-semibold, 600);
    color: #64748b;
    background: #f1f5f9;
}

.dm-session-badge--active {
    color: #16a34a;
    background: #f0fdf4;
}

.dm-session-badge--revoked {
    color: #dc2626;
    background: #fef2f2;
}

.dm-session-badge--logout {
    color: #475569;
    background: #f1f5f9;
}

.dm-session-badge--duplicate {
    color: #64748b;
    background: #f8fafc;
}

.dm-session-meta {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #94a3b8;
}

.dm-session-row--revoked {
    opacity: 0.72;
}

.dm-session-row--revoked .dm-list-name,
.dm-session-row--revoked .dm-session-ip {
    color: #94a3b8;
}

.dm-session-revoke-placeholder {
    display: inline-block;
    width: 32px;
    text-align: center;
    color: #cbd5e1;
}

.dm-ocr-control-body {
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dm-ocr-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dm-ocr-status-label {
    font-size: 13px;
    color: #64748b;
    font-weight: var(--fw-semibold, 600);
}

.dm-ocr-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: var(--fw-semibold, 600);
    background: #f1f5f9;
    color: #475569;
}

.dm-ocr-status-badge.is-running {
    background: #f0fdf4;
    color: #16a34a;
}

.dm-ocr-status-badge.is-paused,
.dm-ocr-status-badge.is-stopped {
    background: #fff7ed;
    color: #ea580c;
}

.dm-ocr-status-badge.is-backoff {
    background: #fef3c7;
    color: #b45309;
}

.dm-ocr-backoff {
    font-size: 12px;
    color: #b45309;
}

.dm-ocr-control-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.dm-ocr-delay-form {
    margin: 0;
}

.dm-ocr-quota-error {
    font-size: 12px;
    line-height: 1.45;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 12px;
    word-break: break-word;
    max-height: 120px;
    overflow: auto;
}

.dm-ocr-usage-table td,
.dm-ocr-usage-table th {
    white-space: nowrap;
}

.dm-ocr-usage-note {
    margin: 0;
    padding: 12px 16px 16px;
    font-size: 12px;
    line-height: 1.5;
    color: #64748b;
}

.dm-ocr-usage-note code {
    font-size: 11px;
}

.dm-ocr-item-badge {
    display: inline-flex;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: var(--fw-semibold, 600);
    text-transform: none;
}

.dm-ocr-item-badge--queued {
    color: #2563eb;
    background: #eff6ff;
}

.dm-ocr-item-badge--waiting {
    color: #b45309;
    background: #fef3c7;
}

.dm-ocr-item-badge--processing {
    color: #7c3aed;
    background: #f5f3ff;
}

.dm-ocr-origin-badge {
    display: inline-flex;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: var(--fw-semibold, 600);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.dm-ocr-origin-badge--ocr {
    color: #0369a1;
    background: #e0f2fe;
}

.dm-ocr-origin-badge--merit {
    color: #b91c1c;
    background: #fee2e2;
}

.dm-ocr-origin-badge--upload {
    color: #c2410c;
    background: #ffedd5;
}

.dm-ocr-origin-hint {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
}

.dm-ocr-error-cell {
    max-width: 280px;
    font-size: 12px;
    color: #64748b;
    word-break: break-word;
}

.dm-ocr-bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.dm-ocr-bulk-count {
    font-size: 12px;
    font-weight: var(--fw-semibold, 600);
    color: #475569;
    margin-right: 4px;
}

.dm-ocr-check-col {
    width: 36px;
    text-align: center;
    vertical-align: middle;
}

.dm-ocr-check {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #2563eb;
}

.dm-ocr-doc-link {
    color: #2563eb;
    text-decoration: none;
}

.dm-ocr-doc-link:hover {
    text-decoration: underline;
}

.dm-ocr-failed-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.dm-ocr-inline-form {
    margin: 0;
}

.dm-ocr-failed-modal-error {
    font-size: 12px;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 10px;
}

.dm-ocr-failed-modal-error.is-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.dm-ocr-failed-modal-error.is-success {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.dm-ocr-failed-modal-status {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 8px;
    word-break: break-word;
}

.dm-ocr-editor-label {
    display: block;
    font-size: 12px;
    font-weight: var(--fw-semibold, 600);
    color: #64748b;
    margin-bottom: 6px;
}

.dm-ocr-failed-editor {
    width: 100%;
    min-height: 320px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    resize: vertical;
    box-sizing: border-box;
}

.dm-ocr-failed-editor:focus {
    outline: none;
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.25);
}

.dm-session-revoke-all-form {
    margin-left: auto;
    flex-shrink: 0;
}

.dm-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
}

.dm-session-revoke-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #dc2626;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.dm-session-revoke-btn:hover {
    background: #fee2e2;
    border-color: #f87171;
}

.dm-panel-head .dm-session-revoke-all-form + .dm-panel-meta,
.dm-panel-head .dm-panel-meta {
    margin-left: 0;
}

.dm-list-side {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.dm-badge {
    font-size: 11px;
    font-weight: var(--fw-semibold, 500);
    padding: 3px 10px;
    border-radius: 999px;
    background: #f0f4ff;
    color: var(--color-brand-500, #635bff);
}

.dm-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--color-border, #e3e8ef);
    margin-bottom: 24px;
    padding-bottom: 0;
}

.dm-tab-btn {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    font-family: inherit;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-subtle, #8898aa);
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.dm-tab-btn:hover {
    color: var(--color-text, #0a2540);
}

.dm-tab-btn.is-active {
    color: var(--color-brand-500, #635bff);
    border-bottom-color: var(--color-brand-500, #635bff);
}

.dm-tabs--links {
    margin-top: 8px;
    margin-bottom: 24px;
}

.dm-tabs--links .dm-tab-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.dm-tabs--admin .dm-tab-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.admin-tab-panel {
    font-family: var(--font-sans);
}

.dm-tab-dropdown {
    position: relative;
}

.dm-tab-dropdown.is-active > .dm-tab-dropdown__toggle {
    color: var(--color-brand-500, #635bff);
    border-bottom-color: var(--color-brand-500, #635bff);
}

.dm-tab-dropdown__toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dm-tab-dropdown__chevron {
    font-size: 11px;
    transition: transform 0.15s ease;
}

.dm-tab-dropdown.is-open .dm-tab-dropdown__chevron {
    transform: rotate(180deg);
}

.dm-tab-dropdown__menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 190px;
    background: #fff;
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(10, 37, 64, 0.1);
    padding: 6px;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.dm-tab-dropdown.is-open .dm-tab-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dm-tab-dropdown__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    color: var(--color-text-subtle, #8898aa);
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.dm-tab-dropdown__item:hover {
    background: #f7fafc;
    color: var(--color-text, #0a2540);
}

.dm-tab-dropdown__item.is-active {
    background: #f0f4ff;
    color: var(--color-brand-500, #635bff);
}

.dm-empty-state {
    background: #fff;
    border: 1px solid var(--color-border, #e3e8ef);
    border-radius: 14px;
    padding: 60px 24px;
    text-align: center;
}

.dm-empty-state i {
    font-size: 40px;
    color: #c4cdd6;
    margin-bottom: 12px;
}

@media (prefers-reduced-motion: reduce) {
    .dm-modal-backdrop,
    .dm-modal-card,
    .dm-card,
    .fm-fab-panel.active,
    .fm-preview-modal,
    .fm-preview-dialog {
        animation: none !important;
        transition: none !important;
    }

    .dm-modal.is-open .dm-modal-card,
    .dm-modal.is-open .dm-modal-backdrop,
    .dm-modal.is-closing .dm-modal-card,
    .dm-modal.is-closing .dm-modal-backdrop,
    .fm-preview-modal.is-open .fm-preview-dialog,
    .fm-preview-modal.is-closing .fm-preview-dialog {
        opacity: 1;
        transform: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .dm-modal.is-open .dm-modal-header,
    .dm-modal.is-open .dm-modal-body,
    .dm-modal.is-open .dm-modal-footer {
        animation: none !important;
    }

    .dm-toast-wrap,
    .dm-toast-wrap.is-visible,
    .dm-toast-wrap.is-leaving {
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
        animation: none !important;
    }

    .dm-toast-wrap.is-visible .dm-toast-icon,
    .dm-toast-wrap.is-visible.dm-toast-wrap--success .dm-toast {
        animation: none !important;
    }
}

/* ── Toast notifications (glass) ── */
@keyframes dm-toast-enter {
    0% {
        transform: translateX(120%) scale(0.92);
        opacity: 0;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes dm-toast-leave {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(120%) scale(0.95);
        opacity: 0;
    }
}

@keyframes dm-toast-icon-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.25);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes dm-toast-success-ring {
    0% {
        box-shadow:
            0 8px 32px rgba(10, 37, 64, 0.12),
            inset 0 1px 0 rgba(255, 255, 255, 0.65),
            0 0 0 0 rgba(16, 185, 129, 0.45);
    }
    70% {
        box-shadow:
            0 8px 32px rgba(10, 37, 64, 0.12),
            inset 0 1px 0 rgba(255, 255, 255, 0.65),
            0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow:
            0 8px 32px rgba(10, 37, 64, 0.12),
            inset 0 1px 0 rgba(255, 255, 255, 0.65),
            0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.dm-toast-wrap {
    pointer-events: auto;
    opacity: 0;
    transform: translateX(120%) scale(0.92);
    will-change: transform, opacity;
}

.dm-toast-wrap.is-visible {
    animation: dm-toast-enter 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.dm-toast-wrap.is-leaving {
    animation: dm-toast-leave 0.24s ease forwards;
}

.dm-toast-wrap.is-visible.dm-toast-wrap--success .dm-toast {
    animation: dm-toast-success-ring 0.65s ease 0.12s;
}

.dm-toast-wrap.is-visible .dm-toast-icon {
    animation: dm-toast-icon-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.14s both;
}

.dm-toast {
    position: relative;
    overflow: hidden;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(21px);
    -webkit-backdrop-filter: blur(21px);
    border: 1px solid rgba(255, 255, 255, 0.42);
    box-shadow:
        0 8px 32px rgba(10, 37, 64, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.65),
        inset 0 -1px 0 rgba(255, 255, 255, 0.12),
        inset 0 0 16px 8px rgba(255, 255, 255, 0.35);
}

.dm-toast::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
    pointer-events: none;
}

.dm-toast::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), transparent, rgba(255, 255, 255, 0.28));
    pointer-events: none;
}

.dm-toast-body {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
}

.dm-toast-icon {
    font-size: 16px;
    line-height: 1.4;
    flex-shrink: 0;
}

.dm-toast-message {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    line-height: 1.45;
    color: var(--color-text, #0a2540);
}

.dm-toast-close {
    flex-shrink: 0;
    border: none;
    background: rgba(255, 255, 255, 0.35);
    color: var(--color-text-subtle, #8898aa);
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.dm-toast-close:hover {
    background: rgba(255, 255, 255, 0.65);
    color: var(--color-text, #0a2540);
}

.dm-toast--success {
    border-color: rgba(16, 185, 129, 0.28);
    background: rgba(236, 253, 245, 0.82);
}

.dm-toast--success .dm-toast-icon {
    color: #059669;
}

.dm-toast--danger,
.dm-toast--error {
    border-color: rgba(244, 63, 94, 0.28);
    background: rgba(255, 241, 242, 0.84);
}

.dm-toast--danger .dm-toast-icon,
.dm-toast--error .dm-toast-icon {
    color: #e11d48;
}

.dm-toast--warning {
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(255, 251, 235, 0.84);
}

.dm-toast--warning .dm-toast-icon {
    color: #d97706;
}

.dm-toast--info {
    border-color: rgba(14, 165, 233, 0.28);
    background: rgba(240, 249, 255, 0.84);
}

.dm-toast--info .dm-toast-icon {
    color: #0284c7;
}

/* ── Pagination ─────────────────────────────── */

.dm-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 14px 16px 6px;
}

.dm-pagination.is-hidden {
    display: none;
}

.dm-pagination__btn {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--color-border, #e3e8ef);
    background: #fff;
    color: #425466;
    font-size: 13px;
    font-weight: var(--fw-semibold, 500);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.dm-pagination__btn:hover:not(:disabled) {
    background: #f7fafc;
    border-color: #cfd8e3;
}

.dm-pagination__btn.is-active {
    background: linear-gradient(180deg, var(--color-brand-500, #635bff) 0%, var(--color-brand-600, #4f46e5) 100%);
    border-color: var(--color-brand-600, #4f46e5);
    color: #fff;
    box-shadow: 0 6px 16px rgba(99, 91, 255, 0.24);
}

.dm-pagination__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.dm-pagination__gap {
    color: var(--color-text-subtle, #8898aa);
    padding: 0 2px;
    font-size: 13px;
}

.dm-pagination__meta {
    margin-left: 8px;
    font-size: 12px;
    color: var(--color-text-subtle, #8898aa);
    font-weight: var(--fw-medium, 400);
}

@keyframes dmRowIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.dm-page-row-animate,
.fm-file-entry-animate {
    animation: dmRowIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
    backface-visibility: hidden;
}

.fm-file-entry-animate {
    animation-duration: 0.42s;
}

/* ── Empty state (glass) ── */
.fm-empty-glass {
    position: relative;
    overflow: hidden;
    margin: 8px 0 12px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.42);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow:
        0 10px 28px rgba(10, 37, 64, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.72),
        inset 0 -1px 0 rgba(255, 255, 255, 0.18),
        inset 0 0 20px 10px rgba(255, 255, 255, 0.28);
}

.fm-empty-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9), transparent);
    pointer-events: none;
}

.fm-empty-glass::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.34) 0%, transparent 52%, rgba(99, 91, 255, 0.06) 100%);
    pointer-events: none;
}

.fm-empty-glass__inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 20px;
    text-align: center;
    font-size: 14px;
    font-weight: var(--fw-semibold, 500);
    color: #334155;
    letter-spacing: -0.01em;
}

.fm-empty-glass__icon {
    font-size: 18px;
    color: #635bff;
    opacity: 0.92;
    flex-shrink: 0;
}

.fm-no-files-month {
    z-index: 1;
}

.fm-empty-glass--folder {
    margin: 0;
}

.fm-empty-glass--folder .fm-empty-glass__inner {
    padding: 28px 24px;
    color: #64748b;
}

.fm-empty-glass--folder .fm-empty-glass__icon {
    color: #94a3b8;
}

.dm-table-wrap,
#filesTableWrapper,
#filesTableWrapper .overflow-x-auto {
    overflow-x: hidden;
}

/* ── DMTech hub ── */
.dmtech-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.dmtech-hub-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px 20px;
    border-radius: 16px;
    border: 1px solid #e3e8ef;
    background: linear-gradient(180deg, #fff 0%, #fafbff 100%);
    text-decoration: none;
    color: inherit;
}

.dmtech-hub-card:hover {
    border-color: #c7d2fe;
}

.dmtech-hub-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.dmtech-hub-icon--ocr {
    background: #eef2ff;
    color: #4f46e5;
}

.dmtech-hub-icon--stats {
    background: #ecfdf5;
    color: #059669;
}

.dmtech-hub-title {
    font-size: 17px;
    font-weight: 700;
    color: #0a2540;
}

.dmtech-hub-desc {
    font-size: 13px;
    line-height: 1.45;
    color: #64748b;
    flex: 1;
}

.dmtech-hub-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #635bff;
}

/* ── DMTech floating return button ── */
.dmtech-return-btn {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 99999;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    border-radius: 999px;
    border: none;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.dmtech-return-btn[hidden] {
    display: none !important;
}

.dmtech-return-btn i {
    font-size: 18px;
}

@media (max-width: 768px) {
    .dmtech-return-btn {
        bottom: 16px;
        padding: 12px 22px;
        font-size: 14px;
    }
}
