:root {
    --primary: #1E3A8A;
    /* Premium Deep Navy */
    --primary-hover: #1E40AF;
    --secondary: #64748B;
    --secondary-hover: #475569;
    --bg-color: #F8FAFC;
    /* Premium Light Gray */
    --card-bg: #FFFFFF;
    /* Pure White */
    --text-main: #0F172A;
    /* Dark Slate for high contrast */
    --text-muted: #475569;
    /* Medium Gray */
    --border-color: #E2E8F0;
    --tab-inactive: #94A3B8;
    --danger: #EF4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Pretendard', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    color: var(--text-main);
    font-weight: 700;
}

header h1 span {
    color: var(--primary);
}

header p {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Tabs */
.tabs-container {
    margin-bottom: 1.5rem;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 5px;
}

.tabs {
    display: inline-flex;
    list-style: none;
    gap: 0.5rem;
}

.tabs li {
    padding: 0.75rem 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--tab-inactive);
    transition: all 0.2s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.tabs li:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.tabs li.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.25);
}

.tabs li.tab-consolidated {
    background: #0F172A;
    color: white;
    border-color: #0F172A;
}

.tabs li.tab-consolidated.active {
    background: #000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.25);
}

/* Content Area */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.editor-header h2 {
    font-size: 1.25rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Tables */
.table-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-bottom: 1rem;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 1000px;
    table-layout: auto;
}

th,
td {
    padding: 0.8rem 0.5rem;
    /* Reduced horizontal padding slightly, increased vertical */
    border-bottom: 1px solid var(--border-color);
    white-space: normal;
    /* Allow text wrapping */
    word-break: keep-all;
    /* Keep korean words together if possible */
}

th {
    background: #F1F5F9;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid var(--border-color);
    /* Added explicit borders for grid look */
}

/* Consolidated Grid Specifics */
.consolidated-table th,
.consolidated-table td {
    border: 1px solid var(--border-color);
    padding: 0;
    /* Remove padding to allow internal rows to fill the cell */
}

.consolidated-table td strong {
    padding: 0.5rem;
    display: block;
}

.consolidated-table td:not(.grid-cell) {
    padding: 0.5rem;
}

.group-total-row td {
    border-top: 2px solid var(--border-color) !important;
    border-bottom: 2px solid var(--primary) !important;
}

tbody tr:hover {
    background: #F8FAFC;
}

input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    transition: border 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
}

.week-picker-wrapper {
    position: relative;
    cursor: pointer;
}

/* We position the input tiny but present so showPicker can originate from here */
.week-picker {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    outline: none;
    border: none;
    z-index: -1;
}

.actions {
    margin-top: 1rem;
    text-align: center;
}

/* Toast */
/* Phase 7: Consolidated View Enhancements */
.group-header {
    background-color: #E2E8F0;
    border-top: 3px solid var(--primary);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}

.group-header td {
    padding: 1rem 0.5rem;
}

.completed-cell,
.completed-cell .stats-row.plan-row,
.completed-cell .stats-row.act-row,
.completed-cell .act-input {
    background-color: #FFFF00 !important;
}

.type-cell {
    font-size: 0.8rem;
    color: #64748B;
    text-align: center;
    width: 60px;
    /* Slightly wider for alignment */
    border-right: 1px solid var(--border-color);
    vertical-align: middle;
}

.stats-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 0.9rem;
    min-height: 32px;
    padding: 0 0.5rem;
}

.stats-row.plan-row {
    background-color: #F8FAFC;
    /* Light background for plan row */
    border-bottom: 1px solid #E2E8F0;
    /* Internal divider */
    font-weight: 700;
    color: #1E3A8A;
}

.stats-row.act-row {
    background-color: #FFFFFF;
}

.stats-row.center {
    justify-content: center;
    text-align: center;
}

.plan-val-text {
    margin: 0 auto;
    width: 100%;
    text-align: center;
    display: block;
}

.act-input {
    width: 100%;
    /* Fill the grid cell width */
    height: 28px;
    padding: 0;
    border: 1px solid transparent;
    /* Cleaner look within grid */
    border-radius: 0;
    text-align: center;
    font-size: 0.9rem;
    background: transparent;
    color: #1E3A8A;
    font-weight: bold;
}

.act-input:hover {
    background: #F1F5F9;
}

.act-input:focus {
    background: #FFF;
    border-color: var(--primary);
    outline: none;
    box-shadow: inset 0 0 0 1px var(--primary);
}

.act-input:focus {
    border-color: #1E3A8A;
    outline: none;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #0F172A;
    /* Slate 900 */
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    opacity: 1;
    transition: opacity 0.3s;
    z-index: 1000;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}