/* ===== KRT Trading Console Styles — Space Gray Dark Theme ===== */

.krt-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #e4e8ef;
}

/* ── Login Required ── */
.krt-login-required {
    text-align: center;
    padding: 60px 20px;
    background: #272c33;
    border-radius: 8px;
    margin: 20px 0;
    color: #b0b8c8;
}
.krt-login-required a { color: #d4a843; font-weight: 600; }

/* ── Login Banner (비로그인 대시보드) ── */
.krt-login-banner {
    background: linear-gradient(135deg, #363d47 0%, #272c33 100%);
    border: 1px solid #d4a843;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 16px;
    text-align: center;
    font-size: 14px;
    color: #b0b8c8;
}
.krt-login-banner a {
    color: #d4a843;
    font-weight: 700;
    text-decoration: underline;
}
.krt-login-banner a:hover {
    color: #e8c36a;
}

/* ── Role Notice (구독자 안내) ── */
.krt-role-notice {
    background: rgba(76,154,255,0.08);
    border: 1px solid rgba(76,154,255,0.3);
    border-radius: 8px;
    padding: 10px 20px;
    margin-bottom: 16px;
    text-align: center;
    font-size: 13px;
    color: #4c9aff;
}

/* ── Account Selector ── */
.krt-account-selector {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.krt-account-selector label {
    font-weight: 600;
    color: #b0b8c8;
    white-space: nowrap;
}
.krt-account-selector select {
    padding: 8px 12px;
    border: 1px solid #454d58;
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
    background: #22272e;
    color: #e4e8ef;
}

/* ── Cards ── */
.krt-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.krt-card {
    background: #2e343c;
    border: 1px solid #454d58;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.krt-card-label {
    font-size: 13px;
    color: #8a919d;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.krt-card-value {
    font-size: 24px;
    font-weight: 700;
    color: #e4e8ef;
}
.krt-card-value.positive { color: #ff5252; }
.krt-card-value.negative { color: #4c9aff; }

/* ── Sections ── */
.krt-section {
    background: #2e343c;
    border: 1px solid #454d58;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.krt-section h3 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: #e4e8ef;
    border-bottom: 2px solid #d4a843;
    padding-bottom: 8px;
}

/* ── Tables ── */
.krt-table-wrap { overflow-x: auto; }
.krt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.krt-table th {
    background: #272c33;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #b0b8c8;
    border-bottom: 2px solid #454d58;
    white-space: nowrap;
}
.krt-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #3a4150;
    color: #e4e8ef;
}
.krt-table tbody tr:hover { background: rgba(212,168,67,0.04); }
.krt-table .buy { color: #ff5252; font-weight: 600; }
.krt-table .sell { color: #4c9aff; font-weight: 600; }

/* ── Tabs ── */
.krt-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #454d58;
    margin-bottom: 20px;
    overflow-x: auto;
}
.krt-tab {
    padding: 10px 18px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #8a919d;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: all 0.2s;
}
.krt-tab:hover { color: #d4a843; }
.krt-tab.active {
    color: #d4a843;
    border-bottom-color: #d4a843;
    font-weight: 600;
}
.krt-tab-content.hidden { display: none; }

/* ── Buttons ── */
.krt-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.krt-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.krt-btn-primary {
    background: linear-gradient(135deg, #d4a843 0%, #e8c36a 100%);
    color: #1e2228;
}
.krt-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #e8c36a 0%, #d4a843 100%);
    box-shadow: 0 4px 16px rgba(212,168,67,0.3);
}
.krt-btn-success { background: #00d68f; color: #1e2228; }
.krt-btn-success:hover:not(:disabled) { background: #00f0a0; }
.krt-btn-danger { background: #ff5252; color: #fff; }
.krt-btn-danger:hover:not(:disabled) { background: #ff6b6b; }
.krt-btn-outline {
    background: transparent;
    color: #b0b8c8;
    border: 1px solid #454d58;
}
.krt-btn-outline:hover:not(:disabled) {
    background: rgba(212,168,67,0.08);
    color: #d4a843;
    border-color: #d4a843;
}
.krt-btn-small { padding: 6px 12px; font-size: 12px; }

/* ── Trading Controls ── */
.krt-trading-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.krt-global-controls .krt-trading-controls {
    margin-top: 4px;
}

/* 전체 시작/중지 버튼 */
.krt-btn-start-all { background: #ff5252; color: #fff; }
.krt-btn-start-all:hover:not(:disabled) { background: #ff6b6b; box-shadow: 0 4px 16px rgba(255,82,82,0.3); }
.krt-btn-stop-all { background: #4c9aff; color: #fff; }
.krt-btn-stop-all:hover:not(:disabled) { background: #6bb0ff; box-shadow: 0 4px 16px rgba(76,154,255,0.3); }

/* 개별 계좌 시작/중지 버튼 */
.krt-btn-start-acct { background: #ff5252; color: #fff; }
.krt-btn-start-acct:hover:not(:disabled) { background: #ff6b6b; }
.krt-btn-stop-acct { background: #4c9aff; color: #fff; }
.krt-btn-stop-acct:hover:not(:disabled) { background: #6bb0ff; }

/* 상태 뱃지 */
.krt-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.krt-st-running { background: rgba(255,82,82,0.12); color: #ff5252; }
.krt-st-stopped { background: rgba(76,154,255,0.12); color: #4c9aff; }
.krt-st-unknown { background: rgba(138,145,157,0.12); color: #8a919d; }

.krt-td-time { font-size: 12px; color: #8a919d; }

/* 대기 중인 명령 */
.krt-badge {
    display: inline-block;
    background: #d4a843;
    color: #1e2228;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
}
.krt-badge-zero { background: #454d58; color: #8a919d; }

.krt-pending-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.krt-pending-list li {
    padding: 8px 12px;
    border-left: 3px solid #d4a843;
    background: rgba(212,168,67,0.06);
    margin-bottom: 6px;
    border-radius: 0 4px 4px 0;
    font-size: 13px;
    color: #e4e8ef;
}

/* 로딩/빈 상태 */
.krt-loading { text-align: center; padding: 20px; color: #8a919d; }
.krt-muted   { color: #8a919d; font-size: 14px; }

/* ── Log Viewer ── */
.krt-log-viewer {
    background: #1a1f25;
    color: #7ec8e3;
    font-family: "Fira Code", "Consolas", monospace;
    font-size: 12px;
    line-height: 1.6;
    padding: 16px;
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    border: 1px solid #3a4150;
}
.krt-log-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 10px;
}
.krt-log-controls label {
    font-size: 13px;
    color: #8a919d;
}

/* ── Settings Form ── */
.krt-settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.krt-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.krt-field label {
    font-size: 13px;
    font-weight: 600;
    color: #b0b8c8;
}
.krt-field input,
.krt-field select,
.krt-field textarea {
    padding: 8px 12px;
    border: 1px solid #454d58;
    border-radius: 6px;
    font-size: 14px;
    background: #22272e;
    color: #e4e8ef;
}
.krt-field input:focus,
.krt-field select:focus {
    border-color: #d4a843;
    outline: none;
    box-shadow: 0 0 0 2px rgba(212,168,67,0.15);
}

/* ── Toast ── */
.krt-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 12px 20px;
    background: #00d68f;
    color: #1e2228;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    z-index: 9999;
    transition: opacity 0.3s;
}
.krt-toast.error { background: #ff5252; color: #fff; }
.krt-toast.hidden { opacity: 0; pointer-events: none; }

/* ── Accounts Page ── */
.krt-accounts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.krt-accounts-header h3 {
    margin-bottom: 0 !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
}
.krt-td-key {
    font-family: "Fira Code", "Consolas", monospace;
    font-size: 11px;
    color: #8a919d;
    letter-spacing: 0.03em;
}
.krt-td-actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}
.krt-btn-edit {
    background: #4c9aff !important;
    color: #fff !important;
}
.krt-btn-edit:hover { background: #6bb0ff !important; }
.krt-btn-delete {
    background: transparent !important;
    color: #ff5252 !important;
    border: 1px solid #ff5252 !important;
}
.krt-btn-delete:hover {
    background: #ff5252 !important;
    color: #fff !important;
}
.krt-badge-mock {
    display: inline-block;
    background: rgba(212,168,67,0.12);
    color: #e8c36a;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}
.krt-text-danger { color: #ff5252; font-size: 13px; }

/* ── Modal ── */
.krt-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.krt-modal.hidden { display: none; }
.krt-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}
.krt-modal-content {
    position: relative;
    background: #2e343c;
    border: 1px solid #454d58;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
    animation: krt-modal-in 0.2s ease;
}
.krt-modal-sm { max-width: 420px; }
@keyframes krt-modal-in {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.krt-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #454d58;
}
.krt-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #e4e8ef;
}
.krt-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #8a919d;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.krt-modal-close:hover { color: #e4e8ef; }
.krt-modal-body { padding: 20px 24px; color: #e4e8ef; }
.krt-modal-content form { padding: 20px 24px; }
.krt-modal-content .krt-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.krt-modal-content .krt-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #b0b8c8;
}
.krt-modal-content .krt-form-group input,
.krt-modal-content .krt-form-group select {
    padding: 9px 12px;
    border: 1px solid #454d58;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    background: #22272e;
    color: #e4e8ef;
}
.krt-modal-content .krt-form-group input:focus,
.krt-modal-content .krt-form-group select:focus {
    border-color: #d4a843;
    outline: none;
    box-shadow: 0 0 0 2px rgba(212,168,67,0.15);
}
.krt-modal-content .krt-form-group input[readonly] {
    background: #1e2228;
    color: #8a919d;
    cursor: not-allowed;
}
.krt-modal-content .krt-form-actions {
    display: flex;
    gap: 10px;
    padding-top: 10px;
    margin-top: 8px;
    border-top: 1px solid #3a4150;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .krt-cards { grid-template-columns: repeat(2, 1fr); }
    .krt-card-value { font-size: 18px; }
    .krt-trading-controls { flex-direction: column; }
    .krt-btn { width: 100%; justify-content: center; }
    .krt-tabs { gap: 0; }
    .krt-tab { padding: 8px 12px; font-size: 13px; }
}
