html { overflow-y: scroll; }
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f5f7;
    color: #171717;
}

header {
    height: 64px;
    background: #111;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: .5px;
}

.user {
    font-size: 14px;
    color: #ccc;
}

main {
    max-width: 1250px;
    margin: 0 auto;
    padding: 30px 24px 50px;
}

.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.top h1 {
    margin: 0;
    font-size: 28px;
}

.top p {
    margin: 7px 0 0;
    color: #777;
}

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

.card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 18px rgba(0,0,0,.05);
}

.card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

.card-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 22px rgba(0,0,0,.09);
}

.card-link:active {
    transform: translateY(0);
}

.stat-title {
    color: #777;
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
}

.stat-sub {
    margin-top: 7px;
    color: #888;
    font-size: 13px;
}

.grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
}

.card h2 {
    margin: 0 0 18px;
    font-size: 19px;
}

.server {
    border: 1px solid #eee;
    border-radius: 9px;
    padding: 14px;
    margin-bottom: 10px;
}

.server:last-child {
    margin-bottom: 0;
}

.server-name {
    font-weight: 700;
    margin-bottom: 8px;
}

.server-info {
    color: #666;
    font-size: 13px;
    line-height: 1.7;
}

.status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    background: #eee;
}

.status.active {
    background: #e8f7ed;
    color: #16803c;
}

.status.disabled {
    background: #fdeaea;
    color: #b42318;
}

.log {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

.log:last-child {
    border-bottom: 0;
}

.log-action {
    font-weight: 700;
}

.log-meta {
    color: #888;
    margin-top: 4px;
}

.empty {
    color: #888;
    font-size: 14px;
}

@media (max-width: 900px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 550px) {
    header {
        padding: 0 16px;
    }

    main {
        padding: 20px 14px 40px;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .top h1 {
        font-size: 24px;
    }
}

/* Clients */
table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

th {
    background: #f7f7f7;
    font-size: 13px;
}

td {
    font-size: 14px;
}

.status-active {
    color: #16803c;
}

.status-disabled {
    color: #b42318;
}

.form-box {
    display: block;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0;
    padding: 0 20px;
    background: #f7f7f7;
    border-radius: 10px;
    transition: max-height .35s ease, opacity .25s ease, margin .35s ease, padding .35s ease;
}

.form-box.open {
    max-height: 500px;
    opacity: 1;
    margin: 20px 0;
    padding: 20px;
}

.toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform .2s ease, background .2s ease;
}

.toggle-btn:active {
    transform: scale(.96);
}

.toggle-icon {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
    transition: transform .3s ease;
}

.toggle-btn.open .toggle-icon {
    transform: rotate(45deg);
}

.toggle-btn.open {
    background: #222;
}

.form-box label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 600;
}

.form-box input,
.form-box textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    margin: 0 0 14px;
    border: 1px solid #ccc;
    border-radius: 7px;
    font-family: Arial, sans-serif;
    font-size: 14px;
    background: #fff;
}

.form-box textarea {
    min-height: 100px;
    resize: vertical;
}

.btn-primary,
.btn-secondary {
    padding: 11px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

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

.btn-secondary {
    border: 1px solid #ccc;
    background: #fff;
    color: #111;
}

@media (max-width: 600px) {
    .card {
        padding: 16px;
    }

    h1 {
        font-size: 24px;
    }
}

/* =========================================================
   LOGIN
   ========================================================= */

.login {
    width: 320px;
    padding: 30px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
}

.login h1 {
    margin-top: 0;
    text-align: center;
}

.login input,
.login button {
    box-sizing: border-box;
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    border-radius: 7px;
    border: 1px solid #ccc;
}

.login button {
    cursor: pointer;
    background: #111;
    color: #fff;
}

.login .error {
    margin-top: 12px;
    color: #c00;
    text-align: center;
}

/* =========================================================
   LOGIN PAGE
   ========================================================= */

body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================================
   CLIENTS
   ========================================================= */

.client-link {
    color: #111;
    text-decoration: underline;
    font-weight: 600;
}

/* =========================================================
   BACK NAVIGATION
   ========================================================= */

.back {
    display: inline-block;
    margin-bottom: 20px;
    color: #111;
    text-decoration: none;
}

/* =========================================================
   CLIENT
   ========================================================= */

.client-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 30px;
}

.item {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.label {
    color: #777;
    font-size: 13px;
    margin-bottom: 5px;
}

.value {
    word-break: break-word;
}

.subscription {
    background: #f7f7f7;
    padding: 16px;
    border-radius: 10px;
}

.token {
    font-family: monospace;
    word-break: break-all;
    background: #fff;
    border: 1px solid #ddd;
    padding: 12px;
    border-radius: 7px;
}

.client-server {
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 18px;
    margin-top: 15px;
}

@media (max-width: 700px) {
    .client-grid {
        grid-template-columns: 1fr;
    }
}

.client-grid .item-full {
    grid-column: 1 / -1;
}

.client-section {
    margin-top: 15px;
}

.subscription-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.subscription-open {
    display: inline-block;
    text-decoration: none;
}

.subscription-copy {
    padding: 11px 16px;
}

.client-block {
    margin-top: 20px;
}

.qr-box {
    margin-top: 10px;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    display: inline-block;
}

/* Sources */
.table-wrap {
    overflow-x: auto;
}

.url {
    max-width: 300px;
    word-break: break-all;
    color: #555;
    font-size: 12px;
}

.type {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 6px;
    background: #f0f0f0;
    font-size: 12px;
}

.btn-danger {
    padding: 8px 12px;
    border: 1px solid #e0b4b4;
    border-radius: 7px;
    background: #fff;
    color: #b42318;
    cursor: pointer;
    font-size: 13px;
}

.btn-danger:hover {
    background: #fdeaea;
}

/* Servers */
#addServer.form-box.open {
    max-height: 1000px;
}

/* Subscription open button */
.open-link {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 7px;
    background: #111;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}

.open-link:hover {
    background: #222;
}


/* Save notification */
.save-toast {
    position: fixed;
    top: 155px;
    left: 50%;
    z-index: 9999;
    padding: 12px 18px;
    background: #111;
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,.18);
    opacity: 0;
    transform: translate(-50%, -10px);
    transition: opacity .25s ease, transform .25s ease;
}

.save-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}
