/* مسکن پرستیژ — CRM
   طراحی: مشکی مات + طلایی شامپاینی. موبایل‌فرست، سبک و بدون فونت خارجی
   فلسفه: کمتر بیشتر است — هر پیکسل باید دلیل داشته باشد. */

:root {
    /* --- پایه: مشکی مات --- */
    --bg: #0A0A0B;
    --bg-elevated: #101012;
    --card: #141416;
    --card-hover: #1B1B1E;
    --line: #26262A;
    --line-soft: #1E1E21;

    /* --- متن --- */
    --ink: #F2EFE9;
    --muted: #9A968D;
    --muted-2: #6C6862;

    /* --- طلایی شامپاینی: رنگ تاکید --- */
    --gold: #D4B978;
    --gold-soft: #C9A66B;
    --gold-dim: rgba(212, 185, 120, 0.14);
    --gold-line: rgba(212, 185, 120, 0.35);
    --on-gold: #16130A;

    /* --- وضعیت‌ها (کم‌رنگ، بدون شلوغی رنگی) --- */
    --danger: #E38B7C;
    --danger-bg: rgba(227, 139, 124, 0.12);
    --success: #8FBF9A;
    --success-bg: rgba(143, 191, 154, 0.12);
    --info: #8FB3D9;
    --info-bg: rgba(143, 179, 217, 0.12);
    --warn: var(--gold);
    --warn-bg: var(--gold-dim);

    --primary: var(--gold);
    --primary-dark: var(--gold-soft);
    --primary-light: var(--gold-dim);

    --radius: 16px;
    --radius-sm: 11px;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px -12px rgba(0,0,0,0.5);
    --shadow-pop: 0 12px 32px -8px rgba(0,0,0,0.6);

    --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Tahoma, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    margin: 0;
    direction: rtl;
    font-size: 15px;
    line-height: 1.6;
    letter-spacing: -0.005em;
}

h1, h2, h3 { font-weight: 700; margin: 0 0 16px; color: var(--ink); letter-spacing: -0.01em; }
h1 { font-size: 1.3rem; }
h3 { margin: 28px 0 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; font-size: 0.76rem; text-transform: uppercase; }

a { color: var(--gold); }
::selection { background: var(--gold-dim); color: var(--ink); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }

.logo-mark { display: inline-flex; align-items: center; gap: 9px; }
.logo-mark svg { flex-shrink: 0; color: var(--gold); }
.logo-text { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; color: var(--ink); }

.topbar {
    background: rgba(10,10,11,0.86);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    height: 58px;
    border-bottom: 1px solid var(--line-soft);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar .brand { color: var(--ink); }
.topbar nav { display: none; }
.user-menu { display: flex; gap: 14px; align-items: center; font-size: 0.85rem; }
.user-menu span { display: none; }
.user-menu a { color: var(--muted); text-decoration: none; font-weight: 600; }
.user-menu a:hover { color: var(--gold); }
.bell-link { position: relative; font-size: 1.05rem; color: var(--muted); display: inline-flex; }
.bell-badge { position: absolute; top: -5px; left: -8px; background: var(--gold); color: var(--on-gold); font-size: 0.6rem; font-weight: 800; border-radius: 10px; padding: 1px 5px; min-width: 15px; text-align: center; line-height: 1.4; }

.bottom-nav {
    position: fixed; bottom: 0; right: 0; left: 0;
    background: rgba(16,16,18,0.92);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-top: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 6px 6px max(6px, env(safe-area-inset-bottom));
    z-index: 30;
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--muted-2); text-decoration: none; font-size: 0.65rem; font-weight: 600;
    padding: 6px 12px; border-radius: 12px;
    flex: 1;
    transition: color 0.15s ease;
}
.bottom-nav a.active { color: var(--gold); }
.bottom-nav svg { width: 22px; height: 22px; }
.bottom-nav a.nav-fab { flex: 0 0 auto; margin-top: -26px; }
.bottom-nav a.nav-fab .fab-circle {
    width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(155deg, #E4CC93, var(--gold-soft));
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px -6px rgba(212,185,120,0.55);
    color: var(--on-gold);
}
.bottom-nav a.nav-fab .fab-circle svg { width: 24px; height: 24px; color: var(--on-gold); }
.bottom-nav a.nav-fab span { color: var(--muted); margin-top: 1px; }

.container { max-width: 780px; margin: 0 auto; padding: 20px 16px 96px; }

@media (min-width: 700px) {
    .topbar nav { display: flex; align-items: center; gap: 2px; }
    .topbar nav a { color: var(--muted); text-decoration: none; padding: 8px 13px; border-radius: 9px; font-size: 0.86rem; font-weight: 600; transition: all 0.15s ease; }
    .topbar nav a:hover { background: var(--card); color: var(--ink); }
    .topbar nav a.active { color: var(--gold); background: var(--gold-dim); }
    .user-menu span { display: inline; color: var(--muted); font-weight: 600; }
    .bottom-nav { display: none; }
    .container { padding-bottom: 40px; }
}

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { margin: 0; }

.form-card, .login-box {
    background: var(--card);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
}

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); padding: 20px; }
.login-box { width: 100%; max-width: 360px; padding: 36px 28px; text-align: center; }
.login-box .brand-mark { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-box .brand-mark svg { color: var(--gold); }
.login-box .logo-text { font-size: 1.4rem; color: var(--ink); }
.login-box .brand-tagline { font-size: 0.7rem; color: var(--muted-2); letter-spacing: 0.14em; margin-bottom: 28px; font-weight: 600; }
.login-box h1 { text-align: center; font-size: 0.92rem; color: var(--muted); font-weight: 500; margin-bottom: 22px; }
.login-box form { text-align: right; }

.form-row { display: flex; flex-direction: column; gap: 14px; margin-bottom: 0; }
@media (min-width: 640px) {
    .form-row { flex-direction: row; gap: 16px; }
}
.form-row label, .full-width { flex: 1; display: flex; flex-direction: column; gap: 7px; font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-bottom: 14px; }

input, select, textarea {
    font-family: inherit;
    padding: 13px 15px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--ink);
    background: var(--bg-elevated);
    width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-line); box-shadow: 0 0 0 3px var(--gold-dim); }
