:root {
    --k-bg: #f5f6fa;
    --k-surface: #ffffff;
    --k-primary: #8f6bff;
    --k-primary-h: #7a57ff;
    --k-success: #4fd1c5;
    --k-success-h: #3fbcb0;
    --k-text: #1f2937;
    --k-muted: #6b7280;
    --k-border: #e5e7eb;
    --k-shadow: 0 4px 10px rgba(0,0,0,.05);
}

#kaldia-root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    background: var(--k-bg);
    padding: 32px;
    border-radius: 10px;
}

.kaldia-wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

.kaldia-header {
    background: var(--k-surface);
    border-radius: 14px;
    box-shadow: var(--k-shadow);
    padding: 32px 40px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: 32px;
}

.kaldia-header h1 {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--k-text);
    line-height: 1.3;
}

.kaldia-header p {
    margin: 0;
    line-height: 1.6;
    max-width: 720px;
    color: var(--k-muted);
}

.kaldia-highlight {
    font-weight: 600;
    color: var(--k-primary);
    background: rgba(143, 107, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.kaldia-card {
    background: var(--k-surface);
    border-radius: 14px;
    box-shadow: var(--k-shadow);
    overflow-x: auto;
}

.kaldia-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.kaldia-table tr {
    border-bottom: 1px solid var(--k-border);
}

.kaldia-table td {
    padding: 20px 28px;
    vertical-align: middle;
}

.kaldia-table td:nth-child(3) {
    padding-left: 40px;
    width: 200px;
}

.kaldia-table td:last-child {
    text-align: right;
}

.kaldia-table .kaldia-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.kaldia-row-title {
    font-weight: 500;
    color: var(--k-text);
    transition: color .15s;
}

.kaldia-row-title a:hover {
    color: var(--k-primary);
    text-decoration: underline;
}

.k-btn {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    transition: background .18s, transform .15s;
    box-shadow: 0 2px 4px rgba(0,0,0,.04);
    cursor: pointer;
}

.k-btn:active {
    transform: translateY(1px);
}

.kaldia-btn-primary {
    background: var(--k-primary);
    color: #fff;
    border: none;
}

.kaldia-btn-primary:hover {
    background: var(--k-primary-h);
}

.kaldia-btn-success {
    background: var(--k-success);
    color: #fff;
    border: none;
}

.kaldia-btn-settings {
    padding: 10px 20px;
    height: auto;
    align-self: flex-start;
}

[data-save] {
    background: var(--k-success);
    color: white;
    border: none;
}

[data-close] {
    background: #FF9F43;
    color: white;
    border: none;
}

[data-delete] {
    background: #F04438;
    color: white;
    border: none;
}

.toast {
    border-radius: 8px;
    color: white;
    animation: toastIn 0.25s ease-out;
}

.toast.good {
    background: var(--k-success);
}

.toast.bad {
    background: #F04438;
}

.kaldia-status {
    display: inline-flex;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #fff;
}

.kaldia-status.ok {
    background: #4FD1C5;
}

.kaldia-status.missing {
    background: #FF9F43;
}

.kaldia-btn-primary.is-loading {
    position: relative;
    overflow: hidden;
}

.kaldia-btn-primary.is-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: currentColor;
    opacity: 0.25;
    animation: loadingBar 1s infinite;
}

@keyframes loadingBar {
    0% { width: 0%; }
    100% { width: 100%; }
}

.k-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s ease-out;
}

.k-modal.active {
    opacity: 1;
}

.k-box {
    background: var(--k-surface);
    border-radius: 14px;
    box-shadow: var(--k-shadow);
    padding: 24px;
    width: 90%;
    max-width: 740px;
}

.k-box textarea {
    width: 100%;
    min-height: 260px;
    font-family: monospace;
    padding: 10px;
    border: 1px solid var(--k-border);
    border-radius: 6px;
    background: var(--k-surface);
    color: var(--k-text);
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    z-index: 10000;
    font-family: "Inter", sans-serif;
}

.toast.good {
    background: #46b450;
}

.toast.bad {
    background: #d63638;
}

.k-disabled {
    opacity: .45;
    pointer-events: none;
    transition: opacity .25s ease;
}

.kaldia-actions {
    position: relative;
    display: inline-block;
    align-self: flex-start;
}

.kaldia-hint {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #ffeec0;
    color: #4b3a00;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
    pointer-events: none;
    z-index: 10;
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .kaldia-header {
        flex-direction: column;
        gap: 20px;
        padding: 20px;
    }
    
    .kaldia-header h1 {
        font-size: 24px;
    }
    
    .kaldia-table td {
        padding: 12px 16px;
    }
    
    .kaldia-table td:nth-child(3) {
        padding-left: 20px;
    }
    
    .k-box {
        width: 95%;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    #kaldia-root {
        padding: 16px;
    }
    
    .kaldia-table .kaldia-buttons {
        flex-direction: column;
        align-items: flex-end;
    }
    
    .k-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .toast {
        width: 90%;
        left: 5%;
        right: auto;
    }
}

@keyframes toastIn {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes modalFadeIn {
    0% { opacity: 0; transform: translateY(-8px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes modalFadeOut {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-8px); }
}
