*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: #142033;
    background: #fff;
    font-size: 16px;
    line-height: 1.5;
}

button,
input,
textarea {
    font: inherit;
}

a {
    color: #1d4e89;
}

:focus-visible {
    outline: 2px solid #1d4e89;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip {
    position: absolute;
    left: 12px;
    top: -48px;
    background: #fff;
    color: #0e1c2f;
    padding: 8px 12px;
    border-radius: 8px;
    z-index: 5;
}

.skip:focus {
    top: 12px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: 18px;
}

.brand-mark {
    width: 32px;
    height: 32px;
    color: #3d7ec4;
    flex: none;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
    min-height: 100vh;
}

.auth-aside {
    background: #0e1c2f;
    color: #fff;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
}

.aside-title {
    margin: 56px 0 12px;
    font-size: 40px;
    line-height: 1.12;
    letter-spacing: -0.035em;
}

.aside-copy {
    margin: 0;
    max-width: 28ch;
    color: #c5d4e4;
    font-size: 17px;
}

.aside-foot {
    margin: 0;
    color: #8aa0b8;
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: #fff;
}

.auth-card {
    width: min(440px, 100%);
}

.auth-card h2 {
    margin: 0;
    font-size: 30px;
    letter-spacing: -0.03em;
    color: #0e1c2f;
}

.app-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
    background: #fff;
}

.sidebar {
    background: #0e1c2f;
    color: #d5deea;
    padding: 24px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.side-brand {
    text-decoration: none;
    color: inherit;
    padding: 0 8px;
}

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

.side-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: #c5d4e4;
    text-decoration: none;
    font-weight: 600;
}

.side-nav a:hover,
.side-nav a.is-active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.side-foot {
    margin-top: auto;
    padding: 0 8px;
}

.side-email {
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.4;
    color: #93a8bd;
    word-break: break-all;
}

.logout {
    background: transparent;
    color: #d5deea;
    border: 0;
    padding: 8px 4px;
    font-weight: 700;
    cursor: pointer;
}

.logout:hover {
    color: #fff;
}

.main {
    padding: 40px 48px 72px;
    max-width: 1080px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 28px;
}

.page-title {
    margin: 0;
    font-size: 32px;
    line-height: 1.15;
    letter-spacing: -0.035em;
    color: #0e1c2f;
}

.page-lead {
    margin: 8px 0 0;
    color: #526272;
    max-width: 62ch;
}

.page-lead strong {
    color: #142033;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid #e4ebf2;
    border-radius: 16px;
    padding: 22px 22px 18px;
}

.stat:hover {
    border-color: #b7cbe2;
}

.stat.is-static {
    cursor: default;
}

.stat.is-static:hover {
    border-color: #e4ebf2;
}

.stat-note {
    display: block;
    margin-top: 12px;
    color: #526272;
}

.stat-label {
    display: block;
    color: #5c6b7a;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.stat-value {
    display: block;
    margin-top: 12px;
    font-size: 42px;
    line-height: 1;
    letter-spacing: -0.04em;
    color: #0e1c2f;
    font-variant-numeric: tabular-nums;
}

.stat-value.is-ok {
    color: #145c32;
}

.stat-value.is-warn {
    color: #8a6400;
}

.stat-value.is-hot {
    color: #9f2d2d;
}

.stack {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 6px;
}

.field > span,
legend {
    font-weight: 700;
    color: #0e1c2f;
}