select { color-scheme: dark; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

button, .btn-primary, .btn-secondary {
    padding: 13px 22px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.94rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 46px;
    transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
}
button, .btn-primary { background: linear-gradient(155deg, #E4CC93, var(--gold-soft)); color: var(--on-gold); }
button:hover, .btn-primary:hover { opacity: 0.92; }
button:active, .btn-primary:active { transform: scale(0.98); }
.btn-secondary { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); }
.btn-secondary:hover { border-color: var(--gold-line); color: var(--gold); }

.alert { padding: 13px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.86rem; font-weight: 600; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { display: none; }
.data-table tbody { display: flex; flex-direction: column; gap: 10px; }
.data-table tr {
    display: flex; flex-direction: column; gap: 4px;
    background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 15px 16px;
    box-shadow: var(--shadow-card);
}
.data-table td { border: none; padding: 4px 0; font-size: 0.87rem; display: flex; justify-content: space-between; gap: 10px; color: var(--ink); }
.data-table td:first-child { font-weight: 700; font-size: 0.95rem; display: block; }
.data-table td[data-label]::before { content: attr(data-label); font-weight: 600; color: var(--muted-2); font-size: 0.72rem; flex-shrink: 0; }
.data-table td:first-child::before { content: none; }
.data-table tr[data-href] { cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.data-table tr[data-href]:active { background: var(--card-hover); border-color: var(--gold-line); }

.data-table .empty { text-align: center; color: var(--muted); padding: 30px 10px; background: none; border: none; box-shadow: none; }

@media (min-width: 700px) {
    .data-table { background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line-soft); }
    .data-table thead { display: table-header-group; }
    .data-table tbody { display: table-row-group; }
    .data-table tr { display: table-row; border: none; border-radius: 0; padding: 0; border-bottom: 1px solid var(--line-soft); box-shadow: none; }
    .data-table tr:last-child { border-bottom: none; }
    .data-table th, .data-table td { padding: 14px 16px; text-align: right; display: table-cell; }
    .data-table td[data-label]::before { content: none; }
    .data-table th { background: var(--bg-elevated); color: var(--muted); font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
    .data-table td { font-size: 0.88rem; }
    .data-table td:first-child { font-weight: 600; font-size: 0.88rem; }
    .data-table tr[data-href]:hover { background: var(--card-hover); }
}

.badge { display: inline-block; padding: 4px 11px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; background: var(--line-soft); color: var(--muted); }
.badge-new { background: var(--info-bg); color: var(--info); }
.badge-in_progress { background: var(--gold-dim); color: var(--gold); }
.badge-negotiating { background: var(--gold-dim); color: var(--gold); }
.badge-closed_won { background: var(--success-bg); color: var(--success); }
.badge-closed_lost { background: var(--danger-bg); color: var(--danger); }

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 12px; background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; font-size: 0.87rem; box-shadow: var(--shadow-card); }
@media (min-width: 640px) { .detail-grid { grid-template-columns: 1fr 1fr; gap: 12px 26px; } }
.detail-grid strong { color: var(--ink); }
.detail-grid > div { color: var(--muted); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 15px 16px; margin-bottom: 10px; box-shadow: var(--shadow-card); }
.timeline-meta { font-size: 0.74rem; color: var(--muted-2); margin-bottom: 8px; font-weight: 600; }
.timeline-meta a { color: var(--gold); font-weight: 700; }
.timeline-note { font-size: 0.89rem; color: var(--ink); }

.entry-type-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.entry-type-tabs label {
    flex: 1; flex-direction: row; align-items: center; justify-content: center; gap: 6px; display: flex;
    color: var(--muted); font-weight: 600; font-size: 0.85rem; margin-bottom: 0;
    border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 11px; cursor: pointer;
    background: var(--bg-elevated);
    transition: all 0.15s ease;
}
.entry-type-tabs input[type="radio"] { width: auto; accent-color: var(--gold); }
.entry-type-tabs label:has(input:checked) { border-color: var(--gold-line); background: var(--gold-dim); color: var(--gold); }

.recorder-box { margin-bottom: 14px; }
.record-btn, .stop-btn {
    display: inline-flex; align-items: center; gap: 8px; width: 100%;
    background: linear-gradient(155deg, #E4CC93, var(--gold-soft)); color: var(--on-gold); border: none;
    padding: 14px 22px; border-radius: var(--radius-sm); font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
.stop-btn { background: var(--danger); color: #26100c; }
.recording-ui { display: flex; align-items: center; gap: 12px; background: var(--danger-bg); border-radius: var(--radius-sm); padding: 12px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; flex-shrink: 0; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.recorded-preview { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.recorded-preview audio { flex: 1; min-width: 200px; }

.voice-bubble { display:flex; align-items:center; gap:10px; background:var(--gold-dim); border-radius:var(--radius-sm); padding:12px 14px; }
.voice-bubble .play-btn { background: var(--gold); color: var(--on-gold); border-radius:50%; width:34px; height:34px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.voice-wave { flex:1; height:20px; background: repeating-linear-gradient(90deg, var(--gold) 0 3px, transparent 3px 6px); opacity:0.45; border-radius: 4px; }
.voice-duration { font-size:0.78rem; color: var(--gold); font-weight: 700; }

.reassign-form { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }
@media (min-width: 640px) { .reassign-form { flex-direction: row; align-items: flex-end; } }
.reassign-form label { flex: 1; margin-bottom: 0; }
.reassign-form .form-actions { margin: 0; }

.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px 8px; text-align: center; box-shadow: var(--shadow-card); }
.stat-num { font-size: 1.5rem; font-weight: 800; color: var(--gold); }
.stat-label { font-size: 0.68rem; color: var(--muted); margin-top: 4px; font-weight: 600; }
@media (min-width: 640px) {
    .stat-card { padding: 22px; }
    .stat-num { font-size: 2rem; }
    .stat-label { font-size: 0.78rem; }
}

.comment-list { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.comment-item { background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 10px 13px; margin-bottom: 6px; font-size: 0.85rem; }
.comment-item strong { color: var(--gold); }
.comment-item .comment-date { color: var(--muted-2); font-size: 0.72rem; margin-right: 8px; display: block; margin-top: 2px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input[type="text"] { flex: 1; }
.comment-form button { padding: 10px 16px; font-size: 0.85rem; min-height: 40px; }
.comment-form .mic-toggle-btn { flex-shrink: 0; padding: 10px 14px; }

.menu-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.menu-list li a { display: block; background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 16px 18px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.94rem; transition: border-color 0.15s ease; }
.menu-list li a:hover, .menu-list li a:active { border-color: var(--gold-line); color: var(--gold); }

.stat-list { list-style: none; padding: 0; margin: 0 0 20px; }
.stat-list li { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 15px 16px; margin-bottom: 10px; cursor: pointer; box-shadow: var(--shadow-card); }
.stat-list li:active { border-color: var(--gold-line); }
.stat-list-name { font-weight: 700; margin-bottom: 8px; }
.stat-list-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg-elevated); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; font-size: 0.75rem; color: var(--muted); }
.chip b { color: var(--ink); }
.chip-success { background: var(--success-bg); border-color: transparent; color: var(--success); }
.chip-success b { color: var(--success); }
.chip-danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.chip-danger b { color: var(--danger); }
.empty-note { text-align: center; color: var(--muted); padding: 24px; }

details.more-fields { margin-bottom: 16px; }
details.more-fields > summary {
    cursor: pointer; list-style: none; color: var(--gold); font-weight: 700; font-size: 0.85rem;
    padding: 12px 4px; display: flex; align-items: center; gap: 6px;
}
details.more-fields > summary::-webkit-details-marker { display: none; }
details.more-fields > summary::before { content: '+'; font-size: 1.05rem; }
details.more-fields[open] > summary::before { content: '–'; }
details.more-fields .form-row:first-of-type { margin-top: 4px; }
