:root {
    /* Android Material 3 Palette */
    --primary-blue: #007AFF;
    --primary-blue-dark: #005BB5;
    --background-color: #F7F9FC;
    --card-background: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --success: #4CAF50;
    --danger: #E53935;
    --warning: #FF9800;
    --info-bg: #E0F7FA;
    --divider: #E5E7EB;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--background-color);
    color: var(--text-primary);
    font-family: 'Vazirmatn', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    height: 100vh;
}

/* Page Transitions */
.activity {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh;
    background-color: var(--background-color);
}

.activity.active {
    display: block;
}

/* Top Bar */
.top-bar {
    position: sticky;
    top: 0;
    height: 64px;
    background-color: var(--card-background);
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.top-bar h1 {
    font-size: 20px;
    font-weight: 600;
    margin-left: 16px;
    flex: 1;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.2s;
}

.icon-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

/* Setup Bar (New Requirement) */
.quick-setup-bar {
    background: white;
    padding: 12px 16px;
    display: flex;
    gap: 12px;
    border-bottom: 1px solid var(--divider);
}

.small-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.small-input-group label {
    font-size: 9px;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.small-input-group input {
    border: 1px solid var(--divider);
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
    width: 100%;
    background: #fdfdfd;
}

.small-input-group input:focus {
    border-color: var(--primary-blue);
    outline: none;
}

/* Content Container */
.content {
    padding: 16px;
    padding-bottom: 40px;
}

/* Cards */
.card {
    background: var(--card-background);
    border-radius: 16px;
    padding: 0;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* Status Card Redesign */
.status-header {
    background-color: var(--primary-blue);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    cursor: pointer;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
}

.back-icon {
    font-size: 16px;
    opacity: 0.9;
}

.ac-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.6;
}

.ac-indicator.on {
    opacity: 1;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.status-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 24px 10px;
    background: #fff;
    text-align: center;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.status-icon-box {
    width: 56px;
    height: 56px;
    background: #f0f0f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-icon-box.active {
    background: #eef7ff;
    color: var(--primary-blue);
}

.status-icon-box.armed {
    background: #eef7ff;
    color: var(--primary-blue);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.1);
}

.status-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
}

.status-label.active,
.status-label.armed {
    color: var(--primary-blue);
}

/* Reporting Card */
.report-card {
    padding: 0;
    cursor: pointer;
}

.report-bar {
    background-color: var(--primary-blue);
    color: white;
    padding: 8px 16px;
    font-size: 11px;
}

.report-body {
    padding: 16px;
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Section Title */
.section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 24px 0 12px 0;
}

/* Square Buttons (Quick Actions) */
.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.square-btn {
    background: var(--primary-blue);
    border-radius: 16px;
    aspect-ratio: 1/1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: var(--shadow-md);
    border: none;
    cursor: pointer;
    transition: transform 0.1s;
    color: white;
}

.square-btn:active {
    transform: scale(0.95);
}

.square-btn i {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.square-btn span {
    font-size: 14px;
    font-weight: 700;
}

/* List Items */
.list-container {
    background: var(--card-background);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.list-item {
    display: flex;
    align-items: center;
    padding: 18px 16px;
    gap: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.list-item:active {
    background: rgba(0, 0, 0, 0.05);
}

.list-item:not(:last-child) {
    border-bottom: 1px solid var(--background-color);
}

.list-item i.main-icon {
    color: var(--primary-blue);
    font-size: 22px;
}

.list-item span {
    font-size: 15px;
    font-weight: 500;
    flex: 1;
}

/* Output Activity Styles */
.output-card {
    padding: 16px;
}

.output-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.btn-group {
    display: flex;
    gap: 8px;
}

.m-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
}

.btn-success {
    background-color: var(--success);
}

.btn-danger {
    background-color: var(--danger);
}

.btn-primary {
    background-color: var(--primary-blue);
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: white;
    width: 100%;
    max-width: 420px;
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: zoomIn 0.2s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.modal-btn-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wide-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 14px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    text-align: center;
}

.wide-btn:active {
    transform: scale(0.98);
}

.wide-btn.secondary {
    background: #f0f2f5;
    color: var(--text-primary);
}

.wide-btn.outline {
    background: transparent;
    border: 1px solid var(--primary-blue);
    color: var(--primary-blue);
}

/* Tables in Content */
.zones-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.zones-table th {
    background: #f0f2f5;
    padding: 10px 4px;
    text-align: center;
    font-weight: 700;
}

.zones-table td {
    padding: 12px 4px;
    text-align: center;
    border-bottom: 1px solid #f0f2f5;
}

.zones-table input[type="radio"] {
    transform: scale(1.2);
}

.p-12 {
    padding: 12px;
}

.p-16 {
    padding: 16px;
}

.p-20 {
    padding: 20px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-16 {
    margin-bottom: 16px;
}

/* Checkbox Item Row */
.check-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    gap: 12px;
    font-size: 15px;
    font-weight: 500;
}

.check-item input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-blue);
}

/* Tables in Modal */
.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 14px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-green {
    background: #4CAF50;
}

.dot-red {
    background: #E53935;
}

.zone-grid {
    display: grid;
    grid-template-columns: 40px 1fr 1fr 1fr;
    gap: 4px;
    margin-top: 16px;
    font-size: 11px;
}

.zone-header {
    font-weight: 800;
    text-align: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--divider);
}

.zone-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.02);
}

/* Overflow Menu */
.overflow-menu {
    display: none;
    position: absolute;
    top: 56px;
    right: 16px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 200px;
    z-index: 200;
    padding: 8px 0;
}

.menu-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    cursor: pointer;
}

.menu-item:active {
    background: rgba(0, 0, 0, 0.05);
}

/* Welcome Screen */
.welcome-activity {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.logo-circle {
    width: 100px;
    height: 100px;
    background: var(--primary-blue);
    border-radius: 50%;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 40px;
}

.welcome-activity h1 {
    margin-bottom: 8px;
}

.welcome-activity p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

.full-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--divider);
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 16px;
}

.full-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.refresh-spin {
    animation: spin 1s linear infinite;
}

.m-btn.active {
    box-shadow: 0 0 12px rgba(108, 99, 255, 0.5);
    border-color: #fff;
    transform: scale(0.96);
}

/* RTL OVERRIDES */
[dir="rtl"] .top-bar h1 {
    margin-left: 0;
    margin-right: 16px;
}

[dir="rtl"] .fa-chevron-right,
[dir="rtl"] .fa-arrow-left,
[dir="rtl"] .back-icon {
    transform: rotate(180deg);
}