:root {
    --ink: #14201b;
    --muted: #5e6b64;
    --paper: #eef3ef;
    --panel: #ffffff;
    --line: #d5ddd8;
    --side: #12231c;
    --side-hover: #1c3329;
    --accent: #0f6b4c;
    --accent-soft: #e3f3ec;
    --accent-2: #c46212;
    --danger: #b42318;
    --ok: #087443;
    --warn: #8a5a12;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(18, 35, 28, 0.04), 0 16px 40px rgba(18, 35, 28, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    letter-spacing: 0;
    word-spacing: 0;
    color: var(--ink);
    background: var(--paper);
}

a { color: var(--accent); }
code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    background: #f1f5f2;
    padding: 0.1em 0.35em;
    border-radius: 6px;
}

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

.side {
    background: var(--side);
    color: #e8f0eb;
    padding: 28px 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}
.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 2px 0 10px;
}
.brand { padding: 0; min-width: 0; }
.brand small {
    display: block;
    color: #9bb0a6;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.brand strong {
    display: block;
    font-size: 22px;
    font-weight: 700;
}
.home-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: #e8f0eb;
    text-decoration: none;
    background: rgba(232, 240, 235, 0.06);
    border: 1px solid rgba(232, 240, 235, 0.12);
}
.home-btn:hover {
    background: var(--side-hover);
    color: #fff;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
    margin: 16px 12px 4px;
    color: #8aa198;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.nav-logout { margin: 4px 0 0; }
.nav a,
.nav button.linkish {
    color: #e8f0eb;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 10px;
    border: 0;
    background: none;
    text-align: left;
    width: 100%;
    font: inherit;
    cursor: pointer;
}
.nav a:hover,
.nav a.active,
.nav button.linkish:hover { background: var(--side-hover); }
.side-foot {
    margin-top: auto;
    padding: 12px;
    color: #9bb0a6;
    font-size: 12px;
    line-height: 1.6;
}

.main { padding: 36px 40px 56px; max-width: 1120px; }
.top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 24px;
}
h1 {
    margin: 0 0 8px;
    font-size: 30px;
    line-height: 1.2;
    font-weight: 700;
}
h3 { margin: 0 0 12px; font-size: 18px; }
.sub { margin: 0; color: var(--muted); max-width: 42rem; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.card, .box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card { padding: 18px; }
a.card { text-decoration: none; color: inherit; display: block; }
a.card:hover { border-color: #b7cfc4; }
.card b { display: block; font-size: 26px; line-height: 1.2; margin-bottom: 4px; }
.card span { color: var(--muted); font-size: 13px; display: block; margin-bottom: 10px; }
.card code { display: inline-block; }
.box { padding: 22px; margin-bottom: 18px; }
.box p:first-child { margin-top: 0; }
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px 28px;
    margin: 0;
}
.stats dt {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stats dd { margin: 0; }

.flash {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    line-height: 1.45;
}
.flash.ok { background: #e7f6ee; color: var(--ok); }
.flash.error { background: #fde8e6; color: var(--danger); }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 6px;
}
label.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    font-weight: 550;
    line-height: 1.45;
    margin: 0;
    cursor: pointer;
    user-select: none;
}
label.check > span {
    flex: 1;
    min-width: 0;
    padding-top: 1px;
}
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    max-width: 20px;
    max-height: 20px;
    margin: 1px 0 0;
    padding: 0;
    flex: 0 0 20px;
    display: inline-grid;
    place-content: center;
    border: 1.5px solid #b7c4bc;
    border-radius: 6px;
    background: #fff;
    color: transparent;
    cursor: pointer;
    vertical-align: top;
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
input[type="checkbox"]::before {
    content: "";
    width: 11px;
    height: 11px;
    transform: scale(0);
    transition: transform .12s ease;
    background-color: #fff;
    clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 18%, 82% 0, 38% 62%);
}
input[type="checkbox"]:hover {
    border-color: var(--accent);
}
input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}
input[type="checkbox"]:checked::before {
    transform: scale(1);
}
input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
    border-color: var(--accent);
}
input[type="checkbox"]:active {
    transform: scale(0.96);
}
label.check:hover input[type="checkbox"]:not(:checked) {
    border-color: var(--accent);
    background: #f7fbf8;
}

