:root {
    color-scheme: dark;
    --bg: #08070d;
    --bg-soft: #0d0a14;
    --panel: #12101a;
    --panel-2: #171321;
    --panel-3: #1d1729;
    --text: #f6f2ff;
    --text-soft: #d8cfee;
    --muted: #958aa9;
    --line: rgba(196, 158, 255, .14);
    --line-strong: rgba(181, 126, 255, .34);
    --accent: #a855f7;
    --accent-bright: #c084fc;
    --accent-2: #6d5dfc;
    --accent-soft: rgba(168, 85, 247, .13);
    --danger: #ff627d;
    --danger-soft: rgba(255, 98, 125, .13);
    --success: #43d89f;
    --success-soft: rgba(67, 216, 159, .12);
    --warning: #ffcc66;
    --shadow: 0 24px 70px rgba(0, 0, 0, .38);
    --shadow-soft: 0 14px 36px rgba(0, 0, 0, .25);
    --glow: 0 0 0 1px rgba(168, 85, 247, .08), 0 18px 55px rgba(92, 35, 165, .13);
    --radius-xl: 24px;
    --radius-lg: 19px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
    position: relative;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(circle at 9% -4%, rgba(139, 64, 238, .22), transparent 30rem),
        radial-gradient(circle at 96% 2%, rgba(93, 67, 255, .15), transparent 27rem),
        radial-gradient(circle at 50% 115%, rgba(168, 85, 247, .10), transparent 42rem),
        linear-gradient(145deg, #07060b 0%, var(--bg) 48%, #0b0712 100%);
    font: 15px/1.55 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .32;
    background-image:
        linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
    background-size: 38px 38px;
    mask-image: linear-gradient(to bottom, #000, transparent 82%);
}

button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

a {
    color: var(--accent-bright);
    text-decoration: none;
    transition: color .18s ease, opacity .18s ease;
}
a:hover { color: #dbc0ff; }

::selection { color: #fff; background: rgba(168,85,247,.5); }

.app-shell {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 54px;
}

.topbar {
    position: sticky;
    top: 14px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 72px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(15, 12, 22, .87);
    backdrop-filter: blur(22px) saturate(145%);
    box-shadow: 0 18px 56px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.035);
}

.topbar::after {
    content: "";
    position: absolute;
    inset: auto 18px -1px;
    height: 1px;
    opacity: .72;
    background: linear-gradient(90deg, transparent, rgba(168,85,247,.75), transparent);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    flex: 0 0 auto;
    min-width: 190px;
    color: var(--text);
    text-decoration: none;
}
.brand:hover { color: var(--text); }

.brand-mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border: 1px solid rgba(216, 182, 255, .34);
    border-radius: 15px;
    color: #fff;
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,.28), transparent 30%),
        linear-gradient(145deg, #bc65ff, #7735d4 58%, #4e34d9);
    box-shadow: 0 12px 28px rgba(123, 54, 209, .34), inset 0 1px 0 rgba(255,255,255,.24);
    font-size: 22px;
}
.brand-mark::after {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 11px;
}

.brand-copy { display: grid; min-width: 0; line-height: 1.1; }
.brand-copy strong {
    max-width: 150px;
    overflow: hidden;
    color: var(--text);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: .02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.brand-copy small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .2em;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    padding: 2px;
    scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

.main-nav a,
.logout {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 13px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    transition: .2s ease;
}

.nav-icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    color: #bca8d4;
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
}

.main-nav a:hover,
.main-nav a.active,
.logout:hover {
    color: #fff;
    border-color: rgba(190, 143, 255, .18);
    background: rgba(168,85,247,.09);
}
.main-nav a.active {
    border-color: rgba(192,132,252,.30);
    background: linear-gradient(180deg, rgba(168,85,247,.20), rgba(109,93,252,.10));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 10px 25px rgba(82,33,148,.14);
}
.main-nav a.active::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: -4px;
    height: 2px;
    border-radius: 99px;
    background: linear-gradient(90deg, transparent, var(--accent-bright), transparent);
    box-shadow: 0 0 14px rgba(192,132,252,.8);
}
.main-nav a.active .nav-icon { color: var(--accent-bright); }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 46px;
    padding: 5px 12px 5px 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text-soft);
    background: rgba(255,255,255,.035);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.user-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(192,132,252,.22);
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(145deg, rgba(168,85,247,.65), rgba(93,67,255,.56));
    font-size: 13px;
    font-weight: 950;
    text-transform: uppercase;
}
.user-copy { display: grid; line-height: 1.2; }
.user-copy small { color: var(--muted); font-size: 10px; font-weight: 700; }
.logout { min-width: 46px; padding: 0 13px; }
.logout-icon { font-size: 16px; }

