:root {
    --primary: #6366F1;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --bg-body: #f3f4f6;
    --bg-surface: #ffffff;
    --bg-sidebar: #1e293b;
    
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --text-white: #ffffff;
    
    --border: #e5e7eb;
    --border-dark: #334155;
    
    --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);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

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

.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100%;
    z-index: 100;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 0;
    width: calc(100% - 260px);
}

.page-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Sidebar Components */
.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    background-color: rgba(0,0,0,0.2);
}

.logo {
    color: var(--text-white);
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-nav {
    padding: 1.5rem 0;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 2rem;
}

.nav-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0 1.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.6;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: inherit;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background-color: rgba(255,255,255,0.05);
    color: var(--text-white);
}

.nav-item.active {
    border-left-color: var(--primary);
    background-color: rgba(99, 102, 241, 0.1);
}

.nav-item i {
    width: 24px;
    margin-right: 0.75rem;
    text-align: center;
}

/* Top Bar */
.top-bar {
    height: 64px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.breadcrumbs {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.breadcrumbs i {
    font-size: 0.75rem;
    margin: 0 0.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

/* Cards & Layout Utilities */
.card {
    background: var(--bg-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.bg-highlight {
    background: #f8fafc;
    border: 1px dashed var(--border-dark);
}

.bg-dark {
    background: #1e293b;
    color: white;
    border: none;
}

.border-bottom-dark {
    border-bottom-color: rgba(255,255,255,0.1);
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.mb-4 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.75rem; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.w-xs { max-width: 200px; }

/* Typography */
h1 { font-size: 1.875rem; margin: 0 0 0.5rem 0; color: var(--text-main); }
.subtitle { color: var(--text-muted); margin: 0; font-size: 1rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
}

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

.btn-icon.delete:hover {
    color: var(--danger);
}

.full-width {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-input, .form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.925rem;
    color: var(--text-main);
    background: var(--bg-surface);
    transition: border-color 0.2s;
}

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

.large-select {
    padding: 1rem;
    font-size: 1.1rem;
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-icon input {
    padding-left: 2.5rem;
}

.required { color: var(--danger); }
small { display: block; margin-top: 0.25rem; color: var(--text-muted); font-size: 0.8rem; }

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

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

.table th, .table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toggle-label {
    font-weight: 500;
}

/* Specific Config Styles */
.section-block {
    margin-bottom: 2rem;
}

.block-label {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: block;
    color: var(--text-main);
}

.divider {
    border: 0;
    border-top: 1px dashed var(--border);
    margin: 2rem 0;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* Terms Grid */
.terms-grid {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border);
}

.term-row-header {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0 0.5rem;
}

.term-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr;
    gap: 1rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.total-row {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    font-weight: 700;
    font-size: 1.1rem;
}

.label-total { grid-column: 1 / 2; }
.value-total { grid-column: 3 / 4; color: var(--primary); }

/* Summary List */
.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.summary-item:last-child { border-bottom: none; }

.summary-item .label { color: rgba(255,255,255,0.6); font-size: 0.9rem; }
.summary-item .value { font-weight: 500; }
.summary-item .value.highlight { color: #818cf8; font-size: 1.25rem; font-weight: 700; }

.mini-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    padding: 0.25rem 0;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
}

/* Placeholders */
.placeholder-avatar {
    width: 32px;
    height: 32px;
    background: #cbd5e1;
    border-radius: 50%;
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

@media (max-width: 1024px) {
    .grid-2-1, .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        width: 64px;
    }
    
    .sidebar .logo span, .sidebar .nav-label, .sidebar-nav span, .sidebar-nav a {
        display: none;
    }
    
    .sidebar .logo i, .sidebar-nav i {
        margin: 0;
        font-size: 1.25rem;
    }
    
    .main-content {
        margin-left: 64px;
        width: calc(100% - 64px);
    }
}
