* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #007AFF;
    --primary-hover: #0051D5;
    --secondary-color: #5856D6;
    --background: #F5F5F7;
    --surface: #FFFFFF;
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --border: #D2D2D7;
    --error: #FF3B30;
    --success: #34C759;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 48px 40px;
    box-shadow: var(--shadow-hover);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.logo {
    font-size: 36px;
    font-weight: 600;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 16px;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--surface);
    color: var(--text-primary);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    width: 100%;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #C7C7CC;
}

.btn-logout {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-logout:hover {
    background: var(--background);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
}

.btn-logout::before {
    content: "→";
    font-size: 16px;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #D70015;
}

.error-message {
    color: var(--error);
    font-size: 14px;
    margin-top: 12px;
    display: none;
    white-space: pre-line;
    line-height: 1.6;
    padding: 12px;
    background: rgba(255, 59, 48, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--error);
}

.error-message.show {
    display: block;
}

.success-message {
    color: var(--success);
    font-size: 14px;
    margin-top: 12px;
    display: none;
}

.success-message.show {
    display: block;
}

/* Admin Screen */
.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.admin-header h1 {
    font-size: 32px;
    font-weight: 600;
}

.admin-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.admin-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.admin-section h2 {
    font-size: 24px;
    margin-bottom: 24px;
    font-weight: 600;
}

.form-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.form-card h3 {
    font-size: 20px;
    margin-bottom: 20px;
    font-weight: 600;
}

.clients-list h3 {
    font-size: 20px;
    margin-bottom: 16px;
    font-weight: 600;
}

.list-container {
    max-height: 400px;
    overflow-y: auto;
}

.client-item {
    padding: 16px;
    background: var(--background);
    border-radius: 10px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.client-item strong {
    color: var(--text-primary);
}

.client-item span {
    color: var(--text-secondary);
    font-size: 14px;
}

.settings-compact {
    background: var(--background);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.settings-form-inline {
    margin: 0;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-row label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
}

.settings-form-inline .error-message,
.settings-form-inline .success-message {
    margin-top: 8px;
    font-size: 12px;
    padding: 8px;
}

.settings-form-inline .success-message {
    background: rgba(52, 199, 89, 0.1);
    border-left: 3px solid var(--success);
    border-radius: 6px;
}

/* Client Screen */
.client-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

.client-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.client-header h1 {
    font-size: 32px;
    font-weight: 600;
}

.user-info {
    color: var(--text-secondary);
    font-size: 16px;
}

.user-info span {
    color: var(--primary-color);
    font-weight: 500;
}

.client-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.left-panel,
.right-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.right-panel h2 {
    font-size: 24px;
    margin-bottom: 24px;
    font-weight: 600;
}

.entries-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.entry-card {
    background: var(--background);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.entry-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.entry-subject {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.entry-text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.entry-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.entry-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
    width: auto;
}

.file-upload-area {
    margin-top: 8px;
}

.file-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: var(--background);
}

.file-drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(0, 122, 255, 0.05);
}

.file-drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(0, 122, 255, 0.1);
    transform: scale(1.02);
}

.file-drop-content {
    pointer-events: none;
}

.file-drop-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.file-drop-zone p {
    margin: 8px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.file-browse-link {
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
    pointer-events: auto;
}

.file-drop-hint {
    font-size: 12px;
    opacity: 0.7;
}

.attachments-preview {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-tag {
    background: var(--surface);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    position: relative;
}

.attachment-tag::before {
    content: "📎";
    font-size: 16px;
}

.attachment-remove {
    cursor: pointer;
    margin-left: 8px;
    color: var(--error);
    font-weight: bold;
    font-size: 16px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.attachment-remove:hover {
    opacity: 1;
}

/* Admin Entries */
.entries-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.admin-entry-card {
    background: var(--background);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.admin-entry-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.admin-entry-username {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 8px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--surface);
    border-radius: 20px;
    padding: 32px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-hover);
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    position: absolute;
    right: 24px;
    top: 24px;
    font-size: 32px;
    font-weight: 300;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close:hover {
    color: var(--text-primary);
}

.modal-entry-subject {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-entry-text {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.8;
    white-space: pre-wrap;
}

.modal-entry-meta {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.modal-attachments {
    margin-top: 24px;
}

.modal-attachments h4 {
    font-size: 18px;
    margin-bottom: 16px;
    font-weight: 600;
}

.attachment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 8px;
}

.attachment-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.attachment-link:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 1024px) {
    .admin-content,
    .client-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .admin-header,
    .client-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .client-header {
        flex-direction: column;
    }

    .modal-content {
        padding: 24px;
        width: 95%;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #AEAEB2;
}