.content { padding-top: 30px; }

.flash {
    position: relative;
    margin: 18px 3px 0;
    padding: 14px 18px 14px 46px;
    overflow: hidden;
    border: 1px solid rgba(67,216,159,.24);
    border-radius: 15px;
    color: #c8ffe9;
    background: linear-gradient(90deg, rgba(67,216,159,.13), rgba(67,216,159,.055));
    box-shadow: var(--shadow-soft);
}
.flash::before {
    content: "✓";
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    color: #081810;
    background: var(--success);
    font-size: 12px;
    font-weight: 950;
}
.flash.error {
    color: #ffd4dc;
    border-color: rgba(255,98,125,.25);
    background: linear-gradient(90deg, rgba(255,98,125,.14), rgba(255,98,125,.055));
}
.flash.error::before { content: "!"; color: #fff; background: var(--danger); }

.page-head {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
    margin: 6px 2px 22px;
    padding: 2px 0 16px;
}
.page-head::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--line-strong), transparent 60%);
}

h1, h2, h3, p { margin-top: 0; }
h1 {
    margin-bottom: 8px;
    color: #fff;
    font-size: clamp(34px, 5vw, 54px);
    line-height: .98;
    letter-spacing: -.055em;
    text-shadow: 0 10px 35px rgba(105,48,169,.18);
}
h2 { margin-bottom: 0; color: #fff; font-size: 22px; letter-spacing: -.025em; }
h3 { margin-bottom: 5px; color: var(--text); font-size: 17px; letter-spacing: -.015em; }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 11px;
    color: var(--accent-bright);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .16em;
    text-transform: uppercase;
}
.eyebrow::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-bright);
    box-shadow: 0 0 14px rgba(192,132,252,.85);
}

.muted, .hint, small { color: var(--muted); }
.muted { margin-bottom: 0; }
.hint { margin: 12px 0 0; font-size: 13px; }
.empty {
    margin: 0;
    padding: 20px;
    border: 1px dashed var(--line-strong);
    border-radius: 14px;
    color: var(--muted);
    text-align: center;
    background: rgba(255,255,255,.018);
}
.error-text { color: var(--danger); }

.card {
    position: relative;
    min-width: 0;
    padding: 22px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background:
        linear-gradient(145deg, rgba(255,255,255,.045), transparent 34%),
        linear-gradient(180deg, rgba(23,19,33,.96), rgba(15,12,22,.96));
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.035);
}
.card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 120px;
    height: 1px;
    background: linear-gradient(90deg, var(--accent-bright), transparent);
    opacity: .55;
}
.card:hover { border-color: rgba(192,132,252,.20); }

.wide-card { margin-top: 18px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}
.section-title h2 { display: inline-flex; align-items: center; gap: 10px; }
.section-title h2::before {
    content: "";
    width: 3px;
    height: 22px;
    border-radius: 99px;
    background: linear-gradient(var(--accent-bright), var(--accent-2));
    box-shadow: 0 0 14px rgba(168,85,247,.55);
}

.badge,
.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 29px;
    padding: 0 10px;
    border: 1px solid rgba(192,132,252,.22);
    border-radius: 999px;
    color: var(--accent-bright);
    background: var(--accent-soft);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}
.role-badge { margin-left: 7px; }

.stack-form, .note-form, .inline-form, .server-form, .update-form {
    display: grid;
    gap: 14px;
}
.inline-form { grid-template-columns: 1fr 1.4fr auto; align-items: end; }
.server-form { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.server-form .span-2 { grid-column: span 2; }
.server-form.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }
.note-form { grid-template-columns: 1fr 2fr auto; align-items: start; margin-bottom: 18px; }
.vertical-form { grid-template-columns: 1fr; align-items: stretch; }
.vertical-form .span-2 { grid-column: auto; }
.full { width: 100%; }

label {
    display: grid;
    gap: 7px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .01em;
}

