/* ===== Document Flow Module ===== */

.df-app {
    --df-accent: #0F766E;
    --df-accent-soft: #CCFBF1;
    --df-accent-deep: #134E4A;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 72px);
}

/* ===== Topbar ===== */
.df-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
    padding: 0 32px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.df-topbar-left { display: flex; align-items: center; gap: 32px; }
.df-title { font-size: 22px; font-weight: 600; color: var(--color-text-dark); }

.df-tabs { display: flex; gap: 4px; }
.df-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: background .12s, color .12s;
}
.df-tab:hover { background: var(--color-bg-soft); color: var(--color-text-body); }
.df-tab.active {
    background: var(--df-accent-soft);
    color: var(--df-accent);
    font-weight: 600;
}
[data-theme="dark"] .df-tab.active { background: rgba(15,118,110,0.22); }

.df-topbar-right { display: flex; align-items: center; gap: 12px; }

.df-search { position: relative; }
.df-search-icon {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
}
.df-search-input {
    width: 260px; height: 40px;
    padding: 0 14px 0 38px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--color-text-body);
    background: var(--color-bg);
}
.df-search-input:focus {
    outline: none;
    border-color: var(--df-accent);
    box-shadow: 0 0 0 3px rgba(15,118,110,0.15);
}

.df-icon-btn {
    width: 40px; height: 40px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 8px;
    color: var(--color-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.df-icon-btn:hover { color: var(--df-accent); border-color: var(--df-accent); }

.df-tmpl-btn, .df-add-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 40px; padding: 0 14px;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}
.df-add-btn {
    background: var(--df-accent);
    color: #fff;
    border: 1px solid var(--df-accent);
}
.df-add-btn:hover { background: var(--df-accent-deep); border-color: var(--df-accent-deep); }

/* ===== Tab content ===== */
.df-tab-content { display: none; flex: 1; }
.df-tab-content.active { display: flex; flex-direction: column; }
.df-view { display: flex; flex: 1; min-height: 0; }

/* ===== Sidebar ===== */
.df-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--color-bg-soft);
    border-right: 1px solid var(--color-border);
    padding: 24px;
    overflow-y: auto;
}
.df-filter-group { margin-bottom: 28px; }
.df-filter-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 0 0 10px;
}
.df-filter-list { list-style: none; padding: 0; margin: 0; }
.df-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    font-size: 14px;
    color: var(--color-text-body);
    cursor: pointer;
    border-radius: 6px;
}
.df-filter-item:hover { background: var(--color-bg); }
.df-filter-item.active { background: var(--df-accent-soft); color: var(--df-accent); font-weight: 500; }
[data-theme="dark"] .df-filter-item.active { background: rgba(15,118,110,0.22); }
.df-filter-item label { flex: 1; cursor: pointer; }
.df-filter-item input[type="checkbox"] { accent-color: var(--df-accent); cursor: pointer; }
.df-filter-count {
    font-size: 12px;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 1px 7px;
    border-radius: 10px;
}
.df-filter-count.danger {
    background: #FEE2E2;
    color: #B91C1C;
    border-color: #FECACA;
}
[data-theme="dark"] .df-filter-count.danger { background: rgba(220,38,38,0.2); color: #FCA5A5; border-color: transparent; }
.df-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ===== Main ===== */
.df-main { flex: 1; min-width: 0; padding: 24px 32px; overflow: auto; }
.df-subheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.df-list-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-dark);
    margin: 0;
}
.df-list-count { color: var(--color-text-muted); font-weight: 400; margin-left: 4px; }
.df-mini-stats { display: flex; gap: 16px; font-size: 13px; color: var(--color-text-muted); }
.df-mini-stats strong { color: var(--color-text-dark); font-weight: 600; }

