:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #f9fafb;
    --text: #182230;
    --muted: #667085;
    --line: #e4e7ec;
    --line-strong: #cfd4dc;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-soft: #e6f4f1;
    --accent: #c2410c;
    --input-bg: #ffffff;
    --topbar-bg: rgba(255, 255, 255, 0.92);
    --topbar-link: #344054;
    --topbar-muted: #667085;
    --danger: #b42318;
    --danger-soft: #fee4e2;
    --badge-bg: #fff1eb;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-hover: 0 8px 24px rgba(16, 24, 40, 0.08);
    --focus: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

body.theme-dark {
    --bg: #0f172a;
    --panel: #182235;
    --panel-soft: #111827;
    --text: #e5e7eb;
    --muted: #a8b3c5;
    --line: #2f3b4f;
    --line-strong: #45556d;
    --primary: #0f766e;
    --primary-dark: #0d9488;
    --primary-soft: #123834;
    --accent: #fb923c;
    --input-bg: #101827;
    --topbar-bg: rgba(15, 23, 42, 0.92);
    --topbar-link: #dbe4f0;
    --topbar-muted: #9ca9bb;
    --danger: #fb7185;
    --danger-soft: #4a1f2a;
    --badge-bg: #3d2618;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-hover: 0 12px 28px rgba(0, 0, 0, 0.28);
    --focus: 0 0 0 3px rgba(45, 212, 191, 0.2);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 64px;
    padding: 0 28px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--line);
    color: var(--text);
    backdrop-filter: blur(14px);
}

.topbar:has(> .topbar-actions:first-child) {
    justify-content: flex-end;
}

.topbar-public {
    justify-content: flex-end;
}

.topbar-main,
.topbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 800;
    letter-spacing: 0;
}

.brand-logo {
    display: block;
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.brand:hover,
.topbar nav a:hover,
.theme-toggle:hover {
    text-decoration: none;
}

.topbar-time {
    color: var(--topbar-muted);
    font-size: 13px;
}

.topbar-weather {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--topbar-muted);
    font-size: 13px;
    font-weight: 700;
}

.topbar-weather[hidden] {
    display: none;
}

.weather-svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.topbar nav a {
    color: var(--topbar-link);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 14px;
    font-weight: 700;
}

.topbar nav a:hover {
    background: var(--panel);
    color: var(--primary);
}

.language-form {
    display: block;
}

.language-form label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--topbar-muted);
    font-size: 13px;
}

.language-form select {
    width: auto;
    min-width: 128px;
    padding: 7px 28px 7px 10px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--topbar-link);
}

.theme-toggle:hover {
    background: var(--panel);
}

.menu-toggle {
    display: none !important;
}

.menu-toggle-lines,
.menu-toggle-lines::before,
.menu-toggle-lines::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 160ms ease, opacity 160ms ease;
}

.menu-toggle-lines {
    position: relative;
}

.menu-toggle-lines::before,
.menu-toggle-lines::after {
    content: "";
    position: absolute;
    left: 0;
}

.menu-toggle-lines::before {
    top: -6px;
}

.menu-toggle-lines::after {
    top: 6px;
}

body.menu-open .menu-toggle-lines {
    transform: rotate(45deg);
}

body.menu-open .menu-toggle-lines::before {
    opacity: 0;
}

body.menu-open .menu-toggle-lines::after {
    transform: translateY(-6px) rotate(-90deg);
}

.theme-symbol {
    position: relative;
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--topbar-link);
}

.theme-symbol.is-dark::after {
    content: "";
    position: absolute;
    right: -1px;
    top: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--panel-soft);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 28px auto;
}

.panel,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.login-panel {
    width: min(420px, 100%);
    margin: 56px auto;
}

.login-logo {
    display: block;
    width: min(180px, 70%);
    max-height: 92px;
    object-fit: contain;
    margin: 0 auto 22px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.search-panel {
    margin-bottom: 18px;
    padding: 16px;
}

.search-form {
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 240px) auto;
    align-items: end;
}

h1,
h2,
h3 {
    margin: 0 0 10px;
    line-height: 1.2;
}

h1 {
    font-size: 32px;
}

h2 {
    font-size: 20px;
}

.muted {
    color: var(--muted);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.card.unread {
    border-left: 4px solid var(--accent);
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--badge-bg);
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-top: 6px;
    padding: 2px 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.4;
}

body.theme-dark .tag-pill {
    color: #5eead4;
}

