:root {
    --bg: #f3f5f7;
    --card: #fff;
    --text: #17202a;
    --muted: #6b7785;
    --line: #e4e8ec;
    --blue: #1769e0;
    --green: #15845b;
    --amber: #b26a00;
    --red: #c33b3b
}

* {
    box-sizing: border-box
}
.main_tag {
    scroll-behavior: smooth;
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif
}

header {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px max(20px, calc((100% - 1180px) / 2));
    background: #f3f5f7ee;
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line)
}

h1 {
    font-size: 24px;
    line-height: 1.1;
    margin: 3px 0
}

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

.icon, .close {
    border: 0;
    background: var(--card);
    border-radius: 12px;
    width: 42px;
    height: 42px;
    font-size: 24px;
    box-shadow: 0 2px 12px #17202a12;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .12s ease
}

main {
    max-width: 1180px;
    margin: auto;
    padding: 22px 20px 60px
}

.stats {
    display: grid;
    grid-template-columns:repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 18px
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px
}

.stat b {
    display: block;
    font-size: 28px
}

.stat span, .muted {
    color: var(--muted)
}

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

.tabs {
    display: flex;
    overflow: auto;
    gap: 6px
}

.tabs button, .action {
    white-space: nowrap;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 10px;
    padding: 9px 13px;
    font: inherit;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .12s ease
}

.tabs button.active, .action.primary {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff
}

.action:disabled {
    background: #eef1f4;
    border-color: var(--line);
    color: var(--muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none
}

.tabs button:hover, .action:hover, .icon:hover, .close:hover, .mainnav button:hover {
    background: #eef5ff;
    border-color: #b8c9df;
    color: var(--blue);
    box-shadow: 0 4px 14px #1769e01a
}

.action:disabled:hover {
    background: #eef1f4;
    border-color: var(--line);
    color: var(--muted);
    box-shadow: none
}

.tabs button:focus-visible, .action:focus-visible, .icon:focus-visible, .close:focus-visible, .mainnav button:focus-visible {
    outline: 3px solid #9dc3ff;
    outline-offset: 2px
}

.tabs button:active, .action:active, .icon:active, .close:active, .mainnav button:active {
    transform: translateY(1px);
    background: #dcecff;
    color: var(--blue)
}

.tabs button.active:hover, .tabs button.active:active, .action.primary:hover, .action.primary:active, .mainnav button.active:hover, .mainnav button.active:active {
    background: #0f58c2;
    border-color: #0f58c2;
    color: #fff
}

input, select, textarea {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 10px 12px;
    font: inherit;
    min-width: 0
}

input:disabled, select:disabled, textarea:disabled {
    background: #eef1f4;
    color: var(--muted);
    cursor: not-allowed;
    opacity: 1
}

#search {
    width: 280px
}

.tickets {
    display: grid;
    gap: 10px
}

.ticket {
    display: grid;
    grid-template-columns:90px 1fr 170px 150px 120px;
    gap: 14px;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    cursor: pointer
}

.ticket:hover {
    border-color: #b8c9df
}

.number {
    font-weight: 700
}

.ticket h3 {
    font-size: 15px;
    margin: 0 0 3px
}

.ticket p {
    color: var(--muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.badge {
    display: inline-block;
    width: max-content;
    border-radius: 99px;
    padding: 5px 9px;
    font-size: 12px;
    background: #edf2f7
}

.badge.new {
    color: var(--blue);
    background: #eaf2ff
}

.badge.in_progress {
    color: var(--amber);
    background: #fff4da
}

.badge.review {
    color: #7652aa;
    background: #f2eaff
}

.badge.completed {
    color: var(--green);
    background: #e5f7ef
}

.badge.rejected {
    color: var(--red);
    background: #fdeaea
}

.muted {
    font-size: 13px
}

.empty, .notice {
    text-align: center;
    padding: 30px;
    color: var(--muted)
}

.notice {
    background: #fff3cd;
    border-radius: 12px;
    margin-bottom: 15px
}

.accessFormCard {
    margin-bottom: 18px
}

.accessUserPanel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden
}

.accessUserHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line)
}