/* ===== Table ===== */
.df-table-wrap {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
}
.df-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.df-table thead th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 12px 16px;
    background: var(--color-bg-soft);
    border-bottom: 1px solid var(--color-border);
}
.df-table tbody tr {
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background .1s;
}
.df-table tbody tr:last-child { border-bottom: none; }
.df-table tbody tr:hover { background: var(--color-bg-soft); }
.df-table td { padding: 14px 16px; color: var(--color-text-body); vertical-align: middle; }
.df-col-actions { width: 80px; text-align: right; }
.df-muted { color: var(--color-text-muted); }

.df-doc-cell { display: flex; align-items: center; gap: 12px; }
.df-doc-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.df-doc-icon.lg { width: 48px; height: 48px; border-radius: 10px; }
.df-doc-name { font-weight: 500; color: var(--color-text-dark); line-height: 1.2; }
.df-doc-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; font-family: 'SF Mono', ui-monospace, monospace; }

.df-type-chip {
    display: inline-block;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--color-bg-soft);
    border: 1px solid var(--color-border);
    color: var(--color-text-body);
}

.df-owner-cell { display: flex; align-items: center; gap: 8px; }
.df-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.df-status {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
}
.df-st-draft { background: var(--color-bg-soft); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.df-st-awaiting { background: #FEF3C7; color: #92400E; }
.df-st-progress { background: #DBEAFE; color: #1D4ED8; }
.df-st-approved { background: #DCFCE7; color: #166534; }
.df-st-rejected { background: #FEE2E2; color: #991B1B; }
[data-theme="dark"] .df-st-awaiting { background: rgba(245,158,11,0.18); color: #FCD34D; }
[data-theme="dark"] .df-st-progress { background: rgba(37,99,235,0.18); color: #93C5FD; }
[data-theme="dark"] .df-st-approved { background: rgba(34,197,94,0.18); color: #86EFAC; }
[data-theme="dark"] .df-st-rejected { background: rgba(239,68,68,0.18); color: #FCA5A5; }

.df-step { font-size: 13px; color: var(--color-text-body); }

.df-link-chip {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    padding: 2px 8px;
    border-radius: 6px;
    margin-right: 4px;
}
.df-lk-hr { background: #E0E7FF; color: #4338CA; }
.df-lk-fin { background: #DCFCE7; color: #166534; }
.df-lk-proj { background: #FEF3C7; color: #92400E; }
.df-lk-sd { background: #DBEAFE; color: #1D4ED8; }
.df-lk-cal { background: #F3E8FF; color: #6B21A8; }
[data-theme="dark"] .df-lk-hr { background: rgba(67,56,202,0.25); color: #C7D2FE; }
[data-theme="dark"] .df-lk-fin { background: rgba(22,101,52,0.25); color: #86EFAC; }
[data-theme="dark"] .df-lk-proj { background: rgba(146,64,14,0.25); color: #FCD34D; }
[data-theme="dark"] .df-lk-sd { background: rgba(29,78,216,0.25); color: #93C5FD; }
[data-theme="dark"] .df-lk-cal { background: rgba(107,33,168,0.25); color: #C4B5FD; }

.df-row-action {
    width: 28px; height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.df-row-action:hover { background: var(--color-bg-soft); color: var(--color-text-dark); }

/* ===== Document detail ===== */
.df-detail-view { flex-direction: column; padding: 24px 32px; overflow: auto; }
.df-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.df-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 14px;
    padding: 6px 8px;
    border-radius: 6px;
}
.df-back-btn:hover { background: var(--color-bg-soft); color: var(--color-text-dark); }
.df-detail-actions { display: flex; gap: 8px; align-items: center; }
.df-btn-sm {
    height: 36px;
    padding: 0 14px;
    font-size: 13px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
}

.df-detail-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}

.df-detail-left {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
}
.df-detail-title-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}
.df-detail-title {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-dark);
}
.df-detail-meta { display: flex; gap: 10px; align-items: center; font-size: 13px; }

.df-def-list { display: flex; flex-direction: column; gap: 10px; margin: 0 0 20px; }
.df-def-list > div {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    font-size: 13px;
    align-items: start;
}
.df-def-list dt { color: var(--color-text-muted); margin: 0; }
.df-def-list dd { color: var(--color-text-body); margin: 0; }

.df-section-title {
    margin: 16px 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.df-links { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.df-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--color-text-body);
    text-decoration: none;
    background: var(--color-bg-soft);
}
.df-link:hover { border-color: var(--df-accent); }
.df-link strong { color: var(--color-text-dark); font-weight: 600; }
.df-link.df-lk-hr svg { color: #4338CA; }
.df-link.df-lk-fin svg { color: #166534; }
.df-link.df-lk-proj svg { color: #92400E; }

/* Document preview */
.df-preview {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
}
.df-preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--color-bg-soft);
    border-bottom: 1px solid var(--color-border);
    font-size: 12px;
    color: var(--color-text-muted);
}
.df-preview-tools { display: flex; align-items: center; gap: 4px; }
.df-preview-tools button {
    width: 24px; height: 24px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 4px;
    color: var(--color-text-body);
    font-size: 13px;
    cursor: pointer;
}
.df-preview-body {
    background: var(--color-bg-soft);
    padding: 24px;
    display: flex;
    justify-content: center;
}
.df-preview-page {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
    width: 100%;
    max-width: 520px;
    padding: 40px 48px;
    min-height: 500px;
    color: #0F172A;
}
[data-theme="dark"] .df-preview-page { background: #F8FAFC; }
.df-prev-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 20px;
    color: #0F172A;
}
.df-prev-line {
    height: 8px;
    background: #E2E8F0;
    border-radius: 4px;
    margin-bottom: 8px;
}
.df-prev-para { height: 12px; }
.df-prev-sig {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 50px;
}
.df-prev-sig > div { text-align: center; }
.df-prev-sig-line {
    height: 1px;
    background: #94A3B8;
    margin-bottom: 6px;
}
.df-prev-sig span { font-size: 11px; color: #64748B; }

/* ===== Right column (workflow/actions) ===== */
.df-detail-right { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }

.df-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 18px;
}
.df-card-title {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-dark);
}

/* Timeline */
.df-timeline {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}
.df-timeline li {
    display: grid;
    grid-template-columns: 20px 1fr;
    gap: 12px;
    position: relative;
    padding-bottom: 18px;
}
.df-timeline li:last-child { padding-bottom: 0; }
.df-timeline li::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 16px;
    bottom: -2px;
    width: 2px;
    background: var(--color-border);
}
.df-timeline li:last-child::before { display: none; }
.df-tl-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    margin-top: 4px;
    z-index: 1;
}
.df-timeline li.done .df-tl-dot {
    background: var(--df-accent);
    border-color: var(--df-accent);
}
.df-timeline li.done::before { background: var(--df-accent); }
.df-timeline li.current .df-tl-dot {
    background: #F59E0B;
    border-color: #F59E0B;
    box-shadow: 0 0 0 4px rgba(245,158,11,0.2);
}
.df-tl-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-dark);
}
.df-tl-meta {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}
.df-timeline li:not(.done):not(.current) .df-tl-title { color: var(--color-text-muted); }

/* Approvers */
.df-approvers { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.df-approvers li {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    gap: 10px;
    align-items: center;
}
.df-appr-body { font-size: 13px; color: var(--color-text-body); line-height: 1.3; }
.df-appr-state {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--color-bg-soft);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}
.df-appr-state.done { background: #DCFCE7; color: #166534; border-color: transparent; }
.df-appr-state.pending { background: #FEF3C7; color: #92400E; border-color: transparent; }
[data-theme="dark"] .df-appr-state.done { background: rgba(34,197,94,0.22); color: #86EFAC; }
[data-theme="dark"] .df-appr-state.pending { background: rgba(245,158,11,0.22); color: #FCD34D; }

/* Actions card */
.df-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.df-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-body);
    cursor: pointer;
}
.df-action:hover { border-color: var(--df-accent); }
.df-a-approve { background: var(--df-accent); color: #fff; border-color: var(--df-accent); }
.df-a-approve:hover { background: var(--df-accent-deep); border-color: var(--df-accent-deep); }
.df-a-reject:hover { color: #B91C1C; border-color: #B91C1C; }
.df-a-return:hover { color: #B45309; border-color: #B45309; }

.df-comment { display: flex; flex-direction: column; gap: 6px; }
.df-comment label { font-size: 12px; color: var(--color-text-muted); }
.df-comment textarea {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--color-text-body);
    background: var(--color-bg);
    resize: vertical;
    min-height: 70px;
}
.df-comment textarea:focus {
    outline: none;
    border-color: var(--df-accent);
    box-shadow: 0 0 0 3px rgba(15,118,110,0.15);
}

/* History */
.df-history { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.df-history li {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
    color: var(--color-text-body);
}
.df-history li:last-child { border-bottom: none; }
.df-history strong { color: var(--color-text-dark); font-weight: 600; }
.df-history time { font-size: 11px; color: var(--color-text-muted); white-space: nowrap; }
.df-hist-icon {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--color-bg-soft);
    color: var(--color-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

/* ===== Workflow tab ===== */
.df-wf-mode { display: none; }
.df-wf-mode.active { display: block; }

.df-deadline {
    display: inline-block;
    font-size: 13px;
    color: var(--color-text-body);
}
.df-deadline.urgent { color: #B91C1C; font-weight: 500; }

.df-prio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-body);
}
.df-prio-dot { width: 8px; height: 8px; border-radius: 50%; }
.df-p-urgent .df-prio-dot { background: #DC2626; }
.df-p-normal .df-prio-dot { background: #F59E0B; }
.df-p-low .df-prio-dot { background: #94A3B8; }

.df-decide { display: inline-flex; gap: 4px; }
.df-d-btn {
    width: 28px; height: 28px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
}
.df-d-btn.approve { color: var(--df-accent); }
.df-d-btn.approve:hover { background: var(--df-accent); color: #fff; border-color: var(--df-accent); }
.df-d-btn.reject { color: #DC2626; }
.df-d-btn.reject:hover { background: #DC2626; color: #fff; border-color: #DC2626; }

/* Workflow defs grid */
.df-wf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.df-wf-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 18px;
    cursor: pointer;
    transition: border-color .12s, box-shadow .12s;
}
.df-wf-card:hover {
    border-color: var(--df-accent);
    box-shadow: 0 2px 8px rgba(15,118,110,0.08);
}
.df-wf-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.df-wf-card h4 { margin: 0; font-size: 15px; font-weight: 600; color: var(--color-text-dark); }
.df-wf-meta { font-size: 12px; color: var(--color-text-muted); margin: 0 0 14px; }
.df-wf-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.df-wf-steps li {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: var(--color-text-body);
}
.df-wf-n {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--df-accent-soft);
    color: var(--df-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}
[data-theme="dark"] .df-wf-n { background: rgba(15,118,110,0.25); color: #5EEAD4; }

.df-pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    padding: 2px 8px;
    border-radius: 999px;
}
.df-pill-active { background: #DCFCE7; color: #166534; }
.df-pill-draft { background: var(--color-bg-soft); color: var(--color-text-muted); border: 1px solid var(--color-border); }
[data-theme="dark"] .df-pill-active { background: rgba(34,197,94,0.22); color: #86EFAC; }

/* ===== Templates tab — fields preview ===== */
.df-tmpl-preview {
    margin-top: 20px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 20px;
}
.df-tmpl-preview-header { margin-bottom: 14px; }
.df-tmpl-preview-header h3 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-dark);
}
.df-tmpl-preview-header .df-muted { font-size: 13px; }
.df-tmpl-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 8px;
}
.df-tf {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: var(--color-bg-soft);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 13px;
}
.df-tf-key {
    font-family: 'SF Mono', ui-monospace, monospace;
    color: var(--df-accent);
    font-size: 12px;
}
.df-tf-sep { color: var(--color-text-muted); }
.df-tf-val { color: var(--color-text-dark); font-weight: 500; }

/* ===== Modal ===== */
.df-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.df-modal-overlay[hidden] { display: none; }
.df-modal {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
}
.df-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
}
.df-modal-header h3 { margin: 0; font-size: 18px; font-weight: 600; color: var(--color-text-dark); }
.df-modal-close {
    width: 32px; height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}
.df-modal-close:hover { background: var(--color-bg-soft); color: var(--color-text-dark); }

.df-stepper {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-soft);
}
.df-step {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--color-text-muted);
}
.df-step.active { color: var(--df-accent); background: var(--df-accent-soft); font-weight: 600; }
[data-theme="dark"] .df-step.active { background: rgba(15,118,110,0.22); }
.df-step.done { color: var(--color-text-dark); }
.df-step-n {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}
.df-step.active .df-step-n {
    background: var(--df-accent);
    color: #fff;
    border-color: var(--df-accent);
}
.df-step.done .df-step-n {
    background: var(--df-accent-soft);
    color: var(--df-accent);
    border-color: transparent;
}

.df-step-body { display: none; padding: 24px; }
.df-step-body.active { display: block; }

.df-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.df-field label { font-size: 13px; font-weight: 500; color: var(--color-text-dark); }
.df-field input[type="text"],
.df-field input[type="date"],
.df-field select,
.df-field textarea {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--color-text-body);
    background: var(--color-bg);
}
.df-field input:focus,
.df-field select:focus,
.df-field textarea:focus {
    outline: none;
    border-color: var(--df-accent);
    box-shadow: 0 0 0 3px rgba(15,118,110,0.15);
}
.df-field textarea { resize: vertical; min-height: 80px; }
.df-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.df-dropzone {
    border: 2px dashed var(--color-border);
    border-radius: 10px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--color-bg-soft);
    color: var(--color-text-body);
    cursor: pointer;
    margin-bottom: 16px;
}
.df-dropzone:hover { border-color: var(--df-accent); color: var(--df-accent); }
.df-dropzone strong { display: block; font-size: 14px; color: var(--color-text-dark); }
.df-dropzone .df-muted { font-size: 12px; }

.df-wiz-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.df-wiz-steps li {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-soft);
}
.df-wiz-steps li span:last-child { display: flex; justify-content: space-between; font-size: 13px; color: var(--color-text-body); }
.df-wiz-steps strong { color: var(--color-text-dark); font-weight: 600; }
.df-wiz-steps em { font-style: normal; color: var(--color-text-muted); font-size: 12px; }

.df-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-soft);
}
.df-modal-footer-right { margin-left: auto; display: flex; gap: 8px; }

/* ===== Actions card: full width buttons ===== */
.df-actions-card .df-action {
    padding: 10px;
    font-size: 12px;
}

/* ===== Responsive ===== */
@media (max-width: 1180px) {
    .df-detail-grid { grid-template-columns: 1fr; }
    .df-detail-right { position: static; }
}
@media (max-width: 1024px) {
    .df-search-input { width: 200px; }
}
@media (max-width: 768px) {
    .df-topbar { flex-direction: column; height: auto; padding: 12px 16px; gap: 12px; align-items: stretch; }
    .df-topbar-left { flex-direction: column; gap: 12px; align-items: flex-start; }
    .df-topbar-right { flex-wrap: wrap; gap: 8px; }
    .df-search-input { width: 100%; }
    .df-view { flex-direction: column; }
    .df-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--color-border); }
    .df-main { padding: 16px; }
    .df-detail-view { padding: 16px; }
    .df-stepper { flex-direction: column; gap: 4px; }
    .df-field-row { grid-template-columns: 1fr; }
    .df-action-grid { grid-template-columns: 1fr; }
    .df-wf-grid { grid-template-columns: 1fr; }
}
