:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafb;
    --line: #d7dee5;
    --line-strong: #c5d0da;
    --text: #1f2933;
    --muted: #65758b;
    --sidebar: #202832;
    --sidebar-soft: #2b3541;
    --accent: #0f766e;
    --accent-dark: #0b5f59;
    --accent-soft: #e4f3f1;
    --ok: #1f7a4d;
    --warn: #a15c10;
    --danger: #b42318;
    --shadow: 0 12px 28px rgba(31, 41, 51, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #edf4f2 0%, #f6f8fa 48%, #eef2f6 100%);
}

.login-screen {
    width: min(1040px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 420px;
    align-items: center;
    gap: 54px;
}

.login-copy h1,
.login-box h2,
.pagebar h1,
.panel h2 {
    margin: 0;
    letter-spacing: 0;
}

.login-copy h1 {
    margin-top: 20px;
    font-size: 42px;
    line-height: 1.1;
}

.login-copy p,
.login-box p,
.pagebar p,
.panel p {
    margin: 8px 0 0;
    color: var(--muted);
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.login-box {
    display: grid;
    gap: 18px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.captcha-block {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 128px;
    align-items: end;
    gap: 10px;
}

.captcha-block[hidden] {
    display: none;
}

.captcha-image-button {
    height: 44px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.captcha-image-button img {
    width: 128px;
    height: 44px;
    display: block;
}

.workspace {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
    background: var(--sidebar);
    color: #fff;
    padding: 22px 16px;
}

.side-brand {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.side-brand strong,
.side-brand span {
    display: block;
}

.side-brand strong {
    font-size: 16px;
}

.side-brand span {
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.64);
    font-size: 12px;
}

.side-nav {
    display: grid;
    gap: 6px;
}

.nav-group {
    display: grid;
    gap: 4px;
    padding: 8px 0;
}

.nav-group-title {
    padding: 0 12px 4px;
    color: rgba(255, 255, 255, 0.46);
    font-size: 12px;
}

.side-nav .nav-child {
    min-height: 34px;
    padding-left: 24px;
    font-size: 13px;
}

.side-nav a {
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.76);
}

.side-nav a:hover,
.side-nav a.active {
    background: var(--sidebar-soft);
    color: #fff;
}

.main-area {
    min-width: 0;
    overflow-x: hidden;
    padding: 22px 24px 34px;
    display: grid;
    align-content: start;
    gap: 16px;
}

.pagebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 60px;
}

.pagebar h1 {
    font-size: 24px;
}

.session {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    white-space: nowrap;
}

.panel {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
}

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

.panel h2 {
    font-size: 17px;
}

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

.toolbar-actions,
.toolbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-select {
    width: min(240px, 100vw - 48px);
}

.toolbar-search input {
    width: min(280px, 100vw - 48px);
}

.report-blank {
    min-height: calc(100vh - 142px);
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
}

.config-line,
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 14px;
    align-items: end;
}

.config-line {
    grid-template-columns: minmax(260px, 1fr) 220px 160px;
}

.form-page {
    display: none;
}

.form-page.active {
    display: grid;
}

.form-page-title {
    grid-column: 1 / -1;
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13px;
}

.page-dots {
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-dot {
    width: 28px;
    height: 4px;
    border: 0;
    border-radius: 999px;
    background: var(--line-strong);
    cursor: pointer;
}

.page-dot.active {
    background: var(--accent);
}

label {
    display: grid;
    gap: 7px;
    min-width: 0;
}

label span,
.protocol-box span {
    color: var(--muted);
    font-size: 12px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 7px 10px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

textarea {
    min-height: 118px;
    resize: vertical;
    line-height: 1.5;
}

.textarea-wide {
    grid-column: 1 / -1;
}

input:disabled,
button:disabled {
    background: var(--surface-soft);
    color: var(--muted);
    cursor: not-allowed;
}

.switch-line {
    min-height: 36px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.switch-line input {
    width: 18px;
    min-height: 18px;
}

.switch-line span {
    color: var(--text);
    font-size: 14px;
}

.compact-switch {
    min-width: 82px;
}

.protocol-box {
    min-height: 36px;
    display: grid;
    gap: 6px;
}

.protocol-box strong {
    color: var(--accent-dark);
}

.input-action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 6px;
}

.button,
.mini-button {
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0 14px;
    cursor: pointer;
    white-space: nowrap;
}

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

.button-primary:hover {
    background: var(--accent-dark);
}

.button-light,
.mini-button {
    background: #fff;
    border-color: var(--line-strong);
    color: var(--accent-dark);
}

.button-light:hover,
.mini-button:hover {
    border-color: var(--accent);
}

.icon-button {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.icon-button:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.form-actions {
    display: flex;
    align-items: end;
}

.message {
    min-height: 0;
    color: var(--muted);
}

.message.ok {
    color: var(--ok);
}

.message.error {
    color: var(--danger);
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.table-wrap table th:last-child,
.table-wrap table td:last-child,
.sticky-actions {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
    box-shadow: -8px 0 12px rgba(31, 41, 51, 0.06);
}

.table-wrap table th:last-child,
th.sticky-actions {
    background: var(--surface-soft);
    z-index: 3;
}

table {
    width: max-content;
    min-width: 1180px;
    border-collapse: collapse;
    background: #fff;
}

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

tr:last-child td {
    border-bottom: 0;
}

th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

td input,
td select {
    min-width: 150px;
}

.wide-input {
    min-width: 260px;
}

.short-input {
    min-width: 88px;
}

.link-text {
    display: block;
    margin-top: 6px;
    color: var(--accent-dark);
    word-break: break-all;
}

.binding-key,
.binding-url {
    word-break: break-all;
}

.binding-url {
    display: block;
    color: var(--accent-dark);
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 12px;
}

.status-on {
    background: #e8f5ee;
    color: var(--ok);
}

.status-off {
    background: #fff2df;
    color: var(--warn);
}

.subtle {
    color: var(--muted);
    font-size: 12px;
}

.cell-main {
    display: grid;
    gap: 4px;
}

.cell-title {
    font-weight: 700;
}

.cell-meta {
    color: var(--muted);
    font-size: 12px;
    word-break: break-all;
}

.user-identity {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
}

.user-identity-name {
    display: block;
    min-width: 0;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.user-avatar {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    display: block;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    object-fit: cover;
}

.user-avatar-placeholder {
    background: var(--surface-soft);
}

.actions-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-control {
    position: relative;
}

.column-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    display: none;
    min-width: 180px;
    max-height: min(420px, calc(100vh - 140px));
    overflow: auto;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.column-menu.open {
    display: grid;
    gap: 8px;
}

.check-line {
    min-height: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-line input {
    width: 16px;
    min-height: 16px;
}

.check-line span {
    color: var(--text);
    font-size: 13px;
}

.toast-host {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1000;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
}

.toast {
    transform: translateY(-8px);
    opacity: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.ok {
    border-left-color: var(--ok);
}

.toast.error {
    border-left-color: var(--danger);
}

.modal-layer {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(31, 41, 51, 0.36);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(760px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(31, 41, 51, 0.22);
}

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

.modal-foot {
    border-top: 1px solid var(--line);
    border-bottom: 0;
}

.modal-head h2 {
    margin: 0;
    font-size: 18px;
}

.modal-body {
    min-height: 0;
    overflow: auto;
    padding: 16px;
}

.modal-body .form-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.empty-row {
    color: var(--muted);
    text-align: center;
}

.table-pagination {
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
}

.pager-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 960px) {
    .login-screen,
    .workspace {
        grid-template-columns: 1fr;
    }

    .login-screen {
        align-content: center;
        gap: 24px;
        padding: 32px 0;
    }

    .sidebar {
        min-height: auto;
    }

    .side-brand {
        margin-bottom: 16px;
    }

    .side-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .nav-group {
        display: contents;
    }

    .nav-group-title {
        display: none;
    }

    .side-nav .nav-child {
        padding-left: 12px;
    }

    .main-area {
        padding: 18px 12px 28px;
    }

    .pagebar,
    .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .config-line,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .modal-body .form-grid {
        grid-template-columns: 1fr;
    }

    .session {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 720px) {
    body {
        font-size: 15px;
    }

    .login-screen {
        width: min(100% - 24px, 440px);
    }

    .login-copy {
        display: none;
    }

    .login-box {
        padding: 22px;
    }

    .workspace {
        display: block;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 80;
        padding: 12px;
        box-shadow: 0 8px 22px rgba(31, 41, 51, 0.16);
    }

    .side-brand {
        grid-template-columns: 38px minmax(0, 1fr);
        gap: 10px;
        margin-bottom: 10px;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
    }

    .side-brand strong {
        font-size: 14px;
    }

    .side-brand span {
        display: none;
    }

    .side-nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: thin;
    }

    .side-nav a,
    .side-nav .nav-child {
        min-height: 34px;
        flex: 0 0 auto;
        padding: 0 12px;
        border-radius: 6px;
        font-size: 13px;
    }

    .main-area {
        padding: 14px 10px 24px;
        gap: 12px;
    }

    .pagebar {
        min-height: auto;
        gap: 10px;
    }

    .pagebar h1 {
        font-size: 21px;
    }

    .pagebar p {
        display: none;
    }

    .session {
        align-items: stretch;
        gap: 8px;
        white-space: normal;
    }

    .session .button {
        min-width: 88px;
    }

    .panel {
        padding: 12px;
        border-radius: 8px;
        box-shadow: none;
    }

    .panel-head {
        gap: 10px;
        margin-bottom: 12px;
    }

    .toolbar {
        align-items: stretch;
        gap: 10px;
    }

    .toolbar-actions,
    .toolbar-search {
        width: 100%;
        align-items: stretch;
    }

    .toolbar-actions > *,
    .toolbar-search > *,
    .toolbar-search input,
    .toolbar-select,
    .wide-input {
        width: 100%;
        min-width: 0;
    }

    .button,
    .mini-button,
    input,
    select,
    textarea {
        min-height: 42px;
    }

    .column-control {
        width: 100%;
    }

    .column-control > .button {
        width: 100%;
    }

    .column-menu {
        left: 0;
        right: 0;
        width: 100%;
        min-width: 0;
        max-height: 50vh;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        border-radius: 0;
    }

    table {
        width: 100%;
        min-width: 0;
        display: block;
        background: transparent;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 10px;
    }

    tr {
        display: block;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }

    td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 10px;
        min-height: 42px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--line);
        word-break: break-word;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        line-height: 1.6;
    }

    tr:last-child td,
    td:last-child {
        border-bottom: 0;
    }

    .table-wrap table th:last-child,
    .table-wrap table td:last-child,
    .sticky-actions {
        position: static;
        right: auto;
        z-index: auto;
        background: transparent;
        box-shadow: none;
    }

    td.sticky-actions {
        display: block;
        padding: 10px 12px;
        background: var(--surface-soft);
    }

    td.sticky-actions::before {
        display: none;
    }

    .actions-inline,
    .pager-actions,
    .modal-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .actions-inline .button,
    .pager-actions .button,
    .modal-actions .button {
        width: 100%;
    }

    .table-pagination {
        align-items: stretch;
        margin-top: 10px;
    }

    .table-pagination > span {
        width: 100%;
    }

    .user-identity {
        min-width: 0;
    }

    .user-identity-name {
        max-width: none;
        white-space: normal;
    }

    .modal-layer {
        align-items: stretch;
        padding: 0;
    }

    .modal-card {
        width: 100%;
        max-height: 100vh;
        min-height: 100vh;
        border-radius: 0;
    }

    .modal-head,
    .modal-foot,
    .modal-body {
        padding-left: 12px;
        padding-right: 12px;
    }

    .modal-foot {
        align-items: stretch;
        flex-direction: column;
    }

    .page-dots {
        justify-content: center;
    }

    .toast-host {
        top: 10px;
        right: 10px;
        width: calc(100vw - 20px);
    }

    .empty-row {
        display: block;
        text-align: center;
    }

    .empty-row::before {
        display: none;
    }
}