input, textarea, select {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    border: 1px solid rgba(193,162,229,.15);
    border-radius: 13px;
    outline: none;
    color: var(--text);
    background: rgba(4,3,8,.54);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #70667e; }
input:hover, textarea:hover, select:hover { border-color: rgba(192,132,252,.27); }
input:focus, textarea:focus, select:focus {
    border-color: rgba(192,132,252,.72);
    background: rgba(8,5,14,.75);
    box-shadow: 0 0 0 4px rgba(168,85,247,.11), 0 12px 30px rgba(62,26,100,.12);
}
select {
    appearance: none;
    padding-right: 38px;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--accent-bright) 50%),
        linear-gradient(135deg, var(--accent-bright) 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}
select option { color: #171120; background: #fff; }
select[multiple] { min-height: 128px; padding-right: 14px; background-image: none; }
select[multiple] option { padding: 7px 8px; }
input[type="file"] { padding: 8px; }
input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 9px 12px;
    border: 0;
    border-radius: 9px;
    color: #fff;
    background: rgba(168,85,247,.28);
    cursor: pointer;
    font-weight: 800;
}

.btn, .icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 12px 17px;
    overflow: hidden;
    border: 1px solid rgba(192,132,252,.17);
    border-radius: 13px;
    color: var(--text);
    background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.035));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
    cursor: pointer;
    font-weight: 850;
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.btn:hover, .icon-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(192,132,252,.34);
    color: #fff;
    background: rgba(168,85,247,.11);
    box-shadow: 0 10px 26px rgba(54,25,85,.17);
}
.btn:active, .icon-btn:active { transform: translateY(0); }
.btn.primary {
    border-color: rgba(220,190,255,.28);
    color: #fff;
    background: linear-gradient(135deg, #b45dff, #7c3ee8 55%, #5d4bfa);
    box-shadow: 0 12px 28px rgba(117,49,199,.25), inset 0 1px 0 rgba(255,255,255,.22);
}
.btn.primary:hover {
    background: linear-gradient(135deg, #c877ff, #8d50ed 55%, #7162ff);
    box-shadow: 0 15px 34px rgba(126,57,210,.34), inset 0 1px 0 rgba(255,255,255,.24);
}
.icon-btn { min-height: 38px; padding: 8px 11px; border-radius: 11px; font-size: 12px; }
.icon-btn.danger {
    color: #ffcbd5;
    border-color: rgba(255,98,125,.18);
    background: var(--danger-soft);
}
.icon-btn.danger:hover { border-color: rgba(255,98,125,.42); background: rgba(255,98,125,.2); }

.small-link { color: var(--accent-bright); font-size: 13px; font-weight: 850; }

.resource-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.resource-pills a {
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--text);
    background: var(--accent-soft);
}

.resource-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.resource-tile {
    position: relative;
    min-width: 0;
    min-height: 124px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 0 0, rgba(168,85,247,.17), transparent 44%),
        linear-gradient(145deg, rgba(255,255,255,.046), rgba(255,255,255,.018));
    box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,.025);
    transition: .2s ease;
}
.resource-tile::after {
    content: "↗";
    position: absolute;
    right: 17px;
    bottom: 15px;
    color: #7e708f;
    font-size: 15px;
    transition: transform .2s ease, color .2s ease;
}
.resource-tile:hover {
    transform: translateY(-3px);
    border-color: rgba(192,132,252,.42);
    box-shadow: 0 20px 45px rgba(39,17,64,.28), 0 0 0 1px rgba(168,85,247,.06);
}
.resource-tile:hover::after { transform: translate(2px,-2px); color: var(--accent-bright); }
.resource-tile a {
    display: grid;
    align-content: space-between;
    gap: 18px;
    min-height: 124px;
    padding: 19px 46px 19px 19px;
    color: var(--text);
    text-decoration: none;
}
.resource-tile strong { overflow-wrap: anywhere; font-size: 17px; letter-spacing: -.02em; }
.resource-tile span:not(.drag-handle) {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.resource-tiles.is-sortable .resource-tile { cursor: grab; }
.resource-tiles.is-sortable .resource-tile:active { cursor: grabbing; }
.resource-tile.is-dragging, .server-tile.is-dragging {
    opacity: .38;
    transform: scale(.975);
    border-style: dashed;
    border-color: var(--accent-bright);
}
.drag-handle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--muted);
    background: rgba(10,7,15,.7);
    pointer-events: none;
    font-size: 12px;
    letter-spacing: -4px;
}

