:root {
    --bg: #f4efe6;
    --bg-deep: #e7ddd1;
    --panel: rgba(255, 252, 247, 0.84);
    --panel-strong: #fffdf9;
    --panel-border: rgba(125, 92, 58, 0.12);
    --text: #23180d;
    --muted: #756655;
    --muted-soft: #9c8a75;
    --brand: #17624f;
    --brand-strong: #0f4e3f;
    --brand-soft: #dcefe8;
    --accent: #cb6a38;
    --accent-soft: #ffe2d3;
    --danger: #a63232;
    --danger-soft: #fde8e3;
    --line: rgba(84, 59, 34, 0.12);
    --shadow-lg: 0 24px 64px rgba(52, 33, 15, 0.12);
    --shadow-md: 0 14px 34px rgba(52, 33, 15, 0.08);
    --shadow-sm: 0 8px 20px rgba(52, 33, 15, 0.06);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
    --sans: "Aptos", "Segoe UI Variable", "Trebuchet MS", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--sans);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 238, 215, 0.9), transparent 34%),
        radial-gradient(circle at top right, rgba(183, 216, 201, 0.78), transparent 30%),
        linear-gradient(180deg, #fbf7f1 0%, var(--bg) 54%, var(--bg-deep) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.14) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.2), transparent 85%);
}

code,
pre,
textarea {
    font-family: var(--mono);
}

code {
    font-size: 0.92em;
}

a {
    color: inherit;
}

/* ---------- Login ---------- */
.login-body {
    display: grid;
    place-items: center;
    padding: 32px;
}

.login {
    width: min(460px, 100%);
    padding: 36px;
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 251, 246, 0.84));
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
}

.login h1 {
    margin: 0 0 10px;
    font-size: clamp(2rem, 4vw, 2.5rem);
    line-height: 1;
    letter-spacing: -0.04em;
}

.login h1::after {
    content: "";
    display: block;
    width: 76px;
    height: 5px;
    margin-top: 16px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand), var(--accent));
}

.login input {
    width: 100%;
    margin: 18px 0 0;
}

.login button {
    width: 100%;
    margin-top: 16px;
}

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

.login .hint {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

/* ---------- App shell ---------- */
header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 24px clamp(20px, 4vw, 44px) 14px;
    background: linear-gradient(180deg, rgba(248, 242, 234, 0.96), rgba(248, 242, 234, 0.76));
    backdrop-filter: blur(14px);
}

header h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 0.95;
    letter-spacing: -0.05em;
}

header h1::after {
    content: "OTA release operations";
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

header form {
    flex-shrink: 0;
}

.logout,
button {
    appearance: none;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease;
}

.logout {
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

.logout:hover,
button:hover {
    transform: translateY(-1px);
}

.logout:hover {
    background: rgba(255, 255, 255, 0.96);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 0 clamp(20px, 4vw, 44px) 8px;
}

.tabs .tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.92);
    background: rgba(255, 255, 255, 0.62);
    box-shadow: var(--shadow-sm);
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        color 0.18s ease,
        background-color 0.18s ease;
}

.tabs .tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.92);
    transform: translateY(-1px);
}

.tabs .tab.active {
    color: #fff;
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    box-shadow: 0 16px 26px rgba(23, 98, 79, 0.24);
}

main {
    max-width: 1220px;
    margin: 0 auto;
    padding: 26px clamp(20px, 4vw, 44px) 40px;
}

section {
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
    padding: 26px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-xl);
    background: var(--panel);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(14px);
}

section::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--brand), rgba(23, 98, 79, 0.08), var(--accent));
}

section h2,
.page-title {
    margin: 0 0 18px;
    font-size: clamp(1.35rem, 2vw, 1.8rem);
    letter-spacing: -0.03em;
}

.section-hint {
    max-width: 76ch;
    margin-top: -6px;
    margin-bottom: 22px;
    color: var(--muted);
    font-size: 0.98rem;
    line-height: 1.65;
}

/* ---------- Forms ---------- */
label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
}

label.full {
    margin-bottom: 16px;
}

input,
select,
textarea {
    width: 100%;
    padding: 14px 16px;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease,
        background-color 0.18s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted-soft);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(23, 98, 79, 0.34);
    background: #fff;
    box-shadow:
        0 0 0 4px rgba(23, 98, 79, 0.12),
        0 10px 24px rgba(23, 98, 79, 0.08);
    transform: translateY(-1px);
}

input[type="file"] {
    padding: 12px;
}

textarea {
    min-height: 220px;
    line-height: 1.55;
    resize: vertical;
}

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

.actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 20px;
}

button,
#submit-btn,
#apk-submit-btn,
.linphone-form button {
    min-height: 48px;
    padding: 0 22px;
    color: #fff;
    background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
    box-shadow: 0 14px 24px rgba(23, 98, 79, 0.18);
}

button:hover,
#submit-btn:hover,
#apk-submit-btn:hover,
.linphone-form button:hover {
    box-shadow: 0 18px 30px rgba(23, 98, 79, 0.22);
}

button:disabled,
#submit-btn:disabled,
#apk-submit-btn:disabled {
    opacity: 0.65;
    cursor: progress;
    transform: none;
}

#status,
#apk-status,
.linphone-status {
    flex: 1;
    min-height: 24px;
    font-size: 0.95rem;
}

#status.ok,
.linphone-status.ok {
    color: var(--brand-strong);
}

#status.err,
#apk-status.err,
.linphone-status.err {
    color: var(--danger);
}