form {
    display: grid;
    gap: 14px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.checkbox {
    display: flex;
    align-items: center;
}

.checkbox input {
    width: auto;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 13px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    line-height: 1.2;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.button:hover,
button:hover {
    background: var(--primary-dark);
    text-decoration: none;
    transform: translateY(-1px);
}

.button.secondary {
    background: var(--panel-soft);
    border-color: var(--line);
    color: var(--text);
}

.button.secondary:hover {
    background: var(--panel);
    border-color: var(--line-strong);
}

.button.ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--muted);
}

.button.ghost:hover {
    background: var(--panel-soft);
    color: var(--text);
}

.button.subtle {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.button.subtle:hover {
    background: var(--primary);
    color: #fff;
}

.button.danger,
button.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.button.danger:hover,
button.danger:hover {
    background: var(--danger);
    color: #fff;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0;
    background: var(--panel-soft);
    color: var(--text);
    text-decoration: none;
    flex: 0 0 auto;
}

.icon-button:hover {
    background: var(--primary-soft);
    border-color: var(--line-strong);
    color: var(--primary-dark);
}

.icon-button.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.icon-button.danger-icon {
    background: var(--panel-soft);
    border-color: var(--line);
    color: var(--danger);
}

.icon-button.danger-icon:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}

.icon-button.status-icon.is-active {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.icon-button.status-icon.is-active:hover {
    background: #bbf7d0;
    border-color: #22c55e;
}

.icon-button.status-icon.is-inactive {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: var(--danger);
}

.icon-button.status-icon.is-inactive:hover {
    background: #fecaca;
    border-color: var(--danger);
}

body.theme-dark .icon-button.status-icon.is-active {
    background: #123824;
    border-color: #166534;
    color: #86efac;
}

body.theme-dark .icon-button.status-icon.is-active:hover {
    background: #14532d;
    border-color: #22c55e;
}

body.theme-dark .icon-button.status-icon.is-inactive {
    background: #4a1f2a;
    border-color: #7f1d1d;
    color: #fb7185;
}

body.theme-dark .icon-button.status-icon.is-inactive:hover {
    background: #5f1f2d;
    border-color: #fb7185;
}

.action-svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.view-toggle-button {
    width: 28px;
    height: 28px;
    border-color: transparent;
    background: transparent;
}

.mail-svg,
.view-svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.view-svg {
    width: 28px;
    height: 28px;
}

.info-svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.history-popover {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 38px;
}

.history-popover > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    cursor: pointer;
    list-style: none;
}

.history-popover > summary:hover {
    background: var(--primary-soft);
    border-color: var(--line-strong);
    color: var(--primary-dark);
}

.history-popover > summary::-webkit-details-marker {
    display: none;
}

.history-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 30;
    width: min(340px, calc(100vw - 32px));
    max-height: 300px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
}

.history-panel-wide {
    width: min(460px, calc(100vw - 32px));
}

.history-panel h3 {
    font-size: 15px;
    margin-bottom: 10px;
}