.cards-list, .table-list, .server-list { display: grid; gap: 13px; }
.mini-card, .row-card, .server-card {
    min-width: 0;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, rgba(255,255,255,.035), rgba(255,255,255,.012));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
    transition: border-color .18s ease, background .18s ease;
}
.mini-card:hover, .row-card:hover, .server-card:hover {
    border-color: rgba(192,132,252,.24);
    background: linear-gradient(145deg, rgba(168,85,247,.055), rgba(255,255,255,.014));
}
.mini-card p { margin: 14px 0 0; color: var(--text-soft); }
.mini-card-head, .server-top, .row-card {
    display: flex;
    gap: 14px;
    justify-content: space-between;
    align-items: flex-start;
}
.row-card { flex-wrap: wrap; }
.row-main { display: flex; align-items: center; gap: 14px; min-width: 260px; flex: 1; }
.row-main > div { min-width: 0; }
.row-main a { overflow-wrap: anywhere; word-break: break-word; }
.order {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border: 1px solid var(--line);
    border-radius: 13px;
    color: var(--accent-bright);
    background: var(--accent-soft);
    font-size: 12px;
    font-weight: 950;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; }

.edit-box {
    margin-top: 14px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
}
.edit-box summary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--accent-bright);
    cursor: pointer;
    font-size: 13px;
    font-weight: 850;
}
.edit-box summary::before { content: "✦"; font-size: 11px; }

.inline-ip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 29px;
    padding: 4px 10px;
    overflow-wrap: anywhere;
    border: 1px solid rgba(192,132,252,.22);
    border-radius: 999px;
    color: #d8b8ff;
    background: rgba(168,85,247,.095);
    font: 800 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-word;
}

.secret-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 16px;
}
.secret-grid button {
    min-width: 0;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    color: var(--text);
    background: rgba(255,255,255,.025);
    cursor: pointer;
    text-align: left;
    transition: .18s ease;
}
.secret-grid button:hover { border-color: rgba(192,132,252,.38); background: rgba(168,85,247,.07); }
.secret-grid span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.secret-grid b {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    white-space: normal;
    word-break: break-word;
}
.secret-grid .copied { color: var(--success); }

.server-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 335px), 1fr));
    gap: 14px;
}
.server-tile {
    position: relative;
    min-width: 0;
    min-height: 138px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 100% 0, rgba(93,67,255,.12), transparent 46%),
        linear-gradient(150deg, rgba(255,255,255,.043), rgba(255,255,255,.014));
    box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,.025);
    transition: .2s ease;
}
.server-tile:hover {
    transform: translateY(-2px);
    border-color: rgba(192,132,252,.34);
    box-shadow: 0 20px 45px rgba(35,15,57,.24);
}
.server-tiles.is-sortable .server-tile { cursor: grab; }
.server-tiles.is-sortable .server-tile:active { cursor: grabbing; }
.server-tile-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    min-height: 138px;
    padding: 19px 19px 12px;
}
.server-tile-main { flex: 1 1 auto; min-width: 0; }
.server-tile-main h3 { max-width: 100%; margin-bottom: 12px; overflow-wrap: anywhere; word-break: break-word; }
.server-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.server-meta a, .server-meta span { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.server-delete-form { flex: 0 0 auto; margin-left: auto; }
.server-tile .drag-handle { position: static; flex: 0 0 28px; margin-top: 0; }
.server-details { padding: 0 19px 19px; border-top: 1px solid var(--line); }
.server-details[hidden] { display: none; }
.server-tile.is-open {
    grid-column: span 2;
    border-color: rgba(192,132,252,.43);
    box-shadow: 0 22px 54px rgba(48,19,82,.28), inset 0 1px 0 rgba(255,255,255,.035);
}
.server-tile.is-open .server-tile-head { min-height: auto; }
.server-tile::after {
    content: "Нажмите, чтобы открыть доступы";
    display: block;
    padding: 0 19px 15px;
    color: #756a83;
    font-size: 11px;
    pointer-events: none;
}
.server-tile.is-open::after { content: "Нажмите по верхней части, чтобы скрыть доступы"; color: var(--accent-bright); }
.server-tile.is-open .server-details::before { content: ""; display: block; height: 15px; }

.comment {
    margin: 14px 0 0;
    padding: 12px 14px;
    overflow-wrap: anywhere;
    border: 1px solid rgba(192,132,252,.10);
    border-radius: 13px;
    color: var(--text-soft);
    background: rgba(168,85,247,.055);
    word-break: break-word;
}

.clean-list, .timeline ul { margin: 0; padding-left: 20px; color: var(--text-soft); }
.clean-list li + li, .timeline li + li { margin-top: 7px; }
.clean-list li::marker, .timeline li::marker { color: var(--accent-bright); }
.version-number {
    margin-bottom: 10px;
    color: #fff;
    font-size: 50px;
    font-weight: 950;
    letter-spacing: -.07em;
    text-shadow: 0 0 30px rgba(168,85,247,.28);
}

.update-form { grid-template-columns: 1fr auto; align-items: end; }
.timeline { display: grid; gap: 12px; }
.timeline article {
    position: relative;
    padding: 15px 16px 15px 19px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255,255,255,.022);
}
.timeline article::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(var(--accent-bright), var(--accent-2));
}
.timeline strong { margin-right: 10px; color: var(--accent-bright); font-size: 18px; }
.timeline span { color: var(--muted); font-size: 12px; }
.timeline ul { margin-top: 8px; }

