:root {
    --server-bg: #0f1418;
    --shell-bg: #1b2328;
    --panel-bg: #273238;
    --panel-edge: #445158;
    --header-bg: #364248;
    --text-main: #d7e4de;
    --text-soft: #9db0a7;
    --signal-ok: #79d072;
    --badge-bg: #3d4f57;
    --accent-old: #92c27f;
    --warn-old: #cab06d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at 14% 20%, rgba(146, 194, 127, 0.08), transparent 35%),
        radial-gradient(circle at 84% 10%, rgba(202, 176, 109, 0.08), transparent 32%),
        var(--server-bg);
    color: var(--text-main);
    font-family: "Lucida Console", "Courier New", monospace;
}

.desktop-shell {
    width: min(1480px, 100%);
    min-height: min(920px, calc(100vh - 40px));
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 22%), var(--shell-bg);
    border: 2px solid #5f6a70;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(12, 17, 21, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.desktop-shell::after {
    content: "";
    pointer-events: none;
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.02),
        rgba(255, 255, 255, 0.02) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 0.35;
}

.server-header,
.workspace-grid,
.server-footer {
    position: relative;
    z-index: 1;
}

.server-header {
    background: linear-gradient(180deg, #46555c 0%, var(--header-bg) 100%);
    border-bottom: 2px solid #67757c;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.server-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.signal-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 35%, #d9ffe2, var(--signal-ok));
    box-shadow: 0 0 0 3px rgba(121, 208, 114, 0.16), 0 0 12px rgba(121, 208, 114, 0.55);
    flex-shrink: 0;
}

.server-brand h1 {
    margin: 0;
    font-size: clamp(20px, 2vw, 30px);
    letter-spacing: 0.08em;
    color: #ecf4ef;
}

.server-brand p {
    margin: 4px 0 0;
    color: #b9cbc2;
    font-size: 12px;
}

.server-status {
    min-width: 330px;
    display: grid;
    gap: 5px;
    border: 1px solid #6f7d84;
    background: rgba(18, 24, 28, 0.62);
    padding: 10px 12px;
}

.status-line {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: #b8cbc2;
    font-size: 12px;
}

.status-line strong {
    color: #e8f5ee;
    font-weight: 600;
}

.status-online {
    color: #b6ffae;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(260px, 0.85fr);
    grid-template-areas:
        "folders evidence"
        "folders calls";
    gap: 14px;
    padding: 14px;
    flex: 1;
    min-height: 0;
}

.card-panel {
    border: 2px solid var(--panel-edge);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 15%), var(--panel-bg);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid #516068;
    background: rgba(22, 30, 35, 0.4);
    padding: 12px 14px;
}

.panel-head h2 {
    margin: 0;
    font-size: clamp(15px, 1.45vw, 20px);
    letter-spacing: 0.04em;
    color: #ddebdf;
}

.badge {
    border: 1px solid #667980;
    background: var(--badge-bg);
    padding: 3px 10px;
    font-size: 11px;
    text-transform: uppercase;
    color: #d5e6dd;
    white-space: nowrap;
}

.badge.neutral {
    background: #525e64;
}

.folder-panel {
    grid-area: folders;
}

.folder-tree {
    list-style: none;
    margin: 0;
    padding: 10px;
}

.tree-node {
    list-style: none;
}

