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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px;
    width: 100%;
    max-width: 750px;
    animation: fadeIn 0.3s ease-in;
    position: relative;
}

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

.app-title {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

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

.get-key-row {
    display: flex;
    gap: 8px;
}

.get-key-row #getFileKeyBtn {
    width: 25%;
    flex-shrink: 0;
}

.text-input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #333;
    transition: all 0.2s;
}

.text-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.welcome-message {
    text-align: center;
    margin-bottom: 30px;
}

.welcome-message h2 {
    font-size: 24px;
    color: #333;
    margin-bottom: 8px;
}

.error-message {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 0;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    display: none;
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

.error-message.show {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

.error-message.success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    box-shadow: 0 4px 12px rgba(56, 239, 125, 0.3);
}

.dashboard-header {
    position: absolute;
    top: 20px;
    right: 20px;
}

.logout-btn {
    width: auto;
    padding: 8px 20px;
    font-size: 14px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.logout-btn:hover {
    box-shadow: 0 6px 16px rgba(245, 87, 108, 0.4);
}

/* Certificate Prompt */
.cert-prompt {
    text-align: center;
    margin-top: 15px;
}

.cert-prompt-message {
    color: #666;
    font-size: 21px;
    margin-bottom: 18px;
    line-height: 1.6;
}

.cert-prompt-message strong {
    display: block;
}

.cert-prompt-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.cert-accept-btn {
    width: auto;
    padding: 12px 30px;
    font-size: 21px;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    box-shadow: 0 2px 8px rgba(56, 239, 125, 0.3);
}

.cert-accept-btn:hover {
    transform: translateY(-2px);
}

.cert-reject-btn {
    width: auto;
    padding: 12px 30px;
    font-size: 21px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
}

.cert-reject-btn:hover {
    transform: translateY(-2px);
}

.cert-prompt-message.accepted {
    color: #2196F3;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: none;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
    transform: none;
    box-shadow: none;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: transparent;
}

.tab-content {
    margin-top: 20px;
}

.tab-pane {
    display: none;
}

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

/* User Select */
.user-select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.user-select:hover {
    border-color: #667eea;
}

.user-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

/* Drop Zone */
.drop-zone {
    border: 3px dashed #e0e0e0;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
    background: #fafafa;
}

.drop-zone:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.drop-zone.dragover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    border-style: solid;
}

.drop-zone-content {
    pointer-events: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: #667eea;
    margin: 0 auto 16px;
}

.drop-zone-text {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.drop-zone-subtext {
    font-size: 14px;
    color: #999;
}

.file-input {
    display: none;
}

.file-info {
    margin-top: 20px;
    padding: 12px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
}

.file-info p {
    font-size: 14px;
    color: #667eea;
    font-weight: 600;
}

.upload-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
}

/* Files List */
.files-list {
    min-height: 200px;
}

.empty-state {
    color: #999;
    font-size: 16px;
    text-align: center;
    padding: 60px 20px;
}

.file-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-item {
    padding: 16px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
}

.file-item:hover {
    background: #f5f5f5;
    border-color: #667eea;
}

.file-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 20px;
}

.file-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.file-details {
    flex: 1;
}

.file-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.file-meta {
    font-size: 14px;
    color: #666;
    display: flex;
    align-items: center;
}

.file-meta + .tk-uuid {
    margin-top: 12px;
}

.file-meta span {
    display: inline-block;
}

.file-meta span:not(:first-child) {
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid #d0d0d0;
}

/* Key Manager */
.tk-display-group {
    margin-top: 20px;
}

.tk-display-container {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.tk-display {
    flex: 1;
    padding: 12px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    color: #333;
}

.tk-display:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tk-buttons {
    display: flex;
    gap: 8px;
}

.tk-action-btn {
    width: auto;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.tk-action-btn.delete-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

.tk-action-btn.delete-btn:hover {
    box-shadow: 0 6px 16px rgba(245, 87, 108, 0.4);
}

.primary-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
}

/* Key List */
.tk-list {
    margin-top: 20px;
}

.tk-item {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.tk-item:hover {
    background: #f5f5f5;
    border-color: #667eea;
}

/* Notification items have different color scheme */
.notification-item {
    background: #e8f5e9;
    border: 1px solid #81c784;
}

.notification-item:hover {
    background: #c8e6c9;
    border-color: #66bb6a;
}

.notification-item .tk-sender {
    color: #2e7d32;
}

.notification-item .tk-item-display {
    border-color: #81c784;
    background: #f1f8f2;
}

.tk-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

.tk-sender {
    font-weight: 600;
    color: #667eea;
}

.tk-timestamp {
    color: #999;
}

.tk-uuid {
    font-size: 12px;
    color: #333;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    margin-bottom: 2px;
}

.tk-uuid-label {
    color: #667eea;
    font-weight: 600;
}

.file-key-secret.unavailable {
    color: #999;
    font-style: italic;
    font-weight: normal;
}

.tk-item-content {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tk-item-display {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #333;
}

/* File key display: normal state is a left-aligned block (like a plain
   text field) so a real UUID/key stays easy to read; the empty/error
   placeholder states switch to a flex box so their message can be
   centered both horizontally and vertically, which plain text-align
   alone can't do. */
#fileKeyValue {
    white-space: pre-line;
    word-break: break-all;
    min-height: 52px;
}

#fileKeyValue.empty,
#fileKeyValue.key-error {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
}

#fileKeyValue.empty {
    font-style: italic;
    color: #667eea;
    background: #f4f5ff;
    border-color: #c7cdfa;
}