.accessUserHead h3, .accessUserHead p {
    margin: 0
}

.accessUserHead h3 {
    font-size: 16px
}

.accessFormGrid {
    display: grid;
    grid-template-columns:1.2fr 1fr 1fr;
    gap: 12px;
    padding: 16px
}

.accessFormGrid label {
    display: grid;
    gap: 5px
}

.accessFormActions {
    display: flex;
    justify-content: flex-end;
    padding: 0 16px 16px
}

.accessUserPanel input[readonly] {
    background: #f7f9fb;
    color: var(--text)
}

.accessAdminsPanel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 18px;
    overflow: hidden
}

.accessAdminsHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line)
}

.accessAdminsHead h3, .accessAdminsHead p {
    margin: 0
}

.accessAdminsHead h3 {
    font-size: 16px
}

.accessAdminsList {
    display: grid
}

.accessAdminRow {
    display: grid;
    grid-template-columns:1fr auto auto;
    gap: 12px;
    align-items: center;
    min-height: 58px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line)
}

.accessAdminRow:last-child {
    border-bottom: 0
}

.accessAdminName {
    min-width: 0
}

.accessAdminName b, .accessAdminName span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.accessAdminStatus {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 44px;
    height: 24px
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0
}

.switch span {
    position: absolute;
    inset: 0;
    cursor: pointer;
    border-radius: 999px;
    background: #cfd7df;
    transition: background-color .18s ease
}

.switch span::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px #17202a30;
    transition: transform .18s ease
}

.switch input:checked + span {
    background: var(--green)
}

.switch input:checked + span::before {
    transform: translateX(20px)
}

.switch input:disabled + span {
    cursor: not-allowed;
    opacity: .65
}

.hidden {
    display: none
}

dialog {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    padding: 0;
    background: #0005
}

dialog::backdrop {
    background: transparent
}

.sheet {
    position: absolute;
    right: 0;
    top: 0;
    width: min(600px, 100%);
    height: 100%;
    overflow: auto;
    background: var(--card);
    padding: 28px
}

.close {
    float: right
}

.detailTitle {
    margin: 8px 50px 4px 0
}

.meta {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 10px;
    margin: 22px 0
}

.meta div, .historyItem {
    padding: 12px;
    background: var(--bg);
    border-radius: 10px
}

.meta small {
    display: block;
    color: var(--muted)
}

.controls {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 10px;
    padding: 18px 0;
    border-block: 1px solid var(--line)
}

.controls label {
    display: grid;
    gap: 5px
}

.comments {
    margin-top: 22px
}

.historyItem {
    margin: 8px 0
}

.serviceCard {
    display: grid;
    gap: 10px
}

.serviceHeader {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start
}

.assigneeSummary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px
}

.assigneeSummary span {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    padding: 5px 8px;
    font-size: 13px
}

.serviceHint {
    margin: 0
}

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

.serviceChoice {
    display: grid;
    grid-template-columns:auto 1fr auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    padding: 9px 10px
}

.serviceChoice.selected {
    border-color: #9dc3ff;
    background: #eef5ff
}

.serviceChoice small {
    color: var(--muted)
}

.commentForm {
    display: grid;
    gap: 8px;
    margin-top: 16px
}

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

@media (max-width: 760px) {
    header {
        padding: 15px 16px
    }

    main {
        padding: 16px
    }

    .stats {
        grid-template-columns:1fr 1fr
    }

    .toolbar {
        display: block
    }

    .tabs {
        margin-bottom: 10px
    }

    #search {
        width: 100%
    }

    .ticket {
        grid-template-columns:64px 1fr auto
    }

    .ticket .contractor, .ticket .date {
        display: none
    }

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

    .accessAdminRow {
        grid-template-columns:1fr auto
    }

    .accessAdminStatus {
        grid-column: 1 / -1
    }

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

    .accessFormGrid {
        grid-template-columns:1fr
    }

    .accessFormActions {
        display: grid
    }

    .sheet {
        padding: 20px
    }

    .controls, .meta {
        grid-template-columns:1fr
    }
}
