:root {
    --bg-body: #f3f9ff;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --primary: #005fb8; 
    --primary-hover: #004d96;
    --text-main: #202020;
    --text-muted: #605e5c;
    --sidebar-width: 280px;
    --header-height: 70px;
    --radius: 12px;
    --shadow: 0 4px 25px rgba(0, 0, 0, 0.04);
    --font-family: 'Vazirmatn', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; -webkit-tap-highlight-color: transparent; }
button, input, optgroup, select, textarea { font-family: var(--font-family); }
body { font-family: var(--font-family); background-color: var(--bg-body); color: var(--text-main); height: 100vh; overflow: hidden; background-image: radial-gradient(circle at 10% 10%, rgba(0, 95, 184, 0.03) 0%, transparent 50%), radial-gradient(circle at 90% 90%, rgba(0, 183, 195, 0.03) 0%, transparent 50%); }
a { text-decoration: none; color: inherit; }

/* Layout & Sidebar */
.app-container { display: flex; height: 100vh; width: 100vw; position: relative; }
.sidebar { width: var(--sidebar-width); background: var(--glass-bg); border-left: 1px solid rgba(0,0,0,0.05); display: flex; flex-direction: column; z-index: 100; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); height: 100%; }
.brand { height: var(--header-height); display: flex; align-items: center; padding: 0 25px; gap: 12px; font-weight: 900; font-size: 1.3rem; color: var(--primary); border-bottom: 1px solid rgba(0,0,0,0.04); }
.menu-container { flex: 1; overflow-y: auto; padding: 20px 15px; }
.menu-item { margin-bottom: 5px; }
.menu-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-radius: var(--radius); cursor: pointer; color: var(--text-main); font-weight: 500; transition: background 0.2s; }
.menu-header:hover { background-color: rgba(0, 0, 0, 0.03); }
.menu-header.active { background-color: var(--primary); color: white !important; }
.menu-header.active i { color: white !important; }
.menu-header span { display: flex; align-items: center; gap: 12px; }
.menu-header i { font-size: 1.25rem; color: var(--text-muted); transition: 0.3s; }
.submenu { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; padding-right: 24px; margin-right: 18px; border-right: 2px solid #f0f0f0; }
.submenu.open { max-height: 500px; }
.submenu a { display: block; padding: 10px 12px; font-size: 0.9rem; color: var(--text-muted); border-radius: var(--radius); margin-top: 4px; transition: 0.2s; }
.submenu a:hover { background-color: #f5f8fc; color: var(--primary); transform: translateX(-5px); }

/* Main Content & Header */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; background: var(--bg-body); }
header { height: var(--header-height); padding: 0 30px; display: flex; align-items: center; justify-content: space-between; background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(0,0,0,0.04); z-index: 50; }
.header-left { display: flex; align-items: center; gap: 15px; }
.header-right { display: flex; align-items: center; flex: 1; }
.mobile-menu-btn { display: none; font-size: 1.5rem; color: var(--text-main); cursor: pointer; padding: 5px; margin-left: 15px; }
.search-bar { display: flex; align-items: center; background: white; padding: 0 15px; border-radius: 50px; border: 1px solid #e1e5ea; width: 100%; max-width: 380px; height: 44px; transition: 0.3s; }
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0, 95, 184, 0.08); }
.search-bar input { border: none; flex: 1; height: 100%; margin-right: 10px; background: transparent; font-size: 0.95rem; }
.user-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn { position: relative; width: 42px; height: 42px; background: white; border: 1px solid #eee; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; color: var(--text-muted); transition: all 0.2s ease; text-decoration: none !important; }
.icon-btn:hover { background: white; border-color: var(--primary); color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.05); }
.notification-dot { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; background-color: #d13438; border: 2px solid white; border-radius: 50%; box-sizing: content-box; }
.user-profile-area { display: flex; align-items: center; gap: 12px; margin-right: 20px; cursor: pointer; padding: 5px 10px; border-radius: 50px; transition: 0.2s; }
.user-profile-area:hover { background: rgba(255,255,255,0.6); }
.user-info-text { text-align: left; }
.user-name { font-size: 0.9rem; font-weight: 700; color: var(--text-main); }
.user-role { font-size: 0.75rem; color: var(--text-muted); }
.user-avatar-small, .user-initials { width: 40px; height: 40px; border-radius: 50%; border: 2px solid white; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.user-avatar-small { object-fit: cover; }
.user-initials { background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; }

/* Content & Cards */
.content-area { flex: 1; padding: 30px; overflow-y: auto; overflow-x: hidden; }
.page-title { font-size: 1.5rem; margin-bottom: 25px; font-weight: 800; color: var(--text-main); display: flex; align-items: center; gap: 10px; }
.card { background: white; border-radius: 16px; padding: 30px; box-shadow: var(--shadow); border: 1px solid rgba(0,0,0,0.02); margin-bottom: 24px; transition: transform 0.2s; }
.table-container { background: white; border-radius: 16px; padding: 20px; box-shadow: var(--shadow); border: 1px solid rgba(0,0,0,0.02); overflow-x: auto; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; margin-bottom: 25px; }
.form-group { margin-bottom: 20px; }
.form-label { display: block; margin-bottom: 8px; color: var(--text-main); font-weight: 600; font-size: 0.9rem; }
.auth-input, input[type="text"], input[type="password"], input[type="email"], input[type="number"], select, textarea { width: 100%; padding: 12px 16px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 0.95rem; background-color: #fff; color: var(--text-main); transition: all 0.2s ease; }
.auth-input:focus, input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 95, 184, 0.15); }

/* Buttons */
.btn-primary { background-color: var(--primary); color: white; border: none; padding: 12px 24px; border-radius: 8px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: background 0.2s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none !important; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: white; color: var(--text-main); border: 1px solid #d1d5db; padding: 12px 24px; border-radius: 8px; font-size: 0.95rem; cursor: pointer; transition: 0.2s; text-decoration: none !important; display: inline-flex; align-items: center; }
.btn-secondary:hover { background-color: #f9fafb; border-color: #9ca3af; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
th { text-align: right; padding: 15px; border-bottom: 2px solid #f0f2f5; color: var(--text-muted); font-size: 0.9rem; white-space: nowrap; }
td { padding: 15px; border-bottom: 1px solid #f0f2f5; font-size: 0.95rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background-color: #fafbfc; }

/* --- NEW: Badges & Actions for List Views --- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-customer { background-color: #e0f2f1; color: #00695c; }
.badge-supplier { background-color: #fff3e0; color: #e65100; }
.badge-shareholder { background-color: #f3e5f5; color: #7b1fa2; }
.badge-other { background-color: #f5f5f5; color: #616161; }

.action-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--text-muted); transition: 0.2s; margin: 0 2px; }
.action-btn:hover { background-color: #f0f2f5; }
.action-btn.edit:hover { color: var(--primary); background-color: #e6f2fa; }
.action-btn.delete:hover { color: #d13438; background-color: #fde8e9; }

/* Empty State */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { background: #f8f9fa; width: 80px; height: 80px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 2.5rem; color: #cbd5e1; }

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { position: absolute; right: -100%; top: 0; height: 100vh; width: 280px; box-shadow: -5px 0 25px rgba(0,0,0,0.1); }
    .sidebar.active { transform: translateX(-100%); right: -280px; }
    .mobile-menu-btn { display: block; }
    header { padding: 0 15px; }
    .content-area { padding: 20px 15px; }
}
@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; gap: 15px; }
    .user-info-text { display: none; }
    .user-profile-area { margin-right: 10px; padding: 0; }
    .search-bar { max-width: 100%; width: auto; padding: 0 10px; }
    .search-bar input { display: none; }
    .search-bar:focus-within { position: absolute; left: 15px; right: 60px; z-index: 60; background: white; }
    .search-bar:focus-within input { display: block; }
    .page-title { font-size: 1.25rem; flex-wrap: wrap; }
    .card, .table-container { padding: 20px; }
    /* Ensure table controls wrap */
    .list-header-controls { width: 100%; justify-content: flex-start; margin-top: 10px; }
}


/* Tab System */
.tabs-container {
    margin-top: 20px;
}
.tabs-header {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    font-family: var(--font-family);
    font-size: 0.95rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: 0.3s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 700;
}
.tab-content { display: none; animation: fadeIn 0.3s; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Avatar Uploader in Person Form */
.person-avatar-upload {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 3px solid white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    margin: 0 auto;
    transition: 0.3s;
}
.person-avatar-upload:hover { transform: scale(1.05); border-color: var(--primary); }
.person-avatar-upload img { width: 100%; height: 100%; object-fit: cover; }
.person-avatar-upload i { font-size: 3rem; color: #cbd5e1; }

/* Custom Checkbox Grid */
.checkbox-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}
.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Search Bar in List Header */
.list-search {
    position: relative;
    width: 300px;
}
.list-search input {
    width: 100%;
    padding: 10px 35px 10px 15px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
}
.list-search i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

@media (max-width: 768px) {
    .list-search { width: 100%; order: 2; margin-top: 15px; }
    .tabs-header { padding-bottom: 5px; }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-icon {
    width: 70px;
    height: 70px;
    background: #fee2e2;
    color: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 20px;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--text-main);
}

.modal-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 30px;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-danger:hover { background-color: #dc2626; }