:root {
    --bg: #f3efe7;
    --panel: rgba(255, 252, 246, 0.9);
    --panel-strong: #fffaf0;
    --text: #1c1814;
    --muted: #6c6256;
    --line: rgba(97, 77, 48, 0.16);
    --accent: #c6512f;
    --accent-deep: #8d361d;
    --accent-soft: #f7d5c3;
    --success: #2f7d4a;
    --danger: #ad2f2f;
    --shadow: 0 20px 60px rgba(86, 55, 23, 0.12);
    --sidebar-width: 240px;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    color: var(--text);
    background: radial-gradient(circle at top left, rgba(232, 154, 121, 0.28), transparent 32%),
                radial-gradient(circle at top right, rgba(255, 226, 176, 0.45), transparent 28%),
                linear-gradient(180deg, #fbf7f1, var(--bg));
    min-height: 100vh;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--line);
}

.sidebar-header h2 {
    font-size: 18px;
    color: var(--accent-deep);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: var(--accent-soft);
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--line);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
    max-width: calc(100vw - var(--sidebar-width));
}

/* Public Page (No Sidebar) */
.public-page .main-content {
    margin-left: 0;
    max-width: 100vw;
}

/* Hero Section */
.hero {
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent-deep);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1, h2, h3 {
    margin: 0;
}

h1 {
    font-size: clamp(32px, 4vw, 52px);
    line-height: 1.02;
}

.intro {
    margin-top: 14px;
    max-width: 680px;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.7;
}

/* Panel */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    padding: 22px;
}

.panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 20px;
}

/* Forms */
.field {
    margin-bottom: 18px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field-row .field {
    margin-bottom: 18px;
}

@media (max-width: 640px) {
    .field-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

.field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text);
}

.vip-hint {
    margin-left: 6px;
    font-size: 12px;
    font-weight: 400;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 8px;
    border-radius: 12px;
    vertical-align: middle;
}

select option:disabled {
    color: #b8a89a;
    font-style: italic;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    border: 1px solid rgba(100, 77, 42, 0.18);
    border-radius: 8px;
    background: #fffdfa;
    padding: 14px 16px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(198, 81, 47, 0.25);
    border-color: rgba(198, 81, 47, 0.4);
}

textarea {
    resize: vertical;
    min-height: 112px;
    line-height: 1.65;
}

/* Buttons */
.actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

button,
.btn {
    min-width: 124px;
    height: 46px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

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

button:disabled,
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
}

.primary {
    background: var(--accent);
    color: white;
}

.secondary {
    background: var(--accent-soft);
    color: var(--accent-deep);
}

.danger {
    background: var(--danger);
    color: white;
}

.success {
    background: var(--success);
    color: white;
}

/* Hero & Account Widget */
.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.hero-main {
    flex: 1 1 420px;
    min-width: 0;
}

.account-widget {
    flex: 0 0 auto;
    min-width: 220px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.account-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.account-name {
    color: var(--text);
}

.account-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.account-tip {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted, #8a7868);
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}

.badge-vip {
    background: linear-gradient(90deg, #f5c067, #e89a3c);
    color: #4a2e0c;
}

.badge-free {
    background: rgba(100, 77, 42, 0.10);
    color: #6b5b46;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent, #c6512f);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.link-btn:hover {
    opacity: 0.8;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(28, 23, 20, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-backdrop[hidden] {
    display: none !important;
}

.modal {
    background: var(--panel, #fffdfa);
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 16px 20px 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--line);
}

.modal-tab {
    flex: 1;
    padding: 14px;
    background: transparent;
    border: none;
    font-size: 15px;
    color: #8a7868;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.modal-tab.active {
    color: var(--accent, #c6512f);
    border-bottom-color: var(--accent, #c6512f);
    font-weight: 600;
}

.modal-body {
    padding: 18px 20px 20px;
}

.modal-body .field {
    margin-bottom: 14px;
}

.modal-body .actions {
    margin-top: 18px;
}

.hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: #8a7868;
}

.vip-perks {
    margin: 8px 0 16px;
    padding-left: 20px;
    color: #4a3a2a;
    line-height: 1.8;
}

.cs-contact {
    background: rgba(245, 222, 179, 0.25);
    border-left: 3px solid var(--accent, #c6512f);
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.cs-contact-text {
    margin: 4px 0 0;
    word-break: break-all;
}

@media (max-width: 640px) {
    .account-widget {
        width: 100%;
    }
}

/* Logs */
.logs {
    margin: 18px 0 0;
    padding: 16px;
    height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 8px;
    background: #1c1714;
    color: #f5eadf;
    font-family: "Cascadia Code", "Consolas", monospace;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Video Preview */
.video-preview {
    width: 100%;
    aspect-ratio: 9 / 16;
    display: block;
    border-radius: 8px;
    background: #120f0d;
    object-fit: contain;
}

.preview-path {
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
    word-break: break-all;
}

/* Form Messages */
.form-message {
    min-height: 22px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
}

.form-message.error {
    color: var(--danger);
}

.form-message.success {
    color: var(--success);
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 40px;
}

.login-box h1 {
    font-size: 28px;
    margin-bottom: 8px;
    text-align: center;
}

.login-box .subtitle {
    text-align: center;
    color: var(--muted);
    margin-bottom: 32px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

thead {
    background: var(--panel-strong);
}

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

th {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--muted);
}

tbody tr:hover {
    background: rgba(198, 81, 47, 0.05);
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-pending {
    background: #e5e7eb;
    color: #6b7280;
}

.badge-starting {
    background: #dbeafe;
    color: #2563eb;
}

.badge-running {
    background: #fef3c7;
    color: #d97706;
}

.badge-succeeded {
    background: #d1fae5;
    color: #059669;
}

.badge-failed {
    background: #fee2e2;
    color: #dc2626;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 28px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--line);
}

.pagination a:hover {
    background: var(--accent-soft);
}

.pagination .current {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 920px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        max-width: 100vw;
        padding: 20px;
    }

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

    .video-preview {
        aspect-ratio: 9 / 16;
    }
}

/* Public Page Styles */
.public-page {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 40px 0 56px;
}

.public-page .panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 20px;
}

@media (max-width: 920px) {
    .public-page {
        width: min(100vw - 20px, 1180px);
        padding-top: 22px;
    }

    .public-page .panel-grid {
        grid-template-columns: 1fr;
    }
}
