@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap');

:root {
    --primary: #7c6cfc;
    --primary-dark: #6657e8;
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --sidebar: #ffffff;
}

body.dark {
    --bg: #111827;
    --card: #1f2937;
    --text: #f9fafb;
    --muted: #9ca3af;
    --border: #374151;
    --sidebar: #182132;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

body {
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.dashboard-layout {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: 260px;
    flex: 0 0 260px;
    background: var(--sidebar);
    border-left: 1px solid var(--border);
    padding: 24px 18px;
}

.logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 32px;
}

.nav-link {
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--muted);
    margin-bottom: 8px;
    transition: 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(124, 108, 252, 0.12);
    color: var(--primary);
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 24px;
}

.topbar {
    min-height: 72px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 28px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    color: var(--muted);
    font-size: 14px;
}

.theme-btn,
.menu-toggle {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 14px;
    background: rgba(124, 108, 252, 0.14);
    color: var(--primary);
    cursor: pointer;
    font-size: 18px;
    flex: 0 0 42px;
}

.menu-toggle {
    display: none;
    font-size: 22px;
}

.sidebar-overlay {
    display: none;
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-top: 28px;
}

.cards .card {
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 22px;
    max-width: 100%;
    overflow: hidden;
}

.card-title {
    color: var(--muted);
    font-size: 14px;
}

.card-value {
    font-size: 28px;
    font-weight: 800;
    margin-top: 12px;
    text-align: center;
}

.logout {
    color: #ef4444;
}

.form {
    max-width: 520px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0 14px;
    background: var(--bg);
    color: var(--text);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--primary);
    color: #fff;
    padding: 12px 22px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.alert {
    padding: 12px 16px;
    border-radius: 14px;
    margin-bottom: 18px;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 14px 10px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    vertical-align: top;
    white-space: normal;
    word-break: break-word;
    font-size: 13px;
}

.data-table th {
    color: var(--muted);
    font-weight: 700;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.badge.success {
    background: #dcfce7;
    color: #166534;
}

.badge.danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.link-primary {
    color: var(--primary);
    font-weight: 700;
}

.btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 7px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    margin: 2px;
    font-size: 13px;
    white-space: nowrap;
}

.btn-small.success {
    background: #dcfce7;
    color: #166534;
}

.btn-small.danger {
    background: #fee2e2;
    color: #991b1b;
}

.license-copy-box {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    direction: ltr;
    max-width: 100%;
    flex-wrap: wrap;
}

.license-code {
    max-width: 180px;
    white-space: normal;
    word-break: break-all;
    direction: ltr;
    text-align: left;
    display: inline-block;
    font-size: 12px;
    line-height: 1.7;
}

.copy-btn {
    border: none;
    background: rgba(124, 108, 252, 0.14);
    color: var(--primary);
    padding: 6px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
    font-size: 12px;
}

.copy-btn:hover {
    background: var(--primary);
    color: #fff;
}

.device-summary {
    display: grid;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
}

.device-summary span {
    white-space: normal;
}

.sections-list {
    display: grid;
    gap: 10px;
}

.section-item {
    display: flex;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    align-items: center;
    gap: 8px;
}

.section-item input {
    width: auto;
    height: auto;
}

.section-item small {
    color: var(--muted);
    font-size: 12px;
    margin-right: auto;
}

/* Desktop table column tuning */
.data-table th:nth-child(1),
.data-table td:nth-child(1) { width: 9%; }

.data-table th:nth-child(2),
.data-table td:nth-child(2) { width: 9%; }

.data-table th:nth-child(3),
.data-table td:nth-child(3) { width: 10%; }

.data-table th:nth-child(4),
.data-table td:nth-child(4) { width: 7%; }

.data-table th:nth-child(5),
.data-table td:nth-child(5) { width: 9%; }

.data-table th:nth-child(6),
.data-table td:nth-child(6) { width: 9%; }

.data-table th:nth-child(7),
.data-table td:nth-child(7) { width: 18%; }

.data-table th:nth-child(8),
.data-table td:nth-child(8) { width: 10%; }

.data-table th:nth-child(9),
.data-table td:nth-child(9) { width: 8%; }

.data-table th:nth-child(10),
.data-table td:nth-child(10) { width: 6%; }

.data-table th:nth-child(11),
.data-table td:nth-child(11) { width: 5%; }