.history-panel summary {
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.history-panel summary::-webkit-details-marker { display: none; }
.history-panel summary::before {
    content: "+";
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    color: var(--accent-bright);
    background: var(--accent-soft);
    font-weight: 950;
    transition: transform .18s ease;
}
.history-panel[open] summary::before { content: "−"; }
.history-summary-title { color: #fff; font-size: 21px; font-weight: 900; letter-spacing: -.03em; }
.history-summary-hint { margin-left: auto; color: var(--muted); font-size: 12px; }
.history-panel .timeline { margin-top: 14px; }
.pagination { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--text);
    background: rgba(255,255,255,.025);
    font-weight: 900;
}
.pagination a:hover, .pagination a.active {
    border-color: rgba(192,132,252,.44);
    color: #fff;
    background: var(--accent-soft);
}

.login-layout {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 138px);
    padding: 36px 0;
}
.login-card {
    width: min(440px, 100%);
    padding: 30px;
    border-color: rgba(192,132,252,.24);
    background:
        radial-gradient(circle at 50% 0, rgba(168,85,247,.18), transparent 44%),
        linear-gradient(180deg, rgba(24,18,35,.97), rgba(12,9,18,.98));
    box-shadow: 0 34px 100px rgba(0,0,0,.48), 0 0 70px rgba(117,49,199,.10);
}
.login-card h1 { margin-bottom: 24px; font-size: 40px; text-align: center; }
.login-card .eyebrow { display: flex; justify-content: center; }
.login-emblem {
    position: relative;
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin: 0 auto 20px;
    border: 1px solid rgba(222,195,255,.34);
    border-radius: 24px;
    color: #fff;
    background: linear-gradient(145deg, #c56cff, #823de2 58%, #5849ef);
    box-shadow: 0 20px 45px rgba(121,51,204,.33), inset 0 1px 0 rgba(255,255,255,.24);
    font-size: 34px;
}
.login-emblem::after { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(255,255,255,.12); border-radius: 18px; }

.theme-settings-form { display: grid; grid-template-columns: minmax(220px, 320px) auto; align-items: end; gap: 14px; }

/* Settings catalog */
.settings-page-head { margin-bottom: 18px; }
.settings-category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 21px;
}
.settings-nav-card {
    position: relative;
    display: grid;
    gap: 8px;
    min-height: 132px;
    width: 100%;
    padding: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    color: var(--text);
    text-align: left;
    text-decoration: none;
    background:
        radial-gradient(circle at 100% 0, rgba(168,85,247,.11), transparent 42%),
        linear-gradient(145deg, rgba(255,255,255,.04), rgba(255,255,255,.014));
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    font: inherit;
    transition: .2s ease;
}
.settings-nav-card::after {
    content: "→";
    position: absolute;
    right: 17px;
    bottom: 15px;
    color: #756981;
    font-size: 17px;
}
.settings-nav-card span {
    width: fit-content;
    min-width: 42px;
    padding: 5px 10px;
    border: 1px solid rgba(192,132,252,.20);
    border-radius: 999px;
    color: var(--accent-bright);
    background: var(--accent-soft);
    font-size: 11px;
    font-weight: 900;
}
.settings-nav-card strong { color: #fff; font-size: 18px; letter-spacing: -.02em; }
.settings-nav-card small { max-width: calc(100% - 25px); color: var(--muted); font-weight: 700; }
.settings-nav-card:hover, .settings-nav-card.is-active {
    transform: translateY(-3px);
    border-color: rgba(192,132,252,.42);
    box-shadow: 0 20px 45px rgba(38,16,63,.26);
}
.settings-nav-card.is-active {
    background:
        radial-gradient(circle at 100% 0, rgba(192,132,252,.20), transparent 44%),
        linear-gradient(145deg, rgba(168,85,247,.14), rgba(93,67,255,.055));
}
.settings-nav-card.is-active::after { color: var(--accent-bright); }
.settings-helper { margin: -4px 4px 18px; color: var(--muted); font-size: 13px; font-weight: 700; }
.settings-panel { display: none; }
.settings-panel.is-active { display: block; animation: panelIn .24s ease both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.settings-category { margin-top: 22px; scroll-margin-top: 110px; }
.settings-category-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 14px;
    padding: 0 3px;
}
.settings-category-head h2 { font-size: 27px; }
.settings-category-head .muted { max-width: 620px; text-align: right; }
.settings-split { display: grid; grid-template-columns: minmax(280px, .82fr) minmax(0, 1.38fr); gap: 18px; align-items: start; }
.settings-split.single { grid-template-columns: minmax(0, 1fr); }
.settings-block { min-width: 0; }
.settings-block-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.settings-block-title h3 { margin: 0; font-size: 20px; }
.settings-card-list { display: grid; gap: 13px; max-height: 860px; overflow: auto; padding-right: 5px; }
.settings-card-list::-webkit-scrollbar { width: 8px; }
.settings-card-list::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 99px; background: rgba(168,85,247,.28); background-clip: padding-box; }
.settings-list-card { box-shadow: none; }
.settings-role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 15px; }
.settings-role-grid div {
    display: grid;
    gap: 4px;
    min-height: 76px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255,255,255,.022);
}
.settings-role-grid strong { color: var(--text); font-size: 12px; }
.settings-role-grid span { color: var(--muted); font-size: 11px; line-height: 1.35; }

