* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --light: #f8fafc;
    --dark: #1e293b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
}

/* Setup & Login Pages */
.setup-container,
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.setup-card,
.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

.setup-header,
.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.setup-header h1,
.login-header h1 {
    font-size: 32px;
    margin-bottom: 10px;
    color: var(--primary);
}

.setup-header p,
.login-header p {
    color: var(--secondary);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
}

.form-group input,
.form-control,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-control:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    resize: vertical;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.btn-group {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
}

.btn-icon:hover {
    opacity: 0.7;
}

button[type="submit"] {
    width: 100%;
}

/* Dashboard */
#dashboard {
    background: var(--light);
    min-height: 100vh;
}

.navbar {
    background: white;
    padding: 16px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.nav-menu {
    display: flex;
    gap: 8px;
    flex: 1;
}

.nav-link {
    padding: 8px 16px;
    color: var(--secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--light);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-user {
    font-size: 14px;
    color: var(--secondary);
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 24px;
}

.dashboard-page {
    display: none;
}

.dashboard-page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 28px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    font-size: 40px;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
}

.api-key-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px !important;
    font-family: 'Courier New', monospace;
}

/* Section */
.section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.section h3 {
    margin-bottom: 20px;
    font-size: 20px;
}

/* Table */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--light);
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--dark);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    font-size: 14px;
}

.table tbody tr:hover {
    background: var(--light);
}

.text-center {
    text-align: center;
}

/* Status badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-processing {
    background: #dbeafe;
    color: #1e40af;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 6px 12px;
    font-size: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn-primary {
    background: var(--primary);
    color: white;
}

.action-btn-danger {
    background: var(--danger);
    color: white;
}

.action-btn:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.modal-close:hover {
    background: var(--light);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* API Docs */
.api-section {
    margin-bottom: 40px;
}

.api-section h3 {
    margin-bottom: 16px;
    color: var(--dark);
}

.api-endpoint {
    background: var(--light);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.method {
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

.method.get {
    background: #d1fae5;
    color: #065f46;
}

.method.post {
    background: #dbeafe;
    color: #1e40af;
}

.path {
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

pre {
    background: var(--dark);
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* Orders Container - Card View */
.orders-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.order-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.order-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.order-card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.order-card-header:hover {
    opacity: 0.9;
}

.order-card-title {
    font-size: 16px;
    font-weight: 600;
}

.order-card-toggle {
    font-size: 20px;
    transition: transform 0.3s ease;
}

.order-card.expanded .order-card-toggle {
    transform: rotate(180deg);
}

.order-card-body {
    padding: 16px;
    display: none;
    animation: slideDown 0.3s ease;
}

.order-card.expanded .order-card-body {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

.order-card-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.order-card-row:last-child {
    border-bottom: none;
}

.order-card-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.order-card-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.order-card-section-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.order-card-label {
    font-weight: 600;
    color: var(--secondary);
    min-width: 120px;
}

.order-card-value {
    color: var(--dark);
    word-break: break-word;
    flex: 1;
    text-align: right;
    padding-left: 10px;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.status-processing {
    background: #bfdbfe;
    color: #1e40af;
}

.status-badge.status-running {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-partial {
    background: #fed7aa;
    color: #92400e;
}

.status-badge.status-canceled {
    background: #fecaca;
    color: #7f1d1d;
}

.status-badge.status-cancel_pending {
    background: #dbeafe;
    color: #1e40af;
}

.status-badge.status-failed {
    background: #fecaca;
    color: #7f1d1d;
}

.api-section ul {
    margin-left: 24px;
    margin-top: 8px;
}

.api-section li {
    margin-bottom: 8px;
}

/* Utility */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-menu {
        width: 100%;
        flex-wrap: wrap;
    }

    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

/* Orders List Container */
.orders-list-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.order-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.order-item:hover {
    box-shadow: var(--shadow-lg);
}

.order-item-group {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.order-item-group:last-child {
    border-bottom: none;
}

.order-item-group-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.order-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.order-item-label {
    font-weight: 600;
    color: var(--secondary);
    min-width: 120px;
}

.order-item-value {
    color: var(--dark);
    text-align: right;
    flex: 1;
}

/* Form Sections */
.form-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section h4 {
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row .form-group {
    margin-bottom: 0;
}

/* Orders Grid Container */
.orders-grid-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.order-row {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    min-height: 200px;
}

.order-row:hover {
    box-shadow: var(--shadow-lg);
}

.order-column {
    padding: 16px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.order-column:last-child {
    border-right: none;
}

.order-column-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.order-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
    gap: 8px;
}

.order-detail-item:last-child {
    border-bottom: none;
}

.order-detail-label {
    font-weight: 600;
    color: var(--secondary);
    min-width: 100px;
}

.order-detail-value {
    color: var(--dark);
    text-align: right;
    flex: 1;
    margin-left: 8px;
    word-break: break-word;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.order-detail-value a {
    color: var(--primary);
    text-decoration: none;
}

.order-detail-value a:hover {
    text-decoration: underline;
}

.btn-copy {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    margin-left: 4px;
    transition: all 0.2s ease;
}

.btn-copy:hover {
    background: #f0f0f0;
    border-radius: 4px;
    padding: 0 4px;
    transform: scale(1.2);
}

.order-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: flex-start;
    margin-top: auto;
}

.order-actions .btn {
    width: 100%;
    padding: 8px 12px;
    font-size: 12px;
}