.history-list {
    display: grid;
    gap: 10px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.history-list li {
    display: grid;
    gap: 2px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.history-list li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.history-list time {
    color: var(--muted);
    font-size: 13px;
}

.change-history-list li {
    gap: 4px;
}

.change-details ul {
    display: grid;
    gap: 6px;
    padding: 8px 0 0;
    margin: 0;
    list-style: none;
}

.change-details li {
    display: grid;
    grid-template-columns: minmax(92px, auto) 1fr;
    gap: 4px 8px;
    padding: 0;
    border: 0;
}

.change-details span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.change-details del,
.change-details ins {
    display: block;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.change-details del {
    color: var(--danger);
}

.change-details ins {
    color: var(--primary-dark);
}

body.theme-dark .change-details ins {
    color: #5eead4;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.actions form {
    display: inline-flex;
}

td.actions {
    display: table-cell;
}

td.actions > form,
td.actions > .button {
    margin-right: 10px;
    margin-bottom: 8px;
    vertical-align: middle;
}

.actions-column {
    width: 190px;
    text-align: right;
}

.compact-actions-column {
    width: 132px;
    text-align: right;
    white-space: nowrap;
}

td.compact-actions-column {
    justify-content: flex-end;
    gap: 4px;
}

td.compact-actions-column > .icon-button,
td.compact-actions-column > form > .icon-button {
    display: inline-flex;
    margin: 0;
    vertical-align: middle;
}

td.actions-column {
    white-space: nowrap;
}

td.actions-column > form,
td.actions-column > .button {
    margin-right: 0;
    margin-left: 10px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
}

.pagination-status {
    color: var(--muted);
    font-weight: 700;
}

.pagination .disabled {
    opacity: 0.45;
    pointer-events: none;
}

.scroll-top-button {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;
    width: 42px;
    height: 42px;
    padding: 0;
    border-color: var(--line);
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-hover);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
}

.scroll-top-button.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.scroll-top-button svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert.success {
    background: #e8f5ef;
    border-color: #bbebd0;
    color: #14532d;
}

.alert.error {
    background: #fee4e2;
    border-color: #fecaca;
    color: #7a271a;
}

body.theme-dark .alert.success {
    background: #143623;
    border-color: #245d3c;
    color: #bbf7d0;
}

body.theme-dark .alert.error {
    background: #3f1d20;
    border-color: #733236;
    color: #fecaca;
}

.file-list {
    display: grid;
    gap: 10px;
    padding: 0;
    margin: 12px 0 0;
    list-style: none;
}

.file-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.comments-panel {
    margin-top: 18px;
}

.comment-list {
    display: grid;
    gap: 10px;
    padding: 0;
    margin: 12px 0 18px;
    list-style: none;
}

.comment-item {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.comment-item.own-comment {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.comment-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

.comment-meta strong {
    color: var(--text);
}

.comment-item p {
    margin: 8px 0 0;
}

.comment-form {
    margin-top: 14px;
}

.comments-disabled {
    margin-top: 14px;
}

.file-icon {
    position: relative;
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 46px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--panel);
    color: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.file-icon::before {
    content: "";
    position: absolute;
    top: -1px;
    right: -1px;
    width: 15px;
    height: 15px;
    border-left: 1px solid rgba(255, 255, 255, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.28);
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.file-icon span {
    display: block;
    width: 100%;
    padding: 3px 2px;
    background: rgba(0, 0, 0, 0.22);
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    text-align: center;
}

.file-icon-pdf {
    background: #c2410c;
}

.file-icon-word {
    background: #2563eb;
}

.file-icon-sheet {
    background: #15803d;
}

.file-icon-slides {
    background: #b45309;
}

.file-icon-text {
    background: #64748b;
}

.file-icon-image {
    background: #7c3aed;
}

.file-icon-archive {
    background: #52525b;
}

.project-file-icons {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
    vertical-align: middle;
}

.mini-file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    line-height: 1;
    box-shadow: var(--shadow);
}

@media (max-width: 700px) {
    .page-header,
    .file-row,
    .search-form {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        position: sticky;
        align-items: center;
        flex-direction: row;
        flex-wrap: nowrap;
        min-height: 54px;
        padding: 8px 12px;
        gap: 8px;
    }

    .topbar-main {
        flex: 1 1 0;
        min-width: 0;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .brand {
        flex: 0 1 auto;
        max-width: 100%;
        min-width: 0;
    }

    .brand span {
        max-width: 32vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .brand-logo {
        width: 28px;
        height: 28px;
    }

    .topbar-time,
    .topbar-weather {
        flex: 0 0 auto;
        font-size: 12px;
        white-space: nowrap;
    }

    .topbar-weather {
        gap: 3px;
    }

    .weather-svg {
        width: 16px;
        height: 16px;
    }

    .menu-toggle {
        display: inline-flex !important;
        flex: 0 0 auto;
        margin-left: auto;
    }

    .topbar-actions {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        left: 16px;
        right: 16px;
        z-index: 50;
        width: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
        box-shadow: var(--shadow-hover);
    }

    body.menu-open .topbar-actions {
        display: flex;
    }

    .topbar nav {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .topbar nav a {
        padding: 10px 12px;
    }

    .language-form label {
        align-items: stretch;
        flex-direction: column;
        gap: 6px;
    }

    .language-form select,
    .theme-toggle {
        width: 100%;
    }

    .theme-toggle {
        height: 40px;
        gap: 8px;
    }

    .theme-toggle .visually-hidden {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip: auto;
        white-space: normal;
    }

    .mobile-hidden {
        display: none;
    }

    h1 {
        font-size: 26px;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    thead {
        display: none;
    }

    tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 12px;
        background: var(--panel);
    }

    td {
        border-bottom: 0;
    }

    td.actions {
        display: block;
    }

    td.actions.compact-actions-column {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        width: auto;
        gap: 4px;
    }

    td.mobile-empty {
        display: none;
    }

    .history-panel {
        left: 0;
        right: auto;
    }
}