#fileKeyValue.key-error {
    color: #e53e3e;
    background: #fdecea;
    border-color: #f5b0ab;
}

.tk-item-copy-btn,
.tk-item-delete-btn {
    width: auto;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.tk-item-delete-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

.tk-item-delete-btn:hover {
    box-shadow: 0 6px 16px rgba(245, 87, 108, 0.4);
}

/* Key Item Copy Success Dialog */
.tk-item-copy-success {
    margin-top: 12px;
    padding: 12px;
    background: #d4edda;
    border: 2px solid #28a745;
    border-radius: 8px;
    display: none;
    animation: slideDown 0.2s ease-out;
}

.tk-item-copy-success.show {
    display: block;
}

.tk-item-copy-success-text {
    font-size: 14px;
    color: #155724;
    font-weight: 600;
    text-align: center;
}

/* Key Item Delete Success Dialog */
.tk-item-delete-success {
    margin-top: 12px;
    padding: 12px;
    background: #d4edda;
    border: 2px solid #28a745;
    border-radius: 8px;
    display: none;
    animation: slideDown 0.2s ease-out;
}

.tk-item-delete-success.show {
    display: block;
}

.tk-item-delete-success-text {
    font-size: 14px;
    color: #155724;
    font-weight: 600;
    text-align: center;
}

/* File Item Error Message (download/decrypt errors, shown below that
   specific file rather than in the shared dashboard banner) */
.file-item-error-message {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-radius: 8px;
    display: none;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    animation: slideDown 0.2s ease-out;
}

.file-item-error-message.show {
    display: block;
}

/* 'pending' variant: same look as the delete-success dialog above, for
   transient non-error states like "key not received yet". */
.file-item-error-message.pending {
    background: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
}

/* Key Item Confirmation Dialog */
.tk-item-confirm-dialog {
    margin-top: 12px;
    padding: 12px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    display: none;
    animation: slideDown 0.2s ease-out;
}

.tk-item-confirm-dialog.show {
    display: block;
}

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

.tk-item-confirm-text {
    font-size: 14px;
    color: #856404;
    font-weight: 600;
    margin-bottom: 12px;
}

.tk-item-confirm-buttons {
    display: flex;
    gap: 8px;
}

.tk-item-confirm-yes,
.tk-item-confirm-no,
.file-item-download-cancel-btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tk-item-confirm-yes {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

.tk-item-confirm-yes:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 87, 108, 0.4);
}

.tk-item-confirm-no {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tk-item-confirm-no:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.file-item-download-cancel-btn {
    background: #e0e0e0;
    color: #333;
}

.file-item-download-cancel-btn:hover {
    background: #d0d0d0;
}

/* Settings Gear */
.settings-corner {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 20;
}

.settings-btn {
    width: auto;
    padding: 6px 10px;
    font-size: 18px;
    background: transparent;
    color: #999;
    box-shadow: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.2s;
}

.settings-btn:hover {
    color: #667eea;
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
    transform: none;
    box-shadow: none;
}

/* Settings Panel */
.settings-panel {
    display: none;
    position: absolute;
    top: 56px;
    left: 20px;
    width: 280px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 16px;
    z-index: 20;
    animation: slideDown 0.2s ease-out;
}

.settings-panel.open {
    display: block;
}

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

.settings-title {
    font-size: 15px;
    font-weight: 700;
    color: #333;
}

.settings-close-btn {
    width: auto;
    padding: 2px 7px;
    font-size: 14px;
    background: transparent;
    color: #999;
    box-shadow: none;
    border: none;
    border-radius: 4px;
}

.settings-close-btn:hover {
    color: #333;
    background: #f0f0f0;
    transform: none;
    box-shadow: none;
}

.settings-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    color: #333;
    background: white;
    transition: border-color 0.2s;
}

.settings-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.settings-input.invalid {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.settings-field-error {
    font-size: 11px;
    color: #e53e3e;
    margin-top: 4px;
    display: none;
}

.settings-field-error.show {
    display: block;
}

.ws-current-label {
    font-size: 12px;
    color: #999;
    margin-bottom: 14px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

.ws-current-label.overridden {
    color: #764ba2;
    font-weight: 600;
}

.settings-actions {
    display: flex;
    gap: 8px;
}

.settings-save-btn {
    flex: 1;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    box-shadow: 0 2px 8px rgba(56, 239, 125, 0.3);
}

.settings-save-btn:hover {
    box-shadow: 0 4px 12px rgba(56, 239, 125, 0.4);
}

.settings-reset-btn {
    flex: 1;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
}

.settings-reset-btn:hover {
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
}

/* WebSocket Error Notification - Appears just above Secure App title */
.websocket-error-notification {
    display: none;
    margin-bottom: 20px;
}

.websocket-error-notification.show {
    display: flex;
    justify-content: center;
    animation: slideDown 0.3s ease-in-out;
}

.websocket-error-content {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.5);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    display: inline-block;
    width: auto;
}

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

/* Upload Success Modal — a real dialog the user must dismiss, rather than
   a passive banner, so a successful upload is unmistakable. */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.2s ease-in;
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.modal-title.error {
    color: #e53e3e;
}

.modal-message {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
    word-break: break-word;
}