:root {
    --bg-color: #f4f7fa;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --primary: #2563eb; /* Blue */
    --primary-hover: #1d4ed8;
    --success: #10b981; /* Green */
    --warning: #f59e0b; /* Orange */
    --purple: #8b5cf6;
    --danger: #ef4444;
    
    --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);
    
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

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

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

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

.header-content h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.header-content p {
    color: var(--text-muted);
    font-size: 15px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

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

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

.btn-danger {
    background-color: #fee2e2;
    color: var(--danger);
}
.btn-danger:hover { background-color: #fecaca; }

.btn-icon { padding: 8px; font-size: 18px; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; padding: 14px; font-size: 16px; margin-top: 10px; }

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

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
}

.kpi-blue .kpi-icon { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.kpi-green .kpi-icon { background: linear-gradient(135deg, #34d399, #059669); }
.kpi-orange .kpi-icon { background: linear-gradient(135deg, #fbbf24, #d97706); }
.kpi-purple .kpi-icon { background: linear-gradient(135deg, #a78bfa, #6d28d9); }

.kpi-info { display: flex; flex-direction: column; }
.kpi-label { font-size: 13px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--text-main); margin-top: 4px; }

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .main-grid { grid-template-columns: 1fr; }
}

/* Cards (Sections) */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.card h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-main);
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 15px;
    color: var(--text-main);
    transition: all 0.2s ease;
    background-color: #f8fafc;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background-color: #ffffff;
}

.rate-display { display: flex; flex-direction: column; justify-content: flex-end; }
.display-value {
    padding: 10px 14px;
    background: #e0f2fe;
    border-radius: var(--radius-md);
    font-weight: 700;
    color: #0369a1;
    font-size: 16px;
}

.form-caption { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 12px; }

/* History Section */
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.history-header h2 { border: none; margin: 0; padding: 0; }

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td { padding: 12px 16px; border-bottom: 1px solid var(--border-color); font-size: 14px; }
th { background-color: #f8fafc; font-weight: 600; color: var(--text-muted); }
td { color: var(--text-main); }
tbody tr:hover { background-color: #f1f5f9; }

.sortable { cursor: pointer; user-select: none; transition: color 0.2s; white-space: nowrap; }
.sortable:hover { color: var(--primary); }
.sort-icon { font-size: 14px; margin-left: 4px; vertical-align: text-bottom; color: #cbd5e1; }
th.active-sort { color: var(--primary); }
th.active-sort .sort-icon { color: var(--primary); }

.empty-state {
    display: none; /* hidden by JS */
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state ion-icon { font-size: 48px; color: #cbd5e1; margin-bottom: 10px; }
.active-empty { display: block; }

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.small-input { width: 80px; text-align: center; }

@media (max-width: 600px) {
    .header { flex-direction: column; align-items: flex-start; gap: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .footer { flex-direction: column; align-items: stretch; }
    .settings-group { justify-content: space-between; }
}
