:root {
    --bg: #f7f8fb;
    --surface: #ffffff;
    --border: #e6e8ef;
    --text: #1c2130;
    --muted: #6b7280;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --danger: #dc2626;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(20, 20, 43, 0.06), 0 1px 2px rgba(20, 20, 43, 0.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    line-height: 1.7;
}

input, textarea, select, button {
    font-family: inherit;
    font-size: 15px;
}

h1, h2 { margin: 0 0 8px; }

.muted { color: var(--muted); font-size: 14px; }

/* ---------- ورود ---------- */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    padding: 36px 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-card label { margin-top: 14px; font-size: 14px; font-weight: 500; }

.auth-card input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 6px;
}

.auth-card button { margin-top: 22px; }

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
}

/* ---------- ساختار کلی اپ ---------- */
.app { min-height: 100vh; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    gap: 12px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand { font-weight: 700; font-size: 17px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.tab-btn {
    background: transparent;
    border: none;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--muted);
    font-weight: 500;
}

.tab-btn:hover { background: var(--bg); }
.tab-btn.active { background: var(--primary); color: #fff; }

.user-box { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }

.content {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px 60px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tab-panel { display: none; }
.tab-panel.active { display: flex; flex-direction: column; gap: 20px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

label { display: block; font-size: 14px; font-weight: 500; margin: 14px 0 6px; }
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="url"], input[type="password"], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fdfdff;
    color: var(--text);
}

textarea { resize: vertical; font-family: inherit; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > input, .row > select { flex: 1; min-width: 140px; }
.col { flex: 1; min-width: 140px; }

.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkbox-label input { width: auto; }

.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s ease;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; margin-top: 18px; }
.btn-ghost { background: var(--bg); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-danger { background: #fee2e2; color: var(--danger); }

.status-text { margin-top: 10px; font-size: 14px; color: var(--muted); }
.status-text.error { color: var(--danger); }

/* ---------- نوار پیشرفت استخراج ---------- */
.progress-box { margin-top: 16px; }

.progress-steps {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 10px;
}

.progress-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.progress-step .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.progress-step .label { font-size: 12px; color: var(--muted); }

.progress-step.active .dot {
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    animation: pulse-dot 1s ease-in-out infinite;
}
.progress-step.active .label { color: var(--primary); font-weight: 600; }

.progress-step.done .dot { background: var(--primary); }
.progress-step.done .label { color: var(--text); }

.progress-step.error .dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15); }
.progress-step.error .label { color: var(--danger); font-weight: 600; }

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

.progress-bar {
    height: 6px;
    border-radius: 4px;
    background: var(--bg);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.4s ease;
}
.progress-bar-fill.error { background: var(--danger); }

.progress-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

.result-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.result-tab-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
}
.result-tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.result-panel { display: none; position: relative; }
.result-panel.active { display: block; }
.result-panel textarea { width: 100%; }
.copy-btn { margin-top: 10px; }

.history-list, .admins-list { display: flex; flex-direction: column; gap: 10px; }

.history-item, .admin-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

.history-item .meta { font-size: 12px; color: var(--muted); }

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1c2130;
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 100;
}

@media (max-width: 640px) {
    .topbar { flex-direction: column; align-items: stretch; }
    .tabs { justify-content: center; }
    .user-box { justify-content: center; }
    .row { flex-direction: column; align-items: stretch; }
}
