:root {
    --primary: #036666;
    --primary-light: #047a7a;
    --primary-green: #80EF80;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --off-white: #f8f9fa;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --white: #ffffff;
    --black: #000000;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
}

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

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--white);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#app {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Login Screen */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    min-height: calc(100vh - 48px);
}

.login-container {
    background: var(--white);
    padding: 48px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.logo {
    margin-bottom: 32px;
}

.logo-with-cube {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.logo-cube {
    width: 48px;
    height: 48px;
}

.logo-img {
    max-width: 180px;
    height: auto;
}

.logo p {
    color: var(--gray-500);
    font-size: 14px;
}

#login-form {
    text-align: left;
}

#login-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

#login-form input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(3, 102, 102, 0.1);
}

#login-form button {
    width: 100%;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    font-family: inherit;
    color: var(--white);
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

#login-form button:hover {
    background: var(--primary-light);
}

#login-form button:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.message {
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 14px;
}

.message:empty {
    display: none;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

.message a {
    color: inherit;
    font-weight: 500;
}

.message .help-text {
    font-size: 12px;
    opacity: 0.85;
}

.inline-link {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    font-weight: 500;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}

.login-toggle {
    margin-top: 20px;
    text-align: center;
}

.toggle-link {
    background: none;
    border: none;
    color: var(--primary);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

.toggle-link:hover {
    color: var(--primary-light);
}

#totp-form {
    text-align: left;
}

#totp-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

#totp-form input[type="email"] {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#totp-form input[type="email"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(3, 102, 102, 0.1);
}

#totp-form input[type="text"] {
    width: 100%;
    padding: 16px;
    font-size: 28px;
    font-family: monospace;
    letter-spacing: 10px;
    text-align: center;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

#totp-form input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(3, 102, 102, 0.1);
}

#totp-form button {
    width: 100%;
    padding: 16px 24px;
    font-size: 18px;
    font-weight: 600;
    font-family: inherit;
    color: var(--white);
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

#totp-form button:hover {
    background: var(--primary-light);
}

#totp-form button:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

/* Dashboard Header */
header {
    background: var(--white);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-cube {
    width: 32px;
    height: 32px;
}

.header-logo {
    height: 28px;
    width: auto;
}

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

#client-name {
    font-size: 14px;
    color: var(--gray-500);
}

#logout-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-700);
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

#logout-btn:hover {
    background: var(--gray-200);
}

/* Main Dashboard */
main {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 24px;
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
}

/* Welcome Card */
.welcome-card {
    grid-column: span 8;
}

.welcome-card #company-name {
    color: var(--gray-500);
    margin-bottom: 16px;
}

/* Setup Progress Bar */
.setup-progress {
    margin-top: 8px;
}

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

.progress-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.progress-percent {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--gray-200);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 6px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-status {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 8px;
}

/* Preview Card */
.preview-card {
    grid-column: span 4;
    display: flex;
    flex-direction: column;
}

.preview-card p {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 16px;
    flex-grow: 1;
}

.btn-primary {
    display: inline-block;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--white);
    background: var(--primary);
    border-radius: var(--radius);
    text-decoration: none;
    text-align: center;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-light);
}

/* Modules Card */
.modules-card {
    grid-column: span 6;
}

.modules-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.module-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.module-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.module-link:hover {
    background: var(--gray-100);
    transform: translateX(4px);
}

.module-link .module-name::after {
    content: ' →';
    color: var(--primary);
}

.module-name {
    font-weight: 500;
}

.module-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 9999px;
    text-transform: uppercase;
}

.module-status.inactive {
    background: var(--gray-200);
    color: var(--gray-500);
}

.module-status.active {
    background: #fef3c7;
    color: #92400e;
}

.module-status.complete {
    background: #d1fae5;
    color: #065f46;
}

/* Activity Card */
.activity-card {
    grid-column: span 6;
}

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.activity-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.activity-content {
    flex-grow: 1;
}

.activity-action {
    font-weight: 500;
    margin-bottom: 2px;
}

.activity-time {
    font-size: 12px;
    color: var(--gray-500);
}

/* Invoice Card */
.invoice-card {
    grid-column: span 12;
}

.invoice-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.invoice-details {
    display: flex;
    gap: 32px;
}

.invoice-field {
    display: flex;
    flex-direction: column;
}

.invoice-label {
    font-size: 12px;
    color: var(--gray-500);
}

.invoice-value {
    font-weight: 500;
}

.invoice-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 9999px;
    text-transform: uppercase;
}

.invoice-status.paid {
    background: #d1fae5;
    color: #065f46;
}

.invoice-status.unpaid {
    background: #fef3c7;
    color: #92400e;
}

.invoice-status.overdue {
    background: #fee2e2;
    color: #991b1b;
}

/* Contact Steve Card */
.contact-card {
    grid-column: span 12;
}