@media (max-width: 1180px) {
    .brand { min-width: auto; }
    .brand-copy { display: none; }
    .user-copy small { display: none; }
}

@media (max-width: 960px) {
    .app-shell { width: min(100% - 20px, 1320px); padding-top: 10px; }
    .topbar { top: 8px; flex-wrap: wrap; border-radius: 17px; }
    .brand { order: 1; }
    .topbar-actions { order: 2; margin-left: auto; }
    .main-nav { order: 3; flex-basis: 100%; width: 100%; padding-top: 6px; border-top: 1px solid var(--line); }
    .main-nav a { flex: 1 0 auto; }
    .page-head, .mini-card-head, .server-top { align-items: stretch; flex-direction: column; }
    .grid.two, .inline-form, .note-form, .server-form, .server-form.compact, .secret-grid, .update-form, .theme-settings-form { grid-template-columns: 1fr; }
    .server-tile.is-open { grid-column: auto; }
    .server-tile-head { flex-wrap: wrap; }
    .server-delete-form { width: 100%; margin-left: 0; }
    .server-delete-form .icon-btn { width: 100%; }
    .history-panel summary { flex-wrap: wrap; }
    .history-summary-hint { width: 100%; margin-left: 39px; }
    .server-form .span-2 { grid-column: auto; }
    .settings-category-grid { grid-template-columns: 1fr; }
    .settings-split { grid-template-columns: 1fr; }
    .settings-category-head { align-items: flex-start; flex-direction: column; }
    .settings-category-head .muted { text-align: left; }
}