fieldset.field {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

input[type="text"],
input[type="email"],
input[type="search"],
input[type="file"],
textarea {
    width: 100%;
    border: 1px solid #d5dde6;
    border-radius: 12px;
    padding: 12px 14px;
    color: #142033;
    background: #fff;
}

textarea {
    min-height: 320px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    line-height: 1.55;
}

input:focus,
textarea:focus {
    border-color: #1d4e89;
    outline: 3px solid rgba(29, 78, 137, 0.16);
}

.hint,
.muted {
    color: #5c6b7a;
    font-size: 14px;
}

.hint {
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.2;
}

.btn-primary {
    background: #0e1c2f;
    color: #fff;
}

.btn-primary:hover {
    background: #18324d;
}

.btn-secondary {
    background: #fff;
    color: #0e1c2f;
    border-color: #d5dde6;
}

.btn-secondary:hover {
    border-color: #1d4e89;
}

.btn-danger {
    background: #9f2d2d;
    color: #fff;
}

.btn-danger:hover {
    background: #861f1f;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.link-danger {
    color: #9f2d2d;
    font-weight: 700;
}

.flash {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 18px;
}

.flash ul {
    margin: 0;
    padding-left: 18px;
}

.flash-ok {
    background: #e7f6ee;
    color: #145c32;
}

.flash-info {
    background: #e8f1fa;
    color: #16324f;
}

.flash-error {
    background: #fdecec;
    color: #8a1f1f;
}

.flash-error a {
    font-weight: 700;
    margin-left: 8px;
    white-space: nowrap;
}

.empty {
    border: 1px dashed #d5dde6;
    border-radius: 16px;
    padding: 32px 20px;
    text-align: center;
    color: #526272;
}

.empty.compact {
    text-align: left;
    padding: 16px;
    margin-top: 12px;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #5c6b7a;
    font-weight: 700;
    padding: 0 12px 10px;
    border-bottom: 1px solid #e6ebf1;
}

.data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid #eef2f6;
    vertical-align: middle;
}

.row-title {
    color: #0e1c2f;
    font-weight: 700;
    text-decoration: none;
}

.row-title:hover {
    text-decoration: underline;
}

.row-id {
    display: block;
    margin-top: 2px;
    color: #5c6b7a;
    font-size: 12px;
}

.tool-name {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: #1d4e89;
}

input.tool-name {
    font-size: 15px;
}

input[readonly] {
    background: #f4f7fb;
    color: #526272;
}

textarea.textarea-short {
    min-height: 120px;
}

.actions {
    white-space: nowrap;
    text-align: right;
}

.actions a + a {
    margin-left: 14px;
}

.pill {
    display: inline-flex;
    min-width: 1.6rem;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef3f8;
    color: #16324f;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.picker-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.picker-search {
    flex: 1;
}

.picker-search input {
    max-width: 280px;
}

.picker-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    max-height: 360px;
    overflow: auto;
    border: 1px solid #e6ebf1;
    border-radius: 12px;
}

.picker-list li + li {
    border-top: 1px solid #f2f5f8;
}

.picker-list label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    cursor: pointer;
}

.picker-list input {
    margin-top: 4px;
}

.picker-list span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

dialog {
    border: 0;
    padding: 0;
    border-radius: 16px;
    width: min(440px, calc(100vw - 32px));
    box-shadow: 0 24px 80px rgba(14, 28, 47, 0.28);
}

dialog::backdrop {
    background: rgba(14, 28, 47, 0.48);
}

dialog form {
    padding: 28px;
}

dialog h2 {
    margin: 0 0 8px;
    font-size: 22px;
    letter-spacing: -0.03em;
    color: #0e1c2f;
}

dialog p {
    margin: 0;
    color: #526272;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.list-search {
    margin: 0 0 18px;
    max-width: 420px;
}

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

.pager span {
    color: #526272;
}

@media (max-width: 860px) {
    .auth-shell,
    .app-shell,
    .stats {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        padding: 28px 20px;
    }

    .aside-title {
        margin-top: 28px;
        font-size: 32px;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .side-nav {
        display: flex;
        gap: 6px;
        overflow-x: auto;
    }

    .side-nav a {
        white-space: nowrap;
    }

    .side-foot {
        margin-top: 0;
    }

    .main {
        padding: 24px 16px 48px;
    }

    .page-head,
    .picker-top,
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .page-title {
        font-size: 28px;
    }
}