.contact-subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-type-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.type-option {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.type-option input[type="radio"] {
    display: none;
}

.type-label {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    background: var(--gray-100);
    border: 2px solid var(--gray-200);
    border-radius: 20px;
    color: var(--gray-600);
    transition: all 0.2s;
}

.type-option input[type="radio"]:checked + .type-label {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.type-option:hover .type-label {
    border-color: var(--primary);
}

.contact-form textarea {
    width: 100%;
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s;
}

.contact-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-send {
    align-self: flex-start;
    padding: 10px 24px;
}

.contact-status {
    font-size: 13px;
    margin-top: 8px;
}

.contact-status.success {
    color: var(--success);
}

.contact-status.error {
    color: var(--error);
}

.no-invoice {
    color: var(--gray-500);
    font-size: 14px;
}

/* Site Footer - Sticky */
.site-footer {
    background: var(--black);
    color: var(--white);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    font-weight: 400;
    opacity: 1;
    position: sticky;
    bottom: 0;
    z-index: 100;
}

.footer-left {
    display: flex;
    gap: 24px;
    align-items: center;
    opacity: 0.75;
}

.footer-brand,
.footer-copy {
    color: var(--white);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-cube {
    width: 18px;
    height: 18px;
}

.footer-brand .highlight,
.footer-copy .highlight {
    color: var(--primary-green);
}

.footer-right {
    opacity: 0.75;
}

.footer-link {
    background: none;
    border: none;
    color: var(--white);
    font-family: inherit;
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--primary-green);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-nav {
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-nav a {
    color: var(--gray-700);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
    transition: color 0.2s;
}

.modal-nav a:last-child {
    border-bottom: none;
}

.modal-nav a:hover {
    color: var(--primary);
}

/* TOTP Setup Modal */
.totp-required-backdrop {
    background: rgba(0, 0, 0, 0.8);
}

.totp-setup-content {
    max-width: 480px;
}

.totp-setup-body {
    padding: 24px;
}

.totp-setup-intro {
    margin-bottom: 24px;
    padding: 16px;
    background: #fef3c7;
    border-radius: var(--radius);
    color: #92400e;
}

.totp-setup-intro p {
    margin: 0;
    font-size: 14px;
}

.totp-setup-steps {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.totp-step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.step-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content p {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.step-hint {
    color: var(--gray-500);
    font-size: 13px !important;
}

.totp-qr-container {
    margin: 16px 0;
    padding: 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    text-align: center;
}

.totp-qr-image {
    width: 200px;
    height: 200px;
}

.app-links {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.app-link {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    transition: background 0.2s, color 0.2s;
}

.app-link:hover {
    background: var(--primary);
    color: var(--white);
}

.setup-method-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    overflow: hidden;
}

.method-tab {
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    border: none;
    background: var(--gray-100);
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.method-tab:first-child {
    border-right: 1px solid var(--gray-300);
}

.method-tab.active {
    background: var(--primary);
    color: var(--white);
}

.method-tab:hover:not(.active) {
    background: var(--gray-200);
}

.setup-method {
    display: none;
}

.setup-method.active {
    display: block;
}

.manual-entry-instructions {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.manual-entry-instructions ol {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: var(--gray-700);
}

.manual-entry-instructions li {
    margin-bottom: 8px;
}

.manual-entry-instructions li:last-child {
    margin-bottom: 0;
}

.secret-key-box {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
}

.secret-key-box label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.secret-copy-container {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.totp-secret {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 15px;
    letter-spacing: 2px;
    padding: 12px;
    background: var(--gray-100);
    border-radius: var(--radius);
    text-align: center;
    word-break: break-all;
    user-select: all;
}

.copy-btn {
    padding: 12px 16px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    color: var(--white);
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.copy-btn:hover {
    background: var(--primary-light);
}

.copy-btn:active {
    transform: scale(0.98);
}

.copy-feedback {
    margin: 8px 0 0 0;
    font-size: 12px;
    text-align: center;
}

.copy-feedback.success {
    color: #065f46;
}

.copy-feedback.error {
    color: #991b1b;
}

.totp-setup-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 24px;
    font-family: monospace;
    letter-spacing: 8px;
    text-align: center;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.totp-setup-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(3, 102, 102, 0.1);
}

#totp-verify-section .btn-primary {
    width: 100%;
    margin-bottom: 12px;
}

#totp-setup-message {
    margin-top: 0;
}

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

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    margin-top: 16px;
    color: var(--gray-500);
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .card {
        grid-column: span 1 !important;
    }

    .quick-stats {
        gap: 24px;
    }

    .stat-value {
        font-size: 28px;
    }

    header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .login-container {
        margin: 16px;
        padding: 32px 24px;
    }

    .site-footer {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        font-size: 11.5px;
    }

    .footer-left {
        flex-direction: column;
        gap: 4px;
    }

    .totp-setup-content {
        max-width: 100%;
        margin: 16px;
        max-height: calc(100vh - 32px);
    }

    .totp-setup-body {
        padding: 16px;
    }

    .totp-step {
        flex-direction: column;
        gap: 12px;
    }

    .step-number {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .app-links {
        flex-direction: column;
        gap: 8px;
    }

    .app-link {
        text-align: center;
    }

    .setup-method-tabs {
        flex-direction: column;
    }

    .method-tab:first-child {
        border-right: none;
        border-bottom: 1px solid var(--gray-300);
    }

    .totp-qr-image {
        width: 180px;
        height: 180px;
    }

    .secret-copy-container {
        flex-direction: column;
    }

    .totp-secret {
        font-size: 13px;
        letter-spacing: 1px;
    }

    .manual-entry-instructions {
        padding: 12px;
    }

    .manual-entry-instructions ol {
        font-size: 12px;
    }
}
