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

:root {
    --primary-color: #0097a7;
    --primary-hover: #00838f;
    --primary-dark: #1a5276;
    --accent-color: #7cb342;
    --accent-hover: #689f38;
    --success-color: #4caf50;
    --error-color: #c23934;
    --warning-color: #ff9500;
    --border-color: #d0e6eb;
    --background-color: #f5f9fa;
    --card-background: #ffffff;
    --text-primary: #1a5276;
    --text-secondary: #3e5c6b;
    --text-muted: #6a8a99;
    --shadow: 0 2px 4px rgba(0, 151, 167, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 151, 167, 0.2);
    --gradient-primary: linear-gradient(135deg, #85dae8 0%, #95c5db 100%);
    --surface-color: #f8f9fa;
    --surface-border: #e9ecef;
    --input-background: #ffffff;
    --label-color: #495057;
    --value-color: #212529;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.login-container {
    max-width: 450px;
    margin: 100px auto;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    height: 100px;
    width: auto;
    margin-bottom: 15px;
}

header {
    background: var(--gradient-primary);
    padding: 12px 30px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.header-brand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    margin-bottom: 0;
}

.header-logo {
    height: 120px;
    width: auto;
    object-fit: contain;
}

.header-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.brand-name {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    letter-spacing: 1px;
}

h1 {
    color: white;
    font-size: 2rem;
    margin-bottom: 0;
    font-weight: 600;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 600;
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    font-weight: 600;
}

/* Forms */
.form-section {
    background: var(--card-background);
    padding: 40px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

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

label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: block;
    margin-bottom: 8px;
}

label.required::after {
    content: " *";
    color: var(--error-color);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--input-background);
    transition: all 0.3s ease;
    font-family: inherit;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="url"]:hover,
textarea:hover {
    border-color: var(--primary-color);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(1, 118, 211, 0.1);
}

textarea {
    min-height: 80px;
    resize: vertical;
}

/* Hide private key textarea content by default (like password field) */
#private_key {
    -webkit-text-security: disc;
    text-security: disc;
    font-family: monospace;
}

.input-help {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Input with actions (for masked fields) */
.input-with-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-with-actions input,
.input-with-actions textarea {
    flex: 1;
}

.btn-icon {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    background: var(--input-background);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: var(--background-color);
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:not(:disabled):hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--background-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #a52a2a;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    padding: 0;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
}

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

/* Messages */
.error-message {
    background: #fddede;
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

.success-message {
    background: rgba(46, 132, 74, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

.info-message {
    background: rgba(1, 118, 211, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

/* Modal dialog (shares backdrop with loading-overlay) */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-dialog {
    background: var(--card-background);
    color: var(--text-primary);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    padding: 32px;
    max-width: 480px;
    width: 90%;
}

.modal-dialog h3 {
    margin-bottom: 12px;
}

.modal-dialog p {
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.5;
}

.modal-dialog .modal-config-name {
    font-weight: 700;
    color: var(--error-color);
    font-size: 1.05rem;
    word-break: break-all;
}

.modal-dialog .modal-warning {
    background: rgba(194, 57, 52, 0.08);
    border: 1px solid rgba(194, 57, 52, 0.3);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.875rem;
    color: var(--error-color);
    margin: 14px 0 0;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Tables */
.table-container {
    background: var(--card-background);
    padding: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

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

thead {
    background: var(--background-color);
}

th {
    text-align: left;
    padding: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--background-color);
}

.table-actions {
    display: flex;
    gap: 10px;
}

.table-actions button {
    padding: 6px 12px;
    font-size: 0.875rem;
}

/* Navigation */
.nav-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .header-brand {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-logo {
        height: 50px;
    }

    .form-section {
        padding: 20px;
    }

    .table-container {
        padding: 15px;
    }

    table {
        font-size: 0.875rem;
    }

    .table-actions {
        flex-direction: column;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Masked field indicator */
.masked-value {
    font-family: monospace;
    color: var(--text-muted);
}

/* Tenant header styles */
.tenant-header {
    background: var(--card-background);
    padding: 15px 30px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.tenant-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.tenant-info strong {
    color: var(--text-primary);
}

.tenant-info span {
    color: var(--text-secondary);
}

.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.owner {
    background-color: #7c3aed;
    color: white;
}

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

.role-badge.member {
    background-color: #059669;
    color: white;
}

.role-badge.viewer {
    background-color: #6b7280;
    color: white;
}

.tenant-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tenant-switcher label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
}

.tenant-switcher select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--input-background);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 200px;
}

.tenant-switcher select:hover {
    border-color: var(--primary-color);
}

.tenant-switcher select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(1, 118, 211, 0.1);
}

@media (max-width: 768px) {
    .tenant-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tenant-switcher {
        width: 100%;
    }

    .tenant-switcher select {
        width: 100%;
    }
}