.tree-item {
    border: 1px solid #4b5960;
    padding: 10px;
    color: #b8cbc2;
    font-size: 13px;
    background: rgba(15, 21, 24, 0.25);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tree-item:focus-visible {
    outline: 2px solid #94ba84;
    outline-offset: 1px;
}

.tree-item:hover {
    background: rgba(146, 194, 127, 0.1);
    color: #e2f2e7;
}

.tree-parent {
    background: rgba(146, 194, 127, 0.09);
    border-color: #6f8660;
    font-weight: 600;
}

.tree-caret {
    color: #9fb3a9;
    font-size: 11px;
}

.tree-children {
    list-style: none;
    margin: 6px 0 0;
    padding: 0 0 0 22px;
    display: grid;
    gap: 6px;
    position: relative;
}

.tree-children::before {
    content: "";
    position: absolute;
    left: 9px;
    top: 2px;
    bottom: 10px;
    width: 1px;
    background: #5f6f76;
}

.tree-children li {
    position: relative;
    list-style: none;
}

.tree-children li::before {
    content: "";
    position: absolute;
    left: -13px;
    top: 50%;
    width: 11px;
    height: 1px;
    background: #5f6f76;
}

.tree-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-branch {
    color: #8fa29a;
    font-size: 10px;
}

.tree-item.active {
    color: #edfae9;
    border-color: #86b179;
    background: rgba(146, 194, 127, 0.15);
}

.tree-item.locked {
    color: #bdc6c2;
    border-color: #5a646a;
}

.tree-item.locked .bi-lock-fill {
    margin-left: auto;
    color: #d8b66f;
    font-size: 12px;
}

.folder-toast {
    min-height: 26px;
    margin: 8px 10px 10px;
    border: 1px solid transparent;
    background: transparent;
    color: transparent;
    font-size: 11px;
    padding: 6px 9px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.folder-toast.visible {
    border-color: #9a8352;
    background: rgba(202, 176, 109, 0.13);
    color: #e9d4a4;
}

.folder-toast.ok {
    border-color: #6e9a5f;
    background: rgba(121, 208, 114, 0.14);
    color: #cce9c4;
}

.evidence-panel {
    grid-area: evidence;
}

.audio-archive-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #4f5c63;
    color: #a6b8b0;
    font-size: 11px;
    background: rgba(14, 20, 23, 0.28);
}

.audio-list {
    padding: 12px;
    overflow: auto;
    display: grid;
    gap: 12px;
}

.audio-card {
    border: 1px solid #58656c;
    background: rgba(9, 13, 15, 0.28);
    padding: 12px;
    display: grid;
    gap: 10px;
}

.audio-meta h3 {
    margin: 0;
    font-size: 14px;
    color: #e7f4ec;
}

.audio-meta p {
    margin: 4px 0 0;
    font-size: 12px;
    color: #9eb2a9;
}

.evidence-player {
    width: 100%;
    filter: contrast(0.92) saturate(0.85);
}

.audio-foot {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: #96a89f;
    font-size: 11px;
}

.audio-backlog {
    margin-top: 2px;
    border: 1px dashed #5b696f;
    padding: 8px;
    display: grid;
    gap: 6px;
}

.audio-backlog-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid #4b585f;
    background: rgba(10, 15, 18, 0.22);
    padding: 6px 8px;
    font-size: 11px;
    color: #96a9a0;
}

.audio-backlog-row span:last-child {
    color: #d8b66f;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.03em;
}

.calls-panel {
    grid-area: calls;
}

.table-wrap {
    overflow: auto;
    min-height: 0;
    padding: 0 10px 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
    margin-top: 10px;
}

th,
td {
    border: 1px solid #4d5a61;
    text-align: left;
    padding: 8px 10px;
    font-size: 12px;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #405057;
    color: #e5f1ec;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tbody tr:nth-child(odd) {
    background: rgba(10, 14, 17, 0.26);
}

tbody tr:hover {
    background: rgba(146, 194, 127, 0.14);
}

.server-footer {
    border-top: 2px solid #5f6b72;
    background: #303c42;
    padding: 8px 12px;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    color: #c1d0ca;
    font-size: 11px;
}

@media (max-width: 1180px) {
    body {
        padding: 0;
    }

    .desktop-shell {
        width: 100%;
        min-height: 100vh;
        border-width: 0;
    }

    .workspace-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "folders"
            "evidence"
            "calls";
    }

    .server-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .server-status {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 760px) {
    .server-header,
    .panel-head,
    .server-footer {
        padding-left: 10px;
        padding-right: 10px;
    }

    .workspace-grid {
        gap: 10px;
        padding: 10px;
    }

    .audio-foot {
        flex-direction: column;
    }

    .audio-archive-meta {
        flex-direction: column;
    }

    .server-footer {
        flex-direction: column;
    }
}

#police-completion-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(8, 13, 17, 0.86);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#police-completion-modal[hidden] {
    display: none;
}

