/* Login page */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { max-width: 400px; }
.login-card { padding: 2rem; }
.error-text { color: var(--pico-color-red-500); font-size: 0.9rem; }

/* App layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 240px; min-width: 240px; background: var(--pico-background-color);
    border-right: 1px solid var(--pico-muted-border-color);
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
    z-index: 100; overflow-y: auto;
}
.sidebar-header { padding: 1.25rem 1rem 0.75rem; border-bottom: 1px solid var(--pico-muted-border-color); }
.sidebar-title { margin: 0; font-size: 1.1rem; }
.sidebar-nav { flex: 1; padding: 0.5rem; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.75rem;
    border-radius: 6px; text-decoration: none; color: var(--pico-color); font-size: 0.9rem;
    transition: background 0.15s;
}
.nav-link:hover { background: var(--pico-muted-border-color); text-decoration: none; }
.nav-link.active { background: var(--pico-primary-background); color: var(--pico-primary-inverse); font-weight: 600; }
.nav-icon { width: 1.2em; text-align: center; }
.sidebar-footer {
    padding: 0.75rem 1rem; border-top: 1px solid var(--pico-muted-border-color);
    display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 600; }
.user-roles { color: var(--pico-muted-color); font-size: 0.75rem; }
.logout-link { font-size: 0.8rem; }

/* Main content */
.main-content { margin-left: 240px; flex: 1; padding: 1.5rem 2rem; max-width: 1200px; }
.page-header { margin-bottom: 1rem; }
.page-header h2 { margin: 0; }
.page-content { }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { padding: 1.25rem; border-radius: 8px; border: 1px solid var(--pico-muted-border-color); background: var(--pico-background-color); }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.stat-card .stat-label { font-size: 0.85rem; color: var(--pico-muted-color); margin-top: 0.25rem; }

/* Status badges */
.badge {
    display: inline-block; padding: 0.2em 0.6em; border-radius: 12px;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-draft { background: #e2e8f0; color: #475569; }
.badge-confirmed, .badge-submitted, .badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-processing, .badge-in_progress, .badge-loading { background: #fef3c7; color: #92400e; }
.badge-ready_to_ship, .badge-testing { background: #e0e7ff; color: #4338ca; }
.badge-shipped, .badge-in_transit, .badge-planned { background: #ddd6fe; color: #6d28d9; }
.badge-delivered, .badge-received, .badge-complete, .badge-completed, .badge-paid { background: #d1fae5; color: #065f46; }
.badge-cancelled, .badge-void, .badge-voided { background: #fee2e2; color: #991b1b; }
.badge-on_hold { background: #fed7aa; color: #9a3412; }
.badge-partially_shipped { background: #e9d5ff; color: #7c3aed; }
.badge-active { background: #d1fae5; color: #065f46; }

/* Tables */
.table-toolbar { display: flex; gap: 1rem; margin-bottom: 1rem; align-items: flex-end; flex-wrap: wrap; }
.table-toolbar input[type="search"] { max-width: 300px; }
.table-toolbar select { max-width: 200px; }
table { width: 100%; }
.table-actions { display: flex; gap: 0.5rem; }
.table-empty { text-align: center; padding: 2rem; color: var(--pico-muted-color); }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.pagination-info { font-size: 0.85rem; color: var(--pico-muted-color); }

/* Detail page */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.detail-section { margin-bottom: 1.5rem; }
.detail-section h4 { margin-bottom: 0.75rem; border-bottom: 1px solid var(--pico-muted-border-color); padding-bottom: 0.5rem; }
.dl-grid { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; }
.dl-grid dt { font-weight: 600; font-size: 0.85rem; color: var(--pico-muted-color); }
.dl-grid dd { margin: 0; font-size: 0.9rem; }
.action-bar { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* Toasts */
#toast-container {
    position: fixed; top: 1rem; right: 1rem; z-index: 1000;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    padding: 0.75rem 1.25rem; border-radius: 8px; font-size: 0.9rem; font-weight: 500;
    animation: toast-in 0.3s ease, toast-out 0.3s ease 3.7s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast-success { background: #065f46; color: white; }
.toast-error { background: #991b1b; color: white; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }

/* History timeline */
.history-list { list-style: none; padding: 0; }
.history-item { padding: 0.5rem 0; border-bottom: 1px solid var(--pico-muted-border-color); font-size: 0.85rem; }
.history-item:last-child { border-bottom: none; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 60px; min-width: 60px; }
    .nav-link span:not(.nav-icon) { display: none; }
    .sidebar-header, .sidebar-footer .user-info { display: none; }
    .main-content { margin-left: 60px; padding: 1rem; }
    .detail-grid, .form-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}
