/* 세금계산서 화면 공용 (작성 바 / 상세 작업 버튼 / 연동 설정 / 모달) */
.ti-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ti-btn {
    border: 1px solid var(--app-border);
    background: transparent;
    color: var(--app-text);
    border-radius: 6px;
    padding: 0.3rem 0.8rem;
    font-size: 0.875rem;
    cursor: pointer;
}

    .ti-btn:hover:not(:disabled) {
        background: var(--app-hover);
    }

    .ti-btn:disabled {
        opacity: 0.5;
        cursor: default;
    }

    .ti-btn.primary {
        background: #2563eb;
        border-color: #2563eb;
        color: #fff;
    }

        .ti-btn.primary:hover:not(:disabled) {
            background: #1d4ed8;
        }

    .ti-btn.danger {
        border-color: var(--app-danger);
        color: var(--app-danger);
    }

    .ti-btn.small {
        padding: 0.1rem 0.6rem;
        font-size: 0.8rem;
    }

.ti-mode {
    font-size: 0.8rem;
    color: var(--app-muted);
    border: 1px solid var(--app-border-soft);
    border-radius: 12px;
    padding: 0.1rem 0.6rem;
}

    .ti-mode.test {
        color: #fbbf24;
        border-color: rgba(251, 191, 36, 0.5);
    }

    .ti-mode.live {
        color: #4ade80;
        border-color: rgba(74, 222, 128, 0.5);
    }

    .ti-mode.none {
        color: #f87171;
        border-color: rgba(248, 113, 113, 0.5);
    }

.ti-setup {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--app-muted);
    text-decoration: none;
}

    .ti-setup:hover {
        color: var(--app-text);
    }

/* 모달 */
.ti-modal-back {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ti-modal {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 12px;
    width: min(640px, 100%);
    max-height: 90vh;
    overflow: auto;
    padding: 1rem 1.1rem;
    color: var(--app-text);
}

    .ti-modal h5 {
        margin: 0 0 0.3rem;
        font-weight: 700;
    }

.ti-hint {
    font-size: 0.82rem;
    color: var(--app-muted);
    margin-bottom: 0.75rem;
}

.ti-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    max-height: 50vh;
    overflow: auto;
}

.ti-group {
    font-size: 0.78rem;
    color: var(--app-muted);
    margin: 0.5rem 0 0.15rem;
    font-weight: 600;
}

.ti-row {
    display: grid;
    grid-template-columns: auto 50px 1fr auto auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
}

    .ti-row:hover {
        background: var(--app-hover);
    }

    .ti-row.disabled {
        opacity: 0.4;
        cursor: default;
    }

div.ti-row {
    grid-template-columns: 1fr auto auto auto;
    cursor: default;
}

.ti-date {
    color: var(--app-muted);
    font-size: 0.8rem;
}

.ti-name small {
    color: var(--app-muted);
    margin-left: 0.3rem;
}

.ti-num {
    text-align: right;
    white-space: nowrap;
}

.ti-total {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    text-align: right;
    color: var(--app-text);
}

.ti-month {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    font-weight: 600;
}

.ti-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.ti-error {
    margin-top: 0.6rem;
    color: #f87171;
    font-size: 0.85rem;
    white-space: pre-line;
}

/* 상세 화면 작업 영역 */
.ti-panel {
    border: 1px solid var(--app-border-soft);
    border-radius: 10px;
    background: var(--app-surface);
    padding: 0.75rem 0.9rem;
    margin: 0.5rem 0 1rem;
}

.ti-panel-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ti-status {
    font-weight: 700;
    font-size: 0.95rem;
}

.ti-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-left: auto;
}

.ti-message {
    margin-top: 0.45rem;
    font-size: 0.85rem;
    color: var(--app-muted);
    white-space: pre-line;
}

.ti-nts {
    margin-top: 0.3rem;
    font-size: 0.85rem;
}

    .ti-nts b {
        font-family: Consolas, monospace;
        letter-spacing: 0.02em;
    }

.ti-confirm {
    margin-top: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(251, 191, 36, 0.5);
    background: rgba(251, 191, 36, 0.08);
    font-size: 0.875rem;
}

    .ti-confirm .ti-actions {
        margin-top: 0.5rem;
    }

.ti-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.6rem;
    font-size: 0.85rem;
}

    .ti-field input, .ti-field select {
        background: var(--app-bg);
        color: var(--app-text);
        border: 1px solid var(--app-border);
        border-radius: 6px;
        padding: 0.3rem 0.5rem;
    }

.ti-radio {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
}

    .ti-radio:hover {
        background: var(--app-hover);
    }

    .ti-radio small {
        display: block;
        color: var(--app-muted);
    }

.ti-amend-line {
    display: grid;
    grid-template-columns: 1fr 140px auto;
    gap: 0.4rem;
    margin-bottom: 0.35rem;
}

    .ti-amend-line input {
        background: var(--app-bg);
        color: var(--app-text);
        border: 1px solid var(--app-border);
        border-radius: 6px;
        padding: 0.3rem 0.5rem;
        min-width: 0;
    }

/* 연동 설정 */
.ti-setup-page {
    max-width: 760px;
    margin: 0 auto;
}

.ti-step {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 0.6rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--app-border-soft);
}

.ti-step-no {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    border: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

    .ti-step-no.done {
        background: rgba(34, 197, 94, 0.2);
        border-color: rgba(34, 197, 94, 0.7);
        color: #4ade80;
    }

.ti-step h6 {
    margin: 0.15rem 0 0.35rem;
    font-weight: 700;
}

.ti-step p, .ti-step li {
    font-size: 0.875rem;
    color: var(--app-muted);
}

.ti-step code {
    font-size: 0.8rem;
    background: var(--app-bg);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    user-select: all;
}

.ti-ok {
    color: #4ade80;
    font-size: 0.875rem;
}

.ti-warn {
    color: #fbbf24;
    font-size: 0.875rem;
}

@media (max-width: 640.98px) {
    .ti-row {
        grid-template-columns: auto 44px 1fr auto;
    }

        .ti-row .ti-num:last-child {
            display: none;
        }

    .ti-setup {
        margin-left: 0;
    }

    .ti-panel-actions {
        margin-left: 0;
        width: 100%;
    }
}

/* 볼타 API 키 등록 (앱에서) */
.ti-key-input {
    flex: 1 1 260px;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--app-border, #ccc);
    background: var(--app-surface, #fff);
    color: var(--app-text, inherit);
    font-family: monospace;
}

.ti-key-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.4rem 0;
}

.ti-key-line small {
    color: var(--app-muted, #888);
}

.ti-btn.danger {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}