@media (max-width: 680px) {
    .app-shell { width: min(100% - 14px, 1320px); }
    .topbar { padding: 9px; }
    .brand-mark { width: 42px; height: 42px; flex-basis: 42px; border-radius: 13px; }
    .user-pill { padding-right: 7px; }
    .user-copy { display: none; }
    .logout { min-width: 42px; padding: 0; }
    .logout-label { display: none; }
    .main-nav a { min-height: 42px; padding: 0 11px; }
    .nav-label { font-size: 12px; }
    .content { padding-top: 22px; }
    .card { padding: 17px; border-radius: 18px; }
    h1 { font-size: 38px; }
    .page-head { margin-bottom: 17px; }
    .section-title { align-items: flex-start; }
    .resource-tiles, .server-tiles { grid-template-columns: 1fr; }
    .resource-tile a { padding: 17px 44px 17px 17px; }
    .row-main { min-width: 100%; }
    .row-actions { width: 100%; }
    .row-actions .icon-btn, .row-actions form { flex: 1; }
    .row-actions form .icon-btn { width: 100%; }
    .settings-role-grid { grid-template-columns: 1fr; }
    .settings-nav-card { min-height: auto; }
    .login-card { padding: 24px 18px; }
}

body[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f1f8;
    --bg-soft: #ece7f3;
    --panel: #ffffff;
    --panel-2: #faf8fc;
    --panel-3: #f4eff9;
    --text: #20182b;
    --text-soft: #3b3048;
    --muted: #7b7088;
    --line: rgba(69, 43, 91, .12);
    --line-strong: rgba(134, 72, 191, .28);
    --accent: #8a38d6;
    --accent-bright: #9345dc;
    --accent-2: #6354e7;
    --accent-soft: rgba(145, 68, 220, .09);
    --danger: #d9415b;
    --danger-soft: rgba(217,65,91,.09);
    --success: #19845f;
    --success-soft: rgba(25,132,95,.09);
    --shadow: 0 22px 55px rgba(49, 29, 67, .10);
    --shadow-soft: 0 12px 30px rgba(49,29,67,.08);
    background:
        radial-gradient(circle at 8% 0, rgba(159, 79, 224, .14), transparent 31rem),
        radial-gradient(circle at 98% 2%, rgba(93, 78, 232, .10), transparent 27rem),
        linear-gradient(145deg, #fcfbfd 0%, #f5f1f8 55%, #f0ebf5 100%);
}
body[data-theme="light"]::before { opacity: .28; background-image: linear-gradient(rgba(72,42,92,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(72,42,92,.025) 1px, transparent 1px); }
body[data-theme="light"] .topbar { background: rgba(255,255,255,.88); box-shadow: 0 18px 50px rgba(61,35,82,.11), inset 0 1px 0 #fff; }
body[data-theme="light"] h1,
body[data-theme="light"] h2,
body[data-theme="light"] .settings-nav-card strong,
body[data-theme="light"] .history-summary-title { color: #24172e; }
body[data-theme="light"] .card {
    background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(249,247,252,.97));
    box-shadow: var(--shadow), inset 0 1px 0 #fff;
}
body[data-theme="light"] input,
body[data-theme="light"] textarea,
body[data-theme="light"] select { color: var(--text); background-color: rgba(255,255,255,.92); border-color: rgba(69,43,91,.14); }
body[data-theme="light"] input::placeholder,
body[data-theme="light"] textarea::placeholder { color: #a098aa; }
body[data-theme="light"] .btn,
body[data-theme="light"] .icon-btn,
body[data-theme="light"] .mini-card,
body[data-theme="light"] .row-card,
body[data-theme="light"] .server-card,
body[data-theme="light"] .timeline article,
body[data-theme="light"] .settings-role-grid div { background: rgba(73,45,94,.035); }
body[data-theme="light"] .resource-tile,
body[data-theme="light"] .server-tile,
body[data-theme="light"] .settings-nav-card {
    background:
        radial-gradient(circle at 100% 0, rgba(145,68,220,.09), transparent 45%),
        linear-gradient(145deg, rgba(255,255,255,.98), rgba(249,247,252,.94));
    box-shadow: var(--shadow-soft), inset 0 1px 0 #fff;
}
body[data-theme="light"] .secret-grid button,
body[data-theme="light"] .comment { background: rgba(145,68,220,.045); }
body[data-theme="light"] .login-card {
    background: radial-gradient(circle at 50% 0, rgba(145,68,220,.12), transparent 44%), linear-gradient(180deg, #fff, #faf7fc);
}
body[data-theme="light"] .flash { color: #126246; }
body[data-theme="light"] .flash.error { color: #a52b40; }