.police-completion-card {
    width: min(860px, 100%);
    background: linear-gradient(165deg, rgba(146, 194, 127, 0.14), rgba(202, 176, 109, 0.08) 52%, #162127);
    border: 1px solid rgba(146, 194, 127, 0.36);
    border-radius: 18px;
    box-shadow: 0 28px 78px rgba(0, 0, 0, 0.7);
    padding: 34px;
    position: relative;
    animation: policeModalIn 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 18px;
    align-items: end;
}

@keyframes policeModalIn {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.police-completion-close {
    position: absolute;
    top: 12px;
    right: 14px;
    border: none;
    background: transparent;
    color: #99ada4;
    font-size: 28px;
    line-height: 1;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    z-index: 2;
}

.police-completion-close:hover {
    color: #e5f3ec;
    background: rgba(255, 255, 255, 0.08);
}

.police-dialog-avatar-shell {
    width: 98px;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid rgba(162, 204, 144, 0.65);
    background: radial-gradient(circle at 30% 30%, rgba(220, 255, 213, 0.25), rgba(88, 127, 84, 0.3));
    padding: 4px;
    overflow: hidden;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
}

.police-dialog-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.police-dialog-bubble {
    background: linear-gradient(165deg, rgba(8, 13, 17, 0.82), rgba(15, 24, 28, 0.96));
    border: 1px solid rgba(146, 194, 127, 0.45);
    border-radius: 18px 18px 18px 8px;
    padding: 24px 24px 22px;
    display: grid;
    gap: 14px;
    position: relative;
}

.police-dialog-bubble::before {
    content: "";
    position: absolute;
    left: -10px;
    bottom: 18px;
    width: 18px;
    height: 18px;
    background: rgba(13, 21, 25, 0.95);
    border-left: 1px solid rgba(146, 194, 127, 0.45);
    border-bottom: 1px solid rgba(146, 194, 127, 0.45);
    transform: rotate(45deg);
}

.police-completion-eyebrow {
    margin: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #9dd18f;
}

.police-completion-card h2 {
    margin: 0;
    font-size: clamp(24px, 2.6vw, 33px);
    color: #ecf8f1;
    letter-spacing: 0.03em;
}

.police-dialog-message {
    margin: 0;
    min-height: 94px;
    font-size: clamp(16px, 1.6vw, 19px);
    line-height: 1.7;
    color: #d4e5dd;
}

.police-dialog-message.is-typing::after {
    content: "";
    display: inline-block;
    width: 0.56ch;
    height: 1.06em;
    margin-left: 4px;
    vertical-align: -2px;
    background: rgba(212, 229, 221, 0.95);
    animation: policeTypingCaret 0.9s steps(1, end) infinite;
}

@keyframes policeTypingCaret {
    0%,
    45% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

.police-next-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #d7f0dc;
    background: linear-gradient(135deg, #3f6c4a, #31573b);
    border: 1px solid #6f9a67;
    border-radius: 10px;
    padding: 14px 22px;
    font-size: 14px;
    letter-spacing: 0.03em;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.36);
    justify-self: start;
}

.police-next-link:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #4b7d58, #376344);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.46);
    color: #f0fff3;
}

#police-completion-reopen {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    display: flex;
    justify-content: center;
    padding: 14px 16px 24px;
    background: linear-gradient(to top, rgba(8, 13, 17, 0.95), transparent);
}

#police-completion-reopen[hidden] {
    display: none;
}

#police-reopen-btn {
    border: 1px solid #6f9a67;
    background: linear-gradient(135deg, #3f6c4a, #31573b);
    color: #d7f0dc;
    border-radius: 8px;
    padding: 10px 20px;
    font-family: "Lucida Console", "Courier New", monospace;
    font-size: 12px;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.33);
}

#police-reopen-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, #4b7d58, #376344);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
    color: #f0fff3;
}

@media (max-width: 760px) {
    .panel-head {
       display: block;
    }
    .panel-head h2 {
        margin-bottom: 8px;
    }
    .police-completion-card {
        padding: 40px 20px 24px;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .police-completion-close {
        top: 10px;
        right: 10px;
    }

    .police-dialog-avatar-shell {
        width: 72px;
    }

    .police-dialog-bubble {
        padding: 18px 16px 16px;
    }

    .police-dialog-bubble::before {
        display: none;
    }

    .police-dialog-message {
        min-height: 86px;
        font-size: 15px;
    }
}
