*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-body: #0d1117;
    --bg-card: #161b22;
    --bg-input: #0d1117;
    --bg-hover: #1c2333;
    --border: #30363d;
    --border-focus: #58a6ff;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent: #58a6ff;
    --success: #3fb950;
    --danger: #f85149;
    --warning: #d29922;
    --radius: 10px;
    --radius-sm: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Page Layout ===== */

.page {
    display: flex;
    justify-content: center;
    padding: 40px 16px 60px;
}

.container {
    width: 100%;
    max-width: 560px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
}

.page-desc {
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 28px;
}

/* ===== Card ===== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ===== Notice ===== */

.notice {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--danger);
    margin-bottom: 20px;
    text-align: center;
}

/* ===== Form ===== */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--border-focus);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* ===== Buttons ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    color: #fff;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    background: linear-gradient(135deg, var(--accent), #2f81f7);
    border-radius: var(--radius-sm);
}

.btn-submit:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn-loading {
    position: relative;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
}

.btn-success {
    background: var(--success);
}

.btn-success:hover:not(:disabled) {
    background: #2ea043;
}

.btn-danger {
    background: var(--danger);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--danger);
}

.btn-danger-outline:hover:not(:disabled) {
    border-color: var(--danger);
    background: rgba(248, 81, 73, 0.1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 4px 10px;
}

/* ===== Result ===== */

.result-box {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-ok {
    background: rgba(63, 185, 80, 0.12);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--success);
}

.result-fail {
    background: rgba(248, 81, 73, 0.12);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--danger);
}

.result-box[hidden] {
    display: none;
}

/* ===== Guide Steps ===== */

.steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}

.step strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

.step p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

kbd {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
    font-family: inherit;
}

code {
    background: rgba(88, 166, 255, 0.1);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
    color: var(--accent);
}

/* ===== Admin Page Shared ===== */

.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

.app-header {
    padding: 24px 0 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.app-header h1 {
    font-size: 22px;
    font-weight: 600;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.card-header h2 {
    margin-bottom: 0;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ===== Table (admin) ===== */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

.col-idx {
    width: 40px;
    text-align: center;
}

td.col-idx {
    text-align: center;
    color: var(--text-muted);
}

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 12px !important;
}

.status-ok {
    color: var(--success);
    font-weight: 500;
}

.status-fail {
    color: var(--danger);
    font-weight: 500;
}

/* ===== Toast ===== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    animation: toast-in 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 400px;
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--accent); color: #fff; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== Log Panel (admin) ===== */

.log-panel {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-y: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== Responsive ===== */

@media (max-width: 600px) {
    .page {
        padding: 20px 12px 40px;
    }

    .page-title {
        font-size: 22px;
    }

    .card {
        padding: 18px;
    }
}
