* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    transition: all 0.3s;
}

body.dark-theme {
    background: #1a1a1a;
    color: #e0e0e0;
}

body.dark-theme .modal-content,
body.dark-theme .card,
body.dark-theme .form-card {
    background: #2a2a2a;
    color: #e0e0e0;
}

body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea {
    background: #333;
    color: #e0e0e0;
    border-color: #444;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-container h1 {
    text-align: center;
    color: #06d6a0;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #06d6a0;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: #06d6a0;
    color: white;
}

.btn-primary:hover {
    background: #05b386;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-block {
    width: 100%;
}

.btn-filter {
    background: #e9ecef;
    color: #495057;
    margin-right: 10px;
    margin-bottom: 10px;
}

.btn-filter.active {
    background: #06d6a0;
    color: white;
}

.message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    display: none;
}

.message.success {
    display: block;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.header {
    background: white;
    padding: 20px 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

body.dark-theme .header {
    background: #2a2a2a;
}

body.dark-theme .user-badge {
    background: #3a3a3a;
    color: #e0e0e0;
}

body.dark-theme .tab-btn {
    color: #b0b0b0;
}

body.dark-theme .tab-btn.active {
    color: #06d6a0;
}

body.dark-theme .settings-menu-item {
    color: #c0c0c0;
}

body.dark-theme .feat-toggle {
    background: #2a2a2a;
    border-color: #444;
}

body.dark-theme .feat-toggle-label {
    color: #e0e0e0;
}

body.dark-theme .notification-item {
    background: #2a2a2a;
    border-color: #444;
}

.header-left h2 {
    color: #06d6a0;
    margin: 0;
}

.header-right {
    display: flex;
    gap: 15px;
    align-items: center;
}

.user-badge {
    background: #e9ecef;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

.panel {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 30px;
}

.tabs-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 15px;
    color: #666;
    transition: all 0.3s;
    font-weight: 500;
}

.tab-btn:hover {
    color: #06d6a0;
}

.tab-btn.active {
    color: #06d6a0;
    border-bottom-color: #06d6a0;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 15px;
    transition: transform 0.3s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.form-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-width: 600px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-danger { background: #f8d7da; color: #721c24; }

.stat-card {
    background: linear-gradient(135deg, #06d6a0 0%, #04b386 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.stat-card h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    opacity: 0.9;
}

.stat-card .value {
    font-size: 36px;
    font-weight: bold;
    margin: 0;
}

.low-stock {
    background: #fee;
    border-left: 4px solid #f44;
    padding: 15px;
    margin: 10px 0;
    border-radius: 4px;
}

.chat-container {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    height: 400px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.chat-message {
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 8px;
    max-width: 70%;
    word-wrap: break-word;
}

.chat-message.sent {
    background: #06d6a0;
    color: white;
    margin-left: auto;
}

.chat-message.received {
    background: #f0f0f0;
}

.chat-message .sender {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 5px;
}

.chat-message .time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
}

.chat-input {
    display: flex;
    gap: 10px;
    padding: 15px;
    border-top: 1px solid #e0e0e0;
}

.chat-input input {
    flex: 1;
}

.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.file-item {
    background: #f5f5f5;
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.file-item a {
    color: #06d6a0;
    text-decoration: none;
}

.file-item a:hover {
    text-decoration: underline;
}

.rating-stars {
    display: flex;
    gap: 5px;
    font-size: 28px;
}

.star {
    cursor: pointer;
    color: #ddd;
    transition: color 0.2s;
}

.star:hover,
.star.active {
    color: #ffc107;
}

.filter-buttons {
    margin-bottom: 20px;
}

.material-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: end;
}

.material-row select,
.material-row input {
    flex: 1;
}

.material-row button {
    padding: 10px 15px;
}

@media (max-width: 768px) {
    .panel {
        padding: 0 15px;
    }
    
    .tabs-container {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .tab-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .tab-header button {
        width: 100%;
    }
}

/* Settings page */
.settings-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    transition: background 0.15s;
}
.settings-menu-item:hover { background: #e2e8f0; }
.settings-menu-item.active { background: #6366f1; color: #fff; font-weight: 600; }
.settings-menu-item.disabled { color: #94a3b8; cursor: not-allowed; }
.settings-menu-item.disabled:hover { background: none; }
.settings-section { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Work type cards */
.work-type-card { display: flex; justify-content: space-between; align-items: center; }

/* Integration development button */
.btn-dev {
    background: #9ca3af;
    color: white;
    cursor: pointer;
    font-size: 13px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    transition: all 0.2s;
}
.btn-dev:hover {
    background: #6b7280;
    transform: none;
}

/* Archive search styling */
.archive-search-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    border: 1px solid #e2e8f0;
}
.archive-search-bar input {
    flex: 1;
    min-width: 180px;
    padding: 10px 14px 10px 38px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") 10px center no-repeat;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: #1e293b;
}
.archive-search-bar input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
    background-color: white;
}
.archive-search-bar select {
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #f8fafc;
    cursor: pointer;
    color: #1e293b;
    transition: border-color 0.2s;
    min-width: 160px;
}
.archive-search-bar select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
body.dark-theme .archive-search-bar {
    background: #2a2a2a;
    border-color: #444;
}
body.dark-theme .archive-search-bar input,
body.dark-theme .archive-search-bar select {
    background: #333;
    border-color: #555;
    color: #e0e0e0;
}

/* Draggable tabs */
.tab-btn[draggable="true"] {
    cursor: grab;
}
.tab-btn.drag-over {
    border-bottom-color: #6366f1;
    background: #eef2ff;
}

/* Work type badge in order card */
.work-type-tag {
    display: inline-block;
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 6px;
}

/* Dark theme: autocomplete and file upload */
body.dark-theme .autocomplete-input,
body.dark-theme .autocomplete-dropdown {
    background: #2a2a2a;
    border-color: #555;
    color: #e0e0e0;
}
body.dark-theme .autocomplete-item:hover,
body.dark-theme .autocomplete-item.selected {
    background: #3a3a5a;
    color: #818cf8;
}
body.dark-theme .file-upload-area {
    background: #2a2a2a;
    border-color: #555;
}
body.dark-theme .file-upload-area:hover {
    background: #33334a;
    border-color: #818cf8;
}
body.dark-theme .file-chip {
    background: #33334a;
    border-color: #555;
    color: #818cf8;
}
/* Tabs drag hint */
.tabs-container::before {
    content: 'Перетащите вкладки для изменения порядка';
    display: none;
    font-size: 10px;
    color: #94a3b8;
    padding: 2px 8px;
}

/* ============ MOBILE ADAPTIVE ============ */
@media (max-width: 768px) {
    /* Header */
    .header { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
    .header-left h2 { font-size: 16px; }
    .header-right { gap: 4px; flex-wrap: wrap; }
    .header-right .btn { font-size: 11px; padding: 5px 8px; }
    #btn-bug-report, #btn-feedback { display: none; }

    /* Tabs - horizontally scrollable */
    .tabs-container { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; display: flex; padding-bottom: 4px; }
    .tab-btn { flex-shrink: 0; font-size: 12px; padding: 8px 10px; }

    /* Tab content */
    .tab-content { padding: 12px 8px; }
    .tab-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .tab-header h3 { font-size: 16px; }

    /* Cards */
    .card { padding: 12px; }

    /* Settings sidebar -> top menu */
    #tab-settings > div { grid-template-columns: 1fr !important; min-height: auto !important; }
    #tab-settings > div > div:first-child { flex-direction: row; overflow-x: auto; gap: 4px; padding: 10px; }
    .settings-menu-item { font-size: 11px; padding: 6px 10px; white-space: nowrap; }

    /* Forms */
    .form-group input, .form-group select, .form-group textarea { font-size: 16px; }

    /* Modal */
    .modal-content { width: 96vw !important; max-width: 96vw !important; margin: 8px; padding: 14px; max-height: 92vh; overflow-y: auto; }
    .modal-header h3 { font-size: 15px; }

    /* Teeth grid on mobile */
    .teeth-grid { overflow-x: auto; }
    .teeth-row { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tooth-btn { width: 28px; height: 28px; font-size: 9px; }

    /* Admin feat grid */
    .admin-feat-grid { grid-template-columns: 1fr !important; }

    /* Order modal form grids */
    #modal-create-order .modal-content > div[style*="grid-template-columns:1fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Photo grid */
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }

    /* Chart bars */
    .chart-bar-wrap { height: 60px; }

    /* Stats cards */
    #statistics-content { display: flex; flex-direction: column; gap: 10px; }
    
    /* Patients list cards */
    .card { word-break: break-word; }
    
    /* Filter buttons */
    .filter-buttons { overflow-x: auto; display: flex; white-space: nowrap; }
    .btn-filter { flex-shrink: 0; }

    /* Login */
    .login-container { padding: 24px 16px; margin: 8px; }
    
    /* Toast */
    #toast-container { top: 10px; right: 10px; left: 10px; }
    .toast { min-width: auto; }
    
    /* Vita shade selector */
    #vita-shade-container button { width: 36px; height: 28px; font-size: 9px; }
}

@media (max-width: 480px) {
    .header-right .user-badge { display: none; }
    .tab-btn { font-size: 11px; padding: 7px 8px; }
    .btn { padding: 7px 12px; font-size: 12px; }
    .tooth-btn { width: 24px; height: 24px; font-size: 8px; }
}

/* ============ FEATURE TOGGLE - ADMIN CONTROLLED ============ */
.feat-toggle.admin-locked {
    opacity: 0.55;
    position: relative;
    background: #f1f5f9;
}
.feat-toggle.admin-locked .toggle-switch { pointer-events: none; }
.feat-toggle.admin-enabled { border-color: #6366f1; }
.feat-toggle.admin-disabled { border-color: #ef4444; background: #fff5f5; }

.admin-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    margin-top: 4px;
}
.admin-badge.enabled { background: #d1fae5; color: #065f46; }
.admin-badge.disabled { background: #fee2e2; color: #991b1b; }

/* ============ ONLINE INDICATOR ============ */
#online-indicator { 
    font-size: 14px; 
    margin-right: 4px; 
    cursor: default;
    animation: pulse-indicator 2s infinite;
}
@keyframes pulse-indicator {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============ VITA SHADE ============ */
#vita-shade-container button:hover { transform: scale(1.1); }
#vita-shade-container button { transition: transform .1s, box-shadow .1s; }

/* ============ XRAY TAB ============ */
.xray-item { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