/* ---------- Markdown ---------- */
.md-editor {
    margin-top: 6px;
}

.md-split {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 18px;
    align-items: stretch;
}

.md-preview {
    min-height: 220px;
    padding: 18px;
    border: 1px solid rgba(23, 98, 79, 0.1);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(180deg, rgba(220, 239, 232, 0.48), rgba(255, 255, 255, 0.82)),
        #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
    overflow: auto;
}

.md-preview .empty {
    color: var(--muted-soft);
}

.md-preview h1,
.md-preview h2,
.md-preview h3 {
    margin: 0 0 14px;
    letter-spacing: -0.03em;
}

.md-preview p,
.md-preview li {
    line-height: 1.6;
}

.md-preview ul {
    padding-left: 20px;
}

.md-preview pre {
    padding: 14px;
    overflow-x: auto;
    border-radius: var(--radius-md);
    background: rgba(35, 24, 13, 0.06);
}

.md-preview code {
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(23, 98, 79, 0.09);
}

/* ---------- Table ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

thead th {
    padding: 16px 14px;
    color: var(--muted);
    font-size: 0.77rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    background: rgba(23, 98, 79, 0.06);
    border-bottom: 1px solid rgba(23, 98, 79, 0.1);
}

tbody td {
    padding: 16px 14px;
    border-bottom: 1px solid rgba(84, 59, 34, 0.08);
    vertical-align: middle;
}

tbody tr {
    transition: background-color 0.18s ease, transform 0.18s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.58);
}

td.small,
td .small {
    color: var(--muted);
    font-size: 0.88rem;
}

td.empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-win {
    color: #0f5c7a;
    background: #dff2fb;
    border-color: #c2e5f7;
}

.badge-mac {
    color: #5b3f87;
    background: #efe6ff;
    border-color: #e0d0ff;
}

.badge-linux {
    color: #91521f;
    background: #ffedd9;
    border-color: #ffd8af;
}

.badge-android {
    color: #266245;
    background: #dff5ea;
    border-color: #bde5cf;
}

.badge-stable {
    color: #1e5e47;
    background: #dff2ea;
    border-color: #bfe5d5;
}

.badge-beta {
    color: #91521f;
    background: #fff0d9;
    border-color: #ffd6aa;
}

.badge-dev {
    color: #8f3550;
    background: #ffe4ef;
    border-color: #ffcadd;
}

.badge-canary {
    color: #8b4a14;
    background: #ffe9c8;
    border-color: #ffd69a;
}

.btn-del {
    min-height: 38px;
    padding: 0 14px;
    color: var(--danger);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(166, 50, 50, 0.15);
    box-shadow: none;
}

.btn-del:hover {
    background: var(--danger-soft);
    box-shadow: none;
}

/* ---------- Status blocks ---------- */
.apk-status {
    margin-bottom: 18px;
    padding: 18px 18px 18px 20px;
    border: 1px solid rgba(23, 98, 79, 0.08);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(220, 239, 232, 0.44), rgba(255, 255, 255, 0.92));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.apk-status.empty {
    border-left-color: rgba(84, 59, 34, 0.24);
    color: var(--muted);
}

.apk-status .current-version {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    overflow-wrap: anywhere;
}

.apk-status .status-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 10px;
}

.apk-status .status-label {
    color: var(--text);
    font-size: 0.95rem;
}

.apk-status .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.apk-status .meta-grid {
    gap: 12px;
}

.apk-status .meta-stack {
    display: grid;
    gap: 6px;
}

.apk-status .meta-chip {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(23, 98, 79, 0.08);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.72);
}

.apk-status .meta-chip-label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.apk-status code {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.apk-status .history {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(84, 59, 34, 0.08);
}

.apk-status .history ul {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
}

.apk-status .history li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.88rem;
}

.apk-status .history li span {
    flex: 1 1 240px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.apk-status .history .btn-del {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.76rem;
    flex-shrink: 0;
}

.linphone-platform {
    margin-bottom: 20px;
}

.linphone-platform:last-child {
    margin-bottom: 0;
}

/* ---------- Utility ---------- */
.error {
    padding: 14px 16px;
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid rgba(166, 50, 50, 0.16);
    border-radius: var(--radius-md);
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .grid,
    .md-split {
        grid-template-columns: 1fr;
    }

    main {
        padding-top: 20px;
    }
}

@media (max-width: 820px) {
    header {
        align-items: flex-start;
        flex-direction: column;
    }

    header form,
    .logout {
        width: 100%;
    }

    .tabs {
        padding-top: 4px;
    }

    .tabs .tab {
        flex: 1 1 220px;
        justify-content: center;
    }

    section {
        padding: 20px;
    }
}

@media (max-width: 640px) {
    .login-body {
        padding: 18px;
    }

    .login {
        padding: 24px;
    }

    main,
    .tabs,
    header {
        padding-left: 16px;
        padding-right: 16px;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    thead {
        display: none;
    }

    tbody tr {
        margin-bottom: 12px;
        padding: 14px;
        border: 1px solid rgba(84, 59, 34, 0.08);
        border-radius: var(--radius-lg);
        background: rgba(255, 255, 255, 0.68);
    }

    tbody td {
        padding: 8px 0;
        border-bottom: 0;
    }

    tbody td:last-child {
        padding-top: 14px;
    }

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

    button,
    #submit-btn,
    #apk-submit-btn,
    .linphone-form button {
        width: 100%;
    }
}
