/* Premium expense record modal — enterprise banking (exm-*) */

.exm-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(8, 15, 35, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.exm-dialog {
    width: 100%;
    max-width: 920px;
    max-height: 90vh;
    min-height: min(520px, 90vh);
    display: flex;
    flex-direction: column;
    background: #f7f9fc;
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.08) inset,
        0 32px 80px rgba(6, 16, 45, 0.45);
    animation: exm-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes exm-in {
    from { opacity: 0; transform: translateY(12px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header — ultra compact single row */
.exm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.22rem 0.5rem;
    min-height: 0;
    background: linear-gradient(125deg, #0b1f3f 0%, #14325f 42%, #1a4d8c 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.exm-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 120% at 100% 0%, rgba(96, 165, 250, 0.18), transparent 55%);
    pointer-events: none;
}

.exm-header-main {
    display: flex;
    align-items: center;
    gap: 0.32rem;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.exm-header-text {
    display: flex;
    align-items: center;
    gap: 0.28rem;
    flex-wrap: wrap;
    min-width: 0;
}

.exm-header-icon {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.exm-title {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
    line-height: 1.1;
    white-space: nowrap;
}

.exm-voucher {
    font-size: 0.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: rgba(255, 255, 255, 0.82);
    letter-spacing: 0.03em;
    line-height: 1.1;
}

.exm-status {
    font-size: 0.48rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.04rem 0.28rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    line-height: 1.2;
}

.exm-status--approved { background: rgba(34, 197, 94, 0.25); color: #bbf7d0; }
.exm-status--draft { background: rgba(251, 191, 36, 0.25); color: #fde68a; }
.exm-status--rejected { background: rgba(239, 68, 68, 0.25); color: #fecaca; }

.exm-close {
    position: relative;
    z-index: 1;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 5px;
    font-size: 0.65rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.exm-close:hover { background: rgba(255, 255, 255, 0.22); }

/* Lock banner */
.exm-lock {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.32rem 0.7rem;
    background: #fff7ed;
    border-bottom: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 0.62rem;
}

.exm-lock i { font-size: 1rem; margin-top: 0.1rem; flex-shrink: 0; }
.exm-lock strong { display: block; font-size: 0.76rem; margin-bottom: 0.1rem; }
.exm-lock span { color: #c2410c; opacity: 0.9; }

/* Body layout */
.exm-body {
    flex: 1;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 220px;
    min-height: 0;
}

.exm-main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 0.28rem 0.38rem;
    display: grid;
    grid-template-rows: auto minmax(0, 3fr);
    gap: 0.28rem;
}

.exm-panel--compact {
    min-height: 0;
    padding: 0.22rem 0.3rem 0.26rem;
}

.exm-panel--lines {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0.2rem;
}

.exm-panel--lines .exm-panel-head {
    flex-shrink: 0;
    margin-bottom: 0.15rem;
}

.exm-lines-scroll {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e8edf5;
    border-radius: 4px;
    background: #fafbfd;
}

.exm-aside {
    background: #fff;
    border-left: 1px solid #e5eaf3;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Panels */
.exm-panel {
    background: #fff;
    border: 1px solid #e8edf5;
    border-radius: 6px;
    padding: 0.28rem 0.35rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.exm-panel-head {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin-bottom: 0.2rem;
    font-size: 0.54rem;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.exm-panel-head i { color: #3b82f6; font-size: 0.72rem; }
.exm-panel-action { margin-left: auto; }

.exm-line-count {
    margin-left: 0.25rem;
    background: #1e3a5f;
    color: #fff;
    font-size: 0.58rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
}

.exm-fields-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.28rem 0.38rem;
}

.exm-fields-grid--dense {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.12rem 0.2rem;
}

.exm-span3 { grid-column: span 3; }

.exm-fields-grid--dense .exm-field {
    display: grid;
    grid-template-columns: minmax(2.1rem, auto) 1fr;
    align-items: center;
    column-gap: 0.18rem;
    row-gap: 0;
}

.exm-fields-grid--dense .exm-field span {
    margin: 0;
    white-space: nowrap;
}

.exm-fields-grid--dense .exm-field--readonly {
    grid-template-columns: minmax(2.4rem, auto) 1fr;
}

.exm-fields-grid--dense .exm-span3 {
    grid-template-columns: minmax(3.2rem, auto) 1fr;
}

.exm-field {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.exm-field--full { grid-column: 1 / -1; }

.exm-field span {
    font-size: 0.48rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    line-height: 1.1;
}

.exm-field span em { color: #ef4444; font-style: normal; }

.exm-field input,
.exm-field select {
    width: 100%;
    padding: 0.12rem 0.28rem;
    border: 1px solid #dbe3f0;
    border-radius: 4px;
    font-size: 0.62rem;
    line-height: 1.15;
    min-height: 1.28rem;
    color: #0f172a;
    background: #fafbfd;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.exm-field input:focus,
.exm-field select:focus {
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.exm-field input:disabled,
.exm-field select:disabled {
    opacity: 0.72;
    cursor: not-allowed;
    background: #f1f5f9;
}

.exm-field--readonly input {
    font-family: ui-monospace, monospace;
    color: #64748b;
}

/* Account */
.exm-account-wrap {
    display: block;
    position: relative;
}

.exm-account-ico {
    position: absolute;
    left: 0.38rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.68rem;
    pointer-events: none;
}

.exm-account-input {
    width: 100%;
    padding: 0.12rem 0.28rem 0.12rem 1.25rem !important;
    border: 1px solid #dbe3f0;
    border-radius: 4px;
    font-size: 0.62rem;
    line-height: 1.15;
    min-height: 1.28rem;
    background: #fafbfd;
}

/* Lines */
.exm-lines {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    padding: 0.2rem 0.22rem 0.28rem;
}

.exm-lines-head,
.exm-line {
    display: grid;
    grid-template-columns: 24px 1.1fr 1.4fr 100px 28px;
    gap: 0.35rem;
    align-items: center;
}

.exm-lines-head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 0.12rem 0.2rem 0.14rem;
    margin: 0 0 0.1rem;
    font-size: 0.52rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.exm-lines-head span:last-child:nth-child(5) { }

.exm-line {
    background: #f8fafc;
    border: 1px solid #e8edf5;
    border-radius: 8px;
    padding: 0.3rem 0.4rem;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.exm-line:hover {
    border-color: #bfdbfe;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.06);
}

.exm-line-no {
    text-align: center;
    font-size: 0.62rem;
    font-weight: 700;
    color: #94a3b8;
}

.exm-line-input {
    width: 100%;
    padding: 0.18rem 0.32rem;
    border: 1px solid #dbe3f0;
    border-radius: 4px;
    font-size: 0.64rem;
    background: #fff;
}

.exm-line-amt { text-align: right; font-variant-numeric: tabular-nums; }

.exm-line-remove {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: #fef2f2;
    color: #dc2626;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.exm-line-remove:hover { background: #fee2e2; }

.exm-lines-empty {
    text-align: center;
    padding: 1rem 0.65rem;
    margin: 0.2rem;
    min-height: 4.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 0.62rem;
}

.exm-lines-empty i { font-size: 1.4rem; display: block; margin-bottom: 0.35rem; opacity: 0.5; }
.exm-lines-empty p { margin: 0; }

/* Aside */
.exm-total-card {
    padding: 0.55rem 0.65rem;
    background: linear-gradient(145deg, #0b1f3f 0%, #1a4d8c 100%);
    color: #fff;
}

.exm-total-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.75;
}

.exm-total-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin: 0.2rem 0;
    font-variant-numeric: tabular-nums;
}

.exm-total-meta { font-size: 0.68rem; opacity: 0.7; }

.exm-cat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0.4rem 0.45rem 0.45rem;
}

.exm-cat-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.45rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #334155;
}

.exm-cat-hint { font-size: 0.6rem; font-weight: 500; color: #94a3b8; }

.exm-cat-search-wrap {
    position: relative;
    margin-bottom: 0.45rem;
}

.exm-cat-search-wrap i {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.8rem;
}

.exm-cat-search {
    width: 100%;
    padding: 0.35rem 0.5rem 0.35rem 1.75rem;
    border: 1px solid #dbe3f0;
    border-radius: 8px;
    font-size: 0.74rem;
    background: #f8fafc;
}

.exm-cat-search:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.exm-cat-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    padding-right: 0.15rem;
}

.exm-cat-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    padding: 0.26rem 0.38rem;
    border: 1px solid #e8edf5;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    font-size: 0.62rem;
    font-weight: 600;
    color: #475569;
    transition: all 0.14s;
}

.exm-cat-item:hover:not(:disabled) {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}

.exm-cat-item--on {
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
    border-color: #1e3a5f;
    color: #fff;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.25);
}

.exm-cat-item:disabled { opacity: 0.55; cursor: not-allowed; }

.exm-cat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.exm-cat-icon { font-size: 0.95rem; opacity: 0.85; flex-shrink: 0; }
.exm-cat-name { flex: 1; min-width: 0; line-height: 1.25; }
.exm-cat-check { font-size: 0.75rem; color: #4ade80; }
.exm-cat-none { font-size: 0.7rem; color: #94a3b8; text-align: center; padding: 0.75rem; }

/* Footer */
.exm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.3rem;
    flex-wrap: wrap;
    padding: 0.26rem 0.45rem;
    background: #fff;
    border-top: 1px solid #e8edf5;
}

.exm-footer-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.7rem;
    color: #64748b;
}

.exm-footer-meta small {
    display: block;
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

.exm-footer-meta strong { color: #0f172a; font-size: 0.76rem; }

.exm-footer-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.exm-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.28rem 0.6rem;
    border-radius: 6px;
    font-size: 0.64rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
}

.exm-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.exm-btn--outline {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #64748b;
}

.exm-btn--outline:hover:not(:disabled) { background: #f8fafc; }

.exm-btn--ghost {
    background: transparent;
    border: 1px dashed #93c5fd;
    color: #2563eb;
    padding: 0.25rem 0.55rem;
    font-size: 0.66rem;
}

.exm-btn--secondary {
    background: linear-gradient(135deg, #334155, #475569);
    color: #fff;
    box-shadow: 0 2px 6px rgba(51, 65, 85, 0.2);
}

.exm-btn--primary {
    background: linear-gradient(135deg, #047857, #10b981);
    color: #fff;
    box-shadow: 0 2px 8px rgba(4, 120, 87, 0.3);
}

.exm-btn--primary:hover:not(:disabled),
.exm-btn--secondary:hover:not(:disabled) {
    transform: translateY(-1px);
    opacity: 0.95;
}

.exm-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: exm-spin 0.65s linear infinite;
}

@keyframes exm-spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
    .exm-body { grid-template-columns: 1fr; }
    .exm-aside {
        border-left: none;
        border-top: 1px solid #e5eaf3;
        max-height: 240px;
    }
    .exm-cat-list {
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: auto;
    }
    .exm-cat-item { width: auto; flex: 1 1 calc(50% - 0.3rem); min-width: 140px; }
    .exm-fields-grid--dense { grid-template-columns: repeat(3, 1fr); }
    .exm-span3 { grid-column: span 3; }
    .exm-fields-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
    .exm-overlay { padding: 0; align-items: flex-end; }
    .exm-dialog { max-height: 96vh; border-radius: 16px 16px 0 0; }
    .exm-fields-grid,
    .exm-fields-grid--dense { grid-template-columns: 1fr; }
    .exm-span3 { grid-column: 1 / -1; }
    .exm-lines-head { display: none; }
    .exm-line {
        grid-template-columns: 24px 1fr 28px;
        grid-template-rows: auto auto;
    }
    .exm-line .exm-line-input:nth-child(3) { grid-column: 2 / 3; }
    .exm-line .exm-line-amt { grid-column: 2 / 3; }
    .exm-line-remove { grid-row: 1 / 3; grid-column: 3; align-self: center; }
    .exm-footer { flex-direction: column; align-items: stretch; }
    .exm-footer-actions { justify-content: flex-end; }
}
