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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    height: 192px;
    margin-right: 1rem;
}

h1 {
    font-size: 2rem;
    font-weight: 300;
}

#auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.welcome-section {
    padding: 4rem 2rem;
    text-align: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: block;
}

.welcome-section h2 {
    font-size: 2rem;
    color: #495057;
    margin-bottom: 1rem;
    font-weight: 300;
}

.welcome-section p {
    font-size: 1.1rem;
    color: #6c757d;
    max-width: 600px;
    margin: 0 auto;
}

#app-content {
    display: none;
}

.login-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s;
}

.login-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.user-info {
    display: none;
    color: white;
    font-size: 0.9rem;
}

#app-content {
    padding: 2rem;
}

.tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 2rem;
}

.tab-button {
    background: none;
    border: none;
    padding: 1rem 2rem;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-button:hover {
    color: #333;
    background: #f8f9fa;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

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

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

.tab-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 200px;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    user-select: none;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.operation-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 0.5rem;
}

.operation-badge.create {
    background-color: #28a745;
    color: white;
}

.operation-badge.update {
    background-color: #007bff;
    color: white;
}

.operation-badge.delete {
    background-color: #dc3545;
    color: white;
}

.operation-badge.restore {
    background-color: #ffc107;
    color: #212529;
}

.users-grid {
    display: grid;
    gap: 1rem;
}

.users-grid .grid-header {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    font-weight: bold;
}

.users-grid .user-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.users-grid .user-row:hover {
    background-color: #f8f9fa;
}

.role-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: capitalize;
}

.role-badge.admin {
    background-color: #dc3545;
    color: white;
}

.role-badge.users {
    background-color: #007bff;
    color: white;
}

.role-badge.readonly {
    background-color: #6c757d;
    color: white;
}

.raw-data {
    padding: 1rem;
}

.raw-data pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
}

.tab-header h2 {
    color: #333;
    font-size: 1.5rem;
    font-weight: 400;
}

.btn-primary {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #5a6fd8;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

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

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

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

.applications-grid {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.grid-header {
    display: grid;
    grid-template-columns: 150px 1fr 200px 200px;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
}

.application-row {
    display: grid;
    grid-template-columns: 150px 1fr 200px 200px;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    cursor: pointer;
    transition: background 0.2s;
}

.application-row:hover {
    background: #f8f9fa;
}

.clickable-cell {
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.clickable-cell:hover {
    background-color: #e3f2fd;
    color: #1976d2;
}

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.copy-btn:hover {
    opacity: 1;
}

.field-display-with-copy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-display-with-copy .field-display {
    flex: 1;
}

.application-row:last-child {
    border-bottom: none;
}

#api-result {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 4px;
    font-family: monospace;
    white-space: pre-wrap;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .grid-header,
    .application-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .tab-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
}
/* Application Detail Page Styles */
.breadcrumb {
    padding: 1rem 2rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.9rem;
}

.breadcrumb-link {
    color: #007bff;
    text-decoration: none;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    margin: 0 0.5rem;
    color: #6c757d;
}

.detail-container {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 2px solid #dee2e6;
}

.detail-header h1 {
    margin: 0;
    color: #333;
}

.detail-form {
    display: flex;
    flex-direction: column;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    max-width: 100%;
}

.field-row:last-child {
    border-bottom: none;
}

.field-row label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    text-align: left;
}

.field-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-group label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.field-display {
    padding: 0.1rem;
    border-radius: 4px;
    min-height: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.field-display[data-field]:hover {
    background: #e9ecef;
    border-color: #007bff;
}

.metadata-section {
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.metadata-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 0.75rem;
}

.metadata-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metadata-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metadata-field span {
    font-size: 0.9rem;
    color: #495057;
}

.field-edit {
    padding: 0.75rem;
    border: 2px solid #007bff;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}

.field-edit:focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

textarea.field-edit {
    min-height: 100px;
    resize: vertical;
}

#app_id-display {
    background: #e9ecef;
    cursor: default;
    font-weight: 600;
    color: #495057;
}

#app_id-display:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.contacts-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contact-row {
    display: grid;
    grid-template-columns: 1fr 2fr 2fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.contact-row:hover {
    background: #f8f9fa;
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Contact Selector Styles */
.contact-selector {
    position: relative;
    display: none;
}

.contact-selector.active {
    display: block !important;
}

.contact-search {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #007bff;
    border-radius: 4px;
    font-size: 1rem;
    outline: none;
}

.contact-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: yellow;
    border: 3px solid red;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: none;
}

.contact-selector.open .contact-dropdown {
    display: block !important;
}

.contact-option {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
}

.contact-option:hover {
    background: #f8f9fa;
}

.contact-option:last-child {
    border-bottom: none;
}

.contact-option-name {
    font-weight: 600;
    color: #333;
}

.contact-option-details {
    font-size: 0.9rem;
    color: #6c757d;
}
/* History container */
.history-container {
    margin: 0;
    padding: 2rem;
}

.cost-container {
    margin: 0;
    padding: 2rem;
}

.cost-controls {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cost-controls label {
    font-weight: 600;
}

.cost-controls select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
}

.cost-table {
    width: 100%;
    border-collapse: collapse;
}

.cost-table th,
.cost-table td {
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.cost-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.cost-cell {
    text-align: right;
    font-family: monospace;
}

.cost-total {
    font-weight: 600;
}

/* Applications entries */
.applications-entries {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.application-entry {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    background: #f9f9f9;
}

.application-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.contact-role {
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.application-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.application-details > div {
    font-size: 14px;
}

/* History entries */
.history-entries {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-entry {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    background: #f9f9f9;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.history-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.history-details > div {
    font-size: 14px;
}
/* Account page styles */
.account-info {
    padding: 2rem;
}

.info-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.info-section h3 {
    margin-bottom: 1rem;
    color: #495057;
    font-size: 1.2rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #dee2e6;
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #495057;
}

.info-value {
    color: #6c757d;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
}

#user-email {
    color: white;
    text-decoration: none;
}

#user-email:hover {
    text-decoration: underline;
}

.policy-section {
    margin-bottom: 1rem;
}

.policy-section h4 {
    margin-bottom: 0.5rem;
    color: #495057;
    font-size: 1rem;
}

.policy-json {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
    color: #495057;
}

/* Loading spinner */
.loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 999;
    display: none;
}

/* Role-based UI visibility */
/* Hide create/edit actions for readonly users */
.role-readonly .action-create,
.role-readonly .action-edit,
.role-readonly .action-delete {
    display: none !important;
}

/* Make readonly fields visually distinct */
.role-readonly .field-display[data-field] {
    cursor: default !important;
    opacity: 0.8;
}

.role-readonly .field-display[data-field]:hover {
    background-color: transparent !important;
}

/* Hide admin-only features for non-admin users */
.role-readonly .admin-only,
.role-users .admin-only {
    display: none !important;
}

/* Role badge styling */
.role-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 8px;
}
