:root {
    --primary: #E17055;
    --primary-dim: rgba(225, 112, 85, 0.2);
    --primary-hover: #fa8266;
    --secondary: #D63031;
    --accent: #00CEC9;
    --bg-color: #0D0A0A;
    --panel-bg: rgba(22, 18, 18, 0.7);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #FFFFFF;
    --text-muted: #A0AEC0;
    --danger: #ff7675;
    --success: #00b894;
    --border-radius: 12px;
    --transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(225, 112, 85, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(0, 206, 201, 0.05) 0%, transparent 40%);
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Sidebar */
.sidebar {
    width: 260px;
    margin: 1rem;
    margin-right: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
    margin-bottom: 2.5rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

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

.nav-item.active {
    color: var(--primary);
    background-color: var(--primary-dim);
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

.btn.full-width {
    width: 100%;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 4px 12px rgba(225, 112, 85, 0.3);
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(225, 112, 85, 0.4);
}

.btn.secondary {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn.secondary:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

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

.btn.danger {
    background-color: rgba(214, 48, 49, 0.1);
    color: var(--danger);
    border: 1px solid rgba(214, 48, 49, 0.3);
}

.btn.danger:hover {
    background-color: rgba(214, 48, 49, 0.2);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border-radius: 4px;
}

.icon-btn:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.1);
}

/* File input hack */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.file-input-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
    height: 100%;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    overflow: hidden;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    width: 300px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    width: 100%;
    outline: none;
}

.views-container {
    flex: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 2rem;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

/* Dashboard View */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.kpi-card.gradient-border::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.kpi-card h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.kpi-value.warning { color: var(--text-main); }
.kpi-value.small { font-size: 1.5rem; align-items: center; display: flex; height: 3.75rem; }

.kpi-trend {
    font-size: 0.875rem;
    color: var(--text-muted);
}
.kpi-trend.highlight { color: var(--accent); }

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

.section-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--panel-border);
}

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

/* Chart */
.chart-container {
    padding: 1.5rem;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 1rem;
}

.chart-bar-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chart-label {
    width: 120px;
    font-size: 0.875rem;
    text-align: right;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-track {
    flex: 1;
    height: 24px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.chart-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    min-width: 4px;
    transition: width 1s ease-out;
}

.chart-value {
    width: 60px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Timeline */
.timeline {
    list-style: none;
    padding: 1.5rem;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-date {
    width: 50px;
    text-align: center;
    flex-shrink: 0;
}

.t-day {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.t-month {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.timeline-content {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    padding: 1rem;
    border-radius: 8px;
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-item.urgent .timeline-content {
    border-color: rgba(225, 112, 85, 0.4);
    background: rgba(225, 112, 85, 0.05);
}

.timeline-content h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.timeline-content p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.t-cost {
    font-weight: 700;
    color: var(--primary);
}

/* List View */
.list-controls {
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.filters {
    display: flex;
    gap: 1rem;
}

.select-input {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
    appearance: none;
    outline: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23A0AEC0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

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

.subs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.sub-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: var(--transition);
}

.sub-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.15);
}

.sub-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.sub-icon-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sub-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.sub-name h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.sub-cat {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sub-cost {
    text-align: right;
}

.sub-amount {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.sub-cycle {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.sub-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--panel-border);
}

.sub-renewal {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sub-renewal span {
    color: var(--text-main);
    font-weight: 500;
}

.sub-actions {
    display: flex;
    gap: 0.25rem;
}

/* Empty State */
.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state.visible {
    display: flex;
}

.empty-state .icon-wrapper {
    width: 80px;
    height: 80px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    max-width: 400px;
}

.mt-4 { margin-top: 1.5rem; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 100%;
    max-width: 500px;
    padding: 0;
    transform: scale(1);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal {
    transform: scale(0.95);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

#subForm {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus {
    border-color: var(--primary);
    background-color: rgba(0, 0, 0, 0.5);
}

/* date input dark mode fix for webkit */
::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

.input-with-prefix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-prefix .prefix {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
}

.input-with-prefix input {
    padding-left: 2rem;
    width: 100%;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background-color: var(--success);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
}

.toast.hidden {
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
}

@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: auto;
        margin: 1rem;
        flex-direction: row;
        align-items: center;
        padding: 1rem;
    }
    
    .logo { margin-bottom: 0; margin-right: 2rem; }
    .nav-menu { flex-direction: row; }
    .sidebar-actions { display: none; }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
