:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #647086;
    --line: #dce2ec;
    --brand: #176f6b;
    --brand-dark: #115855;
    --danger: #bd2f2f;
    --danger-dark: #9f2424;
    --soft: #edf4f3;
    --shadow: 0 14px 40px rgba(28, 39, 59, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 32px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.topbar.actions-only {
    justify-content: flex-end;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 700;
}

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

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
}

.top-actions,
.form-actions,
.bulk-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 20px;
    padding: 22px 32px 32px;
}

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

.form-panel {
    padding: 20px;
    align-self: start;
}

.list-panel {
    min-width: 0;
    padding: 20px;
    scroll-margin-top: 12px;
}

form {
    margin: 0;
}

.contact-form,
.import-form,
.login-form {
    display: grid;
    gap: 14px;
}

.contact-form {
    margin-top: 18px;
}

.import-form {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    outline: 0;
    padding: 10px 11px;
    scroll-margin: 96px 0 45vh;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(23, 111, 107, .14);
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid var(--brand);
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 8px 14px;
    white-space: nowrap;
}

button:hover,
.button:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.ghost {
    background: #fff;
    color: var(--brand);
}

.ghost:hover {
    color: #fff;
}

.secondary {
    border-color: #51627a;
    background: #51627a;
}

.secondary:hover {
    border-color: #3f4d61;
    background: #3f4d61;
}

.danger {
    border-color: var(--danger);
    background: var(--danger);
}

.danger:hover {
    border-color: var(--danger-dark);
    background: var(--danger-dark);
}

.small {
    min-height: 30px;
    padding: 4px 9px;
    font-size: 12px;
}

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

.list-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.search-form {
    display: flex;
    gap: 8px;
    width: min(100%, 540px);
}

.bulk-actions {
    justify-content: flex-start;
    padding: 12px 0;
}

.check-all {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.check-all input,
.col-check input {
    width: 16px;
    height: 16px;
}

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

table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    background: #fff;
}

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

th {
    position: sticky;
    top: 0;
    background: var(--soft);
    color: #3a485d;
    font-size: 12px;
    font-weight: 800;
}

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

tbody tr {
    cursor: pointer;
}

tbody tr.is-active td {
    background: #9fcaff;
}

td {
    color: #2e3a4d;
    word-break: break-word;
}

.strong {
    color: var(--text);
    font-weight: 800;
}

.col-check {
    width: 42px;
    text-align: center;
}

.col-name {
    width: calc(6em + 22px);
    min-width: calc(6em + 22px);
    max-width: calc(6em + 22px);
}

td.col-name span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

tr.is-active td.col-name span {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-break: break-all;
}

.col-actions {
    width: 120px;
}

.row-actions {
    gap: 6px;
}

.empty {
    padding: 44px 20px;
    color: var(--muted);
    text-align: center;
}

.notice {
    margin: 12px 0;
    border-radius: 6px;
    padding: 10px 12px;
    font-weight: 700;
}

.notice.ok {
    background: #e8f6ef;
    color: #17653b;
}

.notice.error {
    background: #ffecec;
    color: #a52626;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(100%, 380px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    padding: 24px;
}

.login-panel h1 {
    font-size: 24px;
}

.login-form {
    margin-top: 18px;
}

@media (max-width: 980px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 20px;
    }

    .layout {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .list-head {
        flex-direction: column;
    }

    .search-form {
        width: 100%;
    }
}

@media (max-width: 620px) {
    h1 {
        font-size: 24px;
    }

    .search-form {
        display: grid;
        grid-template-columns: 1fr auto;
    }

    .search-form .ghost {
        grid-column: 1 / -1;
    }

    .top-actions,
    .form-actions,
    .bulk-actions {
        width: 100%;
    }

    .top-actions .button,
    .form-actions .button,
    .bulk-actions button {
        flex: 1;
    }
}
