:root {
    --bg-app: #f6f8fb;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --secondary: #10b981;
    --secondary-hover: #059669;
    --secondary-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --border: #e2e8f0;
    --font-family: 'Plus Jakarta Sans', sans-serif;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* Navbar */
.app-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--card-bg);
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.025em;
}

.brand-title .accent {
    color: var(--primary);
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-tabs {
    display: flex;
    gap: 8px;
}

.nav-tab {
    background: transparent;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
}

.nav-tab:hover {
    color: var(--text-main);
    background-color: var(--bg-app);
}

.nav-tab.active {
    color: var(--primary);
    background-color: var(--primary-light);
}

.nav-actions .badge {
    background-color: var(--secondary-light);
    color: var(--secondary);
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Workspace */
.workspace-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 32px;
    flex: 1;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

h2 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-main);
}

.description {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

/* Dashboard Grid & Panes */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-info h3 {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.metric-icon {
    font-size: 28px;
    opacity: 0.85;
}

.card-gradient-cash .metric-value { color: var(--primary); }
.card-gradient-inventory .metric-value { color: var(--secondary); }
.card-gradient-sales .metric-value { color: #8b5cf6; }
.card-gradient-po .metric-value { color: var(--warning); }

.dashboard-panes {
    display: grid;
    grid-template-columns: 4fr 5fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .dashboard-panes {
        grid-template-columns: 1fr;
    }
}

/* Parameters Panel */
.parameters-pane {
    display: flex;
    flex-direction: column;
}

.parameters-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.parameter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.parameter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.parameter-group label span span {
    color: var(--primary);
    font-weight: 700;
    background-color: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    background: #e2e8f0;
    border-radius: 9999px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.action-buttons-row {
    display: flex;
    gap: 12px;
    margin-top: auto;
}

/* Chart */
.visualization-pane {
    display: flex;
    flex-direction: column;
}

.chart-container {
    position: relative;
    height: 320px;
    width: 100%;
}

/* Feed Pane */
.feed-pane {
    margin-top: 24px;
}

.log-feed {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 8px;
}

.log-item {
    padding: 10px 14px;
    background-color: var(--bg-app);
    border-left: 4px solid var(--primary);
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-item.info { border-left-color: var(--primary); }
.log-item.success { border-left-color: var(--secondary); }
.log-item.warning { border-left-color: var(--warning); }
.log-item.danger { border-left-color: var(--danger); }

.log-time {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
}

/* Tables */
.table-container {
    overflow-x: auto;
    padding: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.data-table th, .data-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

/* Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
}

.status-badge.nominal, .status-badge.completed, .status-badge.received {
    background-color: var(--secondary-light);
    color: var(--secondary);
}

.status-badge.pending, .status-badge.alert {
    background-color: var(--warning-light);
    color: var(--warning);
}

.status-badge.critical, .status-badge.cancelled {
    background-color: var(--danger-light);
    color: var(--danger);
}

/* Buttons */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

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

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

.btn-secondary {
    background-color: var(--secondary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background-color: var(--bg-app);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

/* Forms */
.standard-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

input, select {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s ease;
}

input:focus, select:focus {
    border-color: var(--primary);
}

/* Split Workspaces (Sales/Purchases Tab layout) */
.sales-workspace, .purchases-workspace {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .sales-workspace, .purchases-workspace {
        grid-template-columns: 1fr;
    }
}

.form-card {
    height: fit-content;
}

/* Modals */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.active {
    display: flex;
}

.modal-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    padding: 24px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    animation: modalSlide 0.2s ease-out;
}

@keyframes modalSlide {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h3 {
    margin-bottom: 0;
}

.close-modal-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
