:root { color-scheme: light; }
* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #f4f6f9;
    color: #1f2937;
}

.page {
    max-width: 1160px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

/* The task table uses the whole screen width with small side margins. */
.page-wide {
    max-width: none;
    margin: 0;
    padding: 16px 20px 48px;
}

#tasks-table { overflow-x: auto; }

/* Task table: columns are as wide as their content; the screen is only the upper bound. */
.tasks-table {
    width: auto;
    max-width: 100%;
}
.tasks-table th,
.tasks-table td { white-space: nowrap; }
.tasks-table td { vertical-align: middle; }
.task-type-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-weight: 500;
    color: #0d6efd;
    text-decoration: underline;
    cursor: pointer;
}
.task-type-text { color: #4b5563; }
.sort-icons {
    font-size: 11px;
    letter-spacing: 1px;
    margin-left: 2px;
}

/* Checkbox is a real input; the flag is its visible label */
.task-check {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}
.task-check input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}
.task-flag {
    font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif;
    font-size: 22px;
    line-height: 1;
    color: #9ca3af;
}
.task-check input:checked + .task-flag { color: #2563eb; }
.task-check input:focus-visible + .task-flag {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Loading skeletons.
   The task list placeholder has no header and no cell borders: each row is one
   long bar. Its width matches the loaded table on a typical screen so the list
   does not change width when the data arrives; narrow screens keep 100%. */
.tasks-skeleton {
    width: 100%;
    /* Approximate width of the loaded table; the script refines it after the first swap. */
    max-width: var(--tasks-table-width, 780px);
    padding: 4px 8px;
    background: #fff;
}
.tasks-skeleton .skeleton-row {
    /* Same height as a Bootstrap table row: 14px bar + two 13px paddings. */
    padding: 13px 0;
}
.skeleton-row span {
    display: block;
    width: 100%;
    min-width: 56px; /* visible bar in a narrow panel block */
    height: 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, #e5e7eb, #f3f4f6, #e5e7eb);
    animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
    0% { opacity: .55; }
    50% { opacity: 1; }
    100% { opacity: .55; }
}

/* Right-side panel: half of the screen, full width on narrow displays */
dialog.task-panel {
    margin: 0 0 0 auto;
    height: 100vh;
    max-height: 100vh;
    width: 50vw;
    max-width: 100vw;
    border: 0;
    padding: 0;
    background: #fff;
    overflow-y: auto;
}
@media (max-width: 900px) {
    dialog.task-panel {
        width: 100vw;
        min-width: 0;
    }
}
dialog.task-panel::backdrop { background: rgba(15, 23, 42, .35); }
.task-panel-head {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}
.task-panel-close {
    border: 0;
    background: transparent;
    color: #374151;
    font-size: 28px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}
.task-panel-close:hover { color: #111827; }

/* Panel content: the recording/transcript or the letter takes two thirds,
   the archive and Bitrix24 results take one third. On narrow displays the
   columns stack in reading order. */
.task-panel-columns {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
    align-items: start;
}
.task-panel-column { min-width: 0; }
@media (max-width: 900px) {
    .task-panel-columns { grid-template-columns: 1fr; }
}

/* Panel blocks: the recording/letter and the two search results are visually
   separate. The link body is replaced by the block endpoint after it loads. */
.panel-block {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fff;
}
.panel-block:last-child { margin-bottom: 0; }
.panel-block-title { margin: 0 0 8px; }
.panel-block-body { min-height: 20px; }
.panel-links {
    list-style: none;
    margin: 0;
    padding: 0;
}
.panel-links li {
    padding: 6px 0;
    border-top: 1px solid #f1f5f9;
    overflow-wrap: anywhere;
}
.panel-links li:first-child { border-top: 0; padding-top: 0; }
.panel-links li:last-child { padding-bottom: 0; }
.panel-links-type {
    color: #6b7280;
    font-size: 12px;
    margin-right: 6px;
}
.panel-links-count { color: #6b7280; font-size: 12px; margin: 8px 0 0; }
.panel-links-warning { color: #92400e; font-size: 12px; margin: 8px 0 0; }
.panel-links-empty { color: #6b7280; margin: 0; }
.panel-links-error { color: #b91c1c; margin: 0; }
.panel-links-retry { color: inherit; }

/* Website request text: raw line breaks are rendered by pre-line, so the PHP side
   must not turn them into <br> as well. */
.letter-body {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Recording playback speed. The native control bar is drawn by the browser and
   cannot host a custom button, so the stepper sits under the player, right-aligned
   and compact. It drives the sibling audio element's playbackRate. */
.recording-speed {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}
.recording-speed-step {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #1f2937;
    font: inherit;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.recording-speed-step:hover:not(:disabled) { background: #f3f4f6; }
.recording-speed-step:disabled { opacity: .4; cursor: default; }
.recording-speed-step:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
.recording-speed-value {
    min-width: 52px;
    text-align: center;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    color: #374151;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    padding: 32px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 30px rgba(15, 23, 42, .08);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .hint { margin: 0 0 24px; color: #6b7280; font-size: 14px; }