.field { margin-bottom: 16px; min-width: 0; }
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea,
.auth-card input:not([type="checkbox"]):not([type="radio"]),
.auth-card select,
.auth-card textarea {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
.field textarea,
.auth-card textarea {
    min-height: 180px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.field textarea.area { min-height: 360px; }
.field select,
.auth-card select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 42px;
    cursor: pointer;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%235e6b64' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.7' d='m4 6.2 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px 16px;
}
.field select::-ms-expand,
.auth-card select::-ms-expand { display: none; }
.field input[type="file"] {
    padding: 8px 12px;
    cursor: pointer;
    line-height: 1.3;
}
.field input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 7px 12px;
    border: 0;
    border-radius: 8px;
    background: #e8eee9;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.field select:focus,
.field textarea:focus,
.auth-card input:not([type="checkbox"]):not([type="radio"]):focus,
.auth-card select:focus {
    outline: 2px solid #b7e0cc;
    border-color: var(--accent);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions input[type="text"],
.actions input:not([type]) {
    width: 160px;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font: inherit;
}
.hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

button, .btn {
    appearance: none;
    border: 0;
    border-radius: 10px;
    padding: 11px 16px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.auth-card button[type="submit"] { width: 100%; margin-top: 6px; }
.btn.ghost, button.ghost { background: #e8eee9; color: var(--ink); }
.btn.warn, button.warn { background: var(--accent-2); }
.btn.danger, button.danger { background: var(--danger); }
.btn.small, button.small { padding: 7px 11px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.CodeMirror { border: 1px solid var(--line); border-radius: 10px; height: 520px; font-size: 14px; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 12% 12%, #cfe8dc, transparent 36%),
        radial-gradient(circle at 88% 8%, #f3e2c8, transparent 30%),
        var(--paper);
}
.auth-card {
    width: min(520px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow);
}
.req-title {
    font-size: 14px;
    font-weight: 650;
    margin: 4px 0 10px;
}
.req-list {
    list-style: none;
    margin: 0 0 22px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.req-list li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 14px;
    line-height: 1.4;
}
.req-mark {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex: 0 0 20px;
    margin-top: 1px;
}
.req-ok .req-mark { background: #e7f6ee; color: var(--ok); }
.req-fail .req-mark { background: #fde8e6; color: var(--danger); }
.req-warn .req-mark { background: #f7ecd4; color: var(--warn); }
.req-detail {
    display: block;
    color: var(--muted);
    font-size: 13px;
}
.auth-card .hint { margin-bottom: 8px; }
.auth-card h1 { margin-bottom: 8px; }
.auth-card .sub { margin-bottom: 22px; }
.warn-http {
    background: #f7ecd4;
    color: var(--warn);
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 16px;
    line-height: 1.45;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow: auto;
    padding: 10px 12px;
    background: #f4f7f5;
    border-radius: 10px;
}
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.live-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-bottom: 18px;
    padding: 12px 14px;
    background: #e7f3ec;
    border: 1px solid #c5ddd0;
    border-radius: 12px;
    color: #24513d;
    font-size: 14px;
}
.live-bar code { background: #fff; }

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.media-card {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.media-card.is-new {
    border-color: #8fc7ae;
    box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}
.media-thumb {
    display: block;
    aspect-ratio: 4 / 3;
    background:
        linear-gradient(45deg, #e8eee9 25%, transparent 25%),
        linear-gradient(-45deg, #e8eee9 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e8eee9 75%),
        linear-gradient(-45deg, transparent 75%, #e8eee9 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #f4f7f5;
    overflow: hidden;
}
.media-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.media-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
}
.media-meta strong {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.media-url {
    display: flex;
    gap: 8px;
    align-items: center;
}
.media-url input {
    flex: 1;
    min-width: 0;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf8;
    font: inherit;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}
.media-url input:focus {
    outline: 2px solid #b7e0cc;
    border-color: var(--accent);
}

.search-table td { vertical-align: top; }
.search-snippets {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.search-snippets code {
    display: block;
    white-space: normal;
    word-break: break-word;
    background: #f4f7f5;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.45;
}

.map {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.map-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    min-height: 180px;
}
.map-card:hover { border-color: #b7cfc4; }
.map-kicker {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.map-card strong { font-size: 24px; line-height: 1.2; }
.map-card span { color: var(--muted); font-size: 13px; flex: 1; }
.map-card code { align-self: flex-start; }

.label-text {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}
.file-pick {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.file-name { color: var(--muted); font-size: 14px; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .side { gap: 16px; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav a, .nav button.linkish { width: auto; }
    .side-foot { display: none; }
    .row { grid-template-columns: 1fr; }
    .main { padding: 20px; }
}
