:root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --primary: #3b82f6;
    --secondary: #22c55e;
    --warning: #ef4444;
    --text: #0f172a;
    --border: #e2e8f0;
}

body.dark-mode {
    --bg: #0f172a;
    --panel: #1e293b;
    --text: #f8fafc;
    --border: #334155;
}

body.dark-mode .form-row { background: #334155; }
body.dark-mode #progress-table { background: #1e293b; color: var(--text); }
body.dark-mode #progress-table th { background-color: #0f172a; color: #cbd5e1; }
body.dark-mode #progress-table tbody tr:hover { background-color: #334155; }
body.dark-mode .input-hours { background: #0f172a; color: #f8fafc; border-color: #475569; }
body.dark-mode .modal-content { background: #1e293b; color: var(--text); }
body.dark-mode .btn-icon { background: #334155; color: #f8fafc; }
body.dark-mode .btn-icon:hover { background: #475569; }
body.dark-mode .main-gauge { background: #334155; }
body.dark-mode .workspace-select { background: #1e293b; color: #f8fafc; border-color: #475569; }
body.dark-mode .app-footer { color: #64748b; }

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); padding: 20px; }
.container { max-width: 1200px; margin: 0 auto; }

.header-main { display: flex; justify-content: space-between; align-items: center; }
.header-logo { height: 36px; width: auto; object-fit: contain; }
.workspace-select { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-family: inherit; font-size: 0.9rem; font-weight: 600; outline: none; }
.stats-banner { display: flex; align-items: center; gap: 30px; margin-top: 20px; }

.main-gauge { background: var(--text); color: white; padding: 15px 25px; border-radius: 12px; font-size: 1.2rem; }

.progress-bar-container { background: var(--border); border-radius: 8px; height: 12px; overflow: hidden; width: 100%; }
.progress-bar-fill { background: var(--primary); height: 100%; width: 0%; transition: width 0.3s ease; }

.panel { background: var(--panel); padding: 25px; border-radius: 16px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); margin-top: 30px; }
.panel-header { display: flex; justify-content: space-between; margin-bottom: 20px; }

.form-row { background: #f1f5f9; padding: 15px; border-radius: 12px; display: flex; gap: 10px; margin-bottom: 20px; }

.chapter-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.chapter-box { width: 24px; height: 24px; border: 1px solid var(--border); font-size: 0.7rem; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 3px; }
.chapter-box.done { background: var(--secondary); color: white; }

/* Table and Books List Presentation */
.table-wrapper { border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 15px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
#progress-table { width: 100%; border-collapse: collapse; background: white; }
#progress-table th, #progress-table td { padding: 16px 20px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
#progress-table th { background-color: #f8fafc; color: #475569; font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
#progress-table tbody tr:last-child td { border-bottom: none; }
#progress-table tbody tr:hover { background-color: #f1f5f9; transition: background 0.2s ease; }

/* Table Cells Specifics */
.danger { color: var(--warning); font-weight: 600; background: #fef2f2; padding: 4px 8px; border-radius: 4px; display: inline-block; }
.effort-cell { display: flex; align-items: center; gap: 12px; }
.effort-val { font-weight: 600; font-size: 1.05rem; color: var(--primary); min-width: 45px; }
.input-hours { padding: 8px; border: 1px solid var(--border); border-radius: 6px; outline: none; background: #f8fafc; transition: border 0.2s; }
.input-hours:focus { border-color: var(--primary); background: white; }
.action-cell { display: flex; gap: 10px; align-items: center; }
.btn-icon { background: #e2e8f0; border: none; padding: 6px 10px; border-radius: 6px; color: #475569; font-weight: 600; cursor: pointer; transition: background 0.2s; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: #cbd5e1; color: #0f172a; }
.btn-icon-danger { background: #fef2f2; border: none; padding: 6px 10px; border-radius: 6px; color: var(--warning); font-weight: 600; cursor: pointer; transition: background 0.2s; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
.btn-icon-danger:hover { background: #fee2e2; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: white; padding: 30px; border-radius: 12px; width: 500px; max-height: 80vh; overflow-y: auto; }
.log-edit-row { display: flex; gap: 10px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

.btn-small { padding: 4px 8px; font-size: 0.8rem; border-radius: 4px; cursor: pointer; }
.danger-text { color: var(--warning); background: none; border: none; cursor: pointer; font-size: 0.8rem; }

.app-footer { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 20px 0; margin-top: 20px; font-size: 0.85rem; color: #94a3b8; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body { padding: 10px; }
    .header-main { flex-direction: column; align-items: flex-start; gap: 15px; }
    .header-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
    .stats-banner { flex-direction: column; align-items: stretch; gap: 15px; }
    .form-row { flex-direction: column; }
    .modal-content { width: 90%; padding: 20px; }
    
    /* Horizontal Scrolling Table for Mobile */
    #progress-table th, #progress-table td { white-space: nowrap; padding: 12px 10px; }
    #progress-table td:nth-child(3) { white-space: normal; min-width: 200px; } /* Allows chapter grid to wrap properly */
}