/* Login */
.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(124, 108, 252, 0.28), transparent 35%),
        radial-gradient(circle at bottom left, rgba(124, 108, 252, 0.14), transparent 35%),
        var(--bg);
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 440px 1fr;
    gap: 28px;
    padding: 28px;
}

.login-card,
.login-visual {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--border);
    border-radius: 32px;
    padding: 34px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(18px);
}

body.dark .login-card,
body.dark .login-visual {
    background: rgba(31, 41, 55, 0.82);
}

.login-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 30px;
}

.login-logo {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 900;
    box-shadow: 0 14px 30px rgba(124, 108, 252, 0.35);
}

.login-brand h1 {
    margin: 0;
    font-size: 24px;
    color: var(--text);
}

.login-brand p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 18px;
}

.login-form input {
    background: var(--bg);
}

.login-btn {
    width: 100%;
    height: 50px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 14px 30px rgba(124, 108, 252, 0.3);
}

.login-btn:hover {
    transform: translateY(-1px);
}

.login-visual {
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-visual::before {
    content: "";
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: rgba(124, 108, 252, 0.18);
    left: -80px;
    top: -80px;
}

.visual-badge {
    width: fit-content;
    background: rgba(124, 108, 252, 0.14);
    color: var(--primary);
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 800;
    margin-bottom: 20px;
}

.login-visual h2 {
    max-width: 560px;
    font-size: 38px;
    line-height: 1.5;
    margin: 0 0 16px;
    color: var(--text);
    position: relative;
    z-index: 1;
}

.login-visual p {
    max-width: 560px;
    color: var(--muted);
    font-size: 16px;
    line-height: 2;
    position: relative;
    z-index: 1;
}

.visual-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: 30px;
    position: relative;
    z-index: 1;
}

.visual-stats div {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 18px;
}

.visual-stats strong {
    display: block;
    color: var(--primary);
    font-size: 22px;
    margin-bottom: 8px;
}

.visual-stats span {
    color: var(--muted);
    font-size: 13px;
}

/* Login responsive */
@media (max-width: 900px) {
    .login-page {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .login-visual {
        display: none;
    }

    .login-card {
        min-height: calc(100vh - 32px);
        border-radius: 24px;
        padding: 24px;
    }

    .login-text {
        flex-grow: 1;
        display: flex;
        align-items: center;
        flex-direction: column;
    }
}

/* Tablet and mobile layout */
@media (max-width: 900px) {
    .dashboard-layout {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: -280px;
        width: 260px;
        height: 100vh;
        z-index: 1000;
        transition: 0.25s ease;
        border-left: 1px solid var(--border);
        background: var(--sidebar);
        overflow-y: auto;
    }

    .sidebar.open {
        right: 0;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        width: 100%;
        padding: 18px;
    }

    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topbar {
        min-height: 76px;
        border-radius: 22px;
        padding: 14px 16px;
        margin-bottom: 24px;
    }

    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
        margin-top: 26px;
    }

    .cards .card {
        min-height: 128px;
        padding: 18px 14px;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary {
        width: 100%;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 1100px;
        width: 1100px;
    }

    .license-code {
        max-width: 250px;
    }
}

/* Small mobile */
@media (max-width: 430px) {
    .main-content {
        padding: 14px;
    }

    .topbar {
        min-height: 72px;
        border-radius: 20px;
        padding: 12px;
    }

    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .theme-btn,
    .menu-toggle {
        width: 48px;
        height: 48px;
        border-radius: 16px;
        font-size: 22px;
    }

    .menu-toggle {
        order: 3;
    }

    .topbar strong {
        font-size: 11px;
    }

    .user-info {
        font-size: 10px;
    }

    .card {
        border-radius: 22px;
        margin-bottom:10px;
    }

    .cards {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-top: 26px;
    }

    .cards .card {
        min-height: 112px;
        padding: 18px 12px;
    }

    .card-title {
        font-size: 13px;
        text-align: center;
    }

    .card-value {
        font-size: 24px;
        margin-top: 10px;
    }

    .btn-primary {
        min-height: 54px;
        border-radius: 16px;
        font-size: 16px;
    }

    .btn-small {
        width: 100%;
        margin-top: 8px;
    }

    .form-group {
        max-width: 100% !important;
    }
}
@media (max-width: 430px) {

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
        flex-direction: row-reverse;
}
    .menu-toggle {
        order: 1;
       
        margin-left: 0;
    }

}