* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, #1a73e8, #1557b0);
    color: #fff;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-left .hamburger {
    display: none;
    background: none; border: none; color: #fff;
    font-size: 22px; cursor: pointer; padding: 4px;
}
.header-left h1 { font-size: 18px; font-weight: 600; }
.header-left .subtitle { font-size: 12px; opacity: 0.7; margin-left: 8px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-right .time { font-size: 12px; opacity: 0.7; }
.header-right button {
    padding: 6px 14px;
    background: rgba(255,255,255,0.18);
    color: #fff;
    border: none; border-radius: 4px;
    font-size: 13px; cursor: pointer;
    transition: background 0.2s;
}
.header-right button:hover { background: rgba(255,255,255,0.3); }
.header-right button:disabled { opacity: 0.5; cursor: not-allowed; }
.header-right .polling-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.8;
}
.header-right .polling-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    animation: pulse 2s infinite;
}
.header-right .polling-dot.paused {
    background: #ff9800;
    animation: none;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.header-right .nav-links a {
    color: #fff; text-decoration: none; font-size: 12px;
    padding: 5px 12px; border-radius: 4px;
    background: rgba(255,255,255,0.12);
    transition: background 0.2s;
}
.header-right .nav-links a:hover { background: rgba(255,255,255,0.25); }

/* ===== Layout ===== */
.layout { display: flex; padding-top: 60px; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
    width: 220px;
    background: #fff;
    border-right: 1px solid #e8e8e8;
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 50;
    transition: transform 0.25s ease;
}
.sidebar .menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    user-select: none;
}
.sidebar .menu-item:hover {
    background: #f5f8ff;
    color: #1a73e8;
}
.sidebar .menu-item.active {
    background: #e8f0fe;
    color: #1a73e8;
    font-weight: 600;
    border-left-color: #1a73e8;
}
.sidebar .menu-item .icon { font-size: 16px; width: 24px; text-align: center; }
.sidebar .menu-item .menu-label { flex: 1; }
.sidebar .menu-item .menu-count {
    font-size: 11px;
    background: #f0f0f0;
    color: #888;
    padding: 1px 8px;
    border-radius: 8px;
    font-weight: 500;
}
.sidebar .menu-item.active .menu-count {
    background: #d2e3fc;
    color: #1a73e8;
}
.sidebar .menu-divider {
    height: 1px; background: #f0f0f0; margin: 4px 12px;
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    margin-left: 220px;
    padding: 24px 32px;
    min-height: calc(100vh - 60px);
}

/* ===== Content header ===== */
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.content-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    padding-left: 14px;
    border-left: 3px solid #1a73e8;
    line-height: 1.4;
}
.content-header h2 .count-badge {
    font-size: 13px;
    font-weight: 400;
    color: #888;
    margin-left: 10px;
}

.card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ===== Stat Cards ===== */
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-card {
    flex: 1;
    min-width: 150px;
    background: #fff;
    border-radius: 10px;
    padding: 18px 20px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s, transform 0.2s;
    cursor: default;
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.stat-card .num { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-card .label { font-size: 12px; color: #888; margin-top: 6px; }
.stat-card .sub { font-size: 11px; color: #aaa; margin-top: 2px; }
.stat-card.color-blue .num { color: #1a73e8; }
.stat-card.color-green .num { color: #2e7d32; }
.stat-card.color-orange .num { color: #e65100; }
.stat-card.color-red .num { color: #c62828; }
.stat-card.color-purple .num { color: #6a1b9a; }
.stat-card.color-teal .num { color: #00695c; }
.stat-card.color-gray .num { color: #555; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; border: 1px solid #e8e8e8; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border: 1px solid #e8e8e8; text-align: left; white-space: nowrap; }
th {
    background: #fafafa;
    font-weight: 600;
    color: #555;
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 12px;
}
tr:hover td { background: #f5f8ff; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.badge-blue { background: #e3f2fd; color: #1565c0; }
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-orange { background: #fff3e0; color: #e65100; }
.badge-red { background: #ffebee; color: #c62828; }
.badge-gray { background: #f5f5f5; color: #616161; }
.badge-purple { background: #f3e5f5; color: #6a1b9a; }
.badge-teal { background: #e0f2f1; color: #00695c; }

/* ===== Progress bar ===== */
.progress-bar { display: flex; align-items: center; gap: 8px; }
.progress-bar .track {
    flex: 1; height: 8px; background: #f0f0f0;
    border-radius: 4px; overflow: hidden; min-width: 80px;
}
.progress-bar .fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.progress-bar .fill-green { background: #66bb6a; }
.progress-bar .fill-orange { background: #ffa726; }
.progress-bar .fill-red { background: #ef5350; }
.progress-bar .pct { font-size: 12px; color: #666; min-width: 36px; text-align: right; }

/* ===== Chart bar ===== */
.chart-bar { display: flex; align-items: center; gap: 6px; }
.chart-bar .bar {
    height: 18px; border-radius: 3px; min-width: 4px;
    transition: width 0.6s ease;
}
.chart-bar .bar-label { font-size: 12px; color: #666; min-width: 36px; text-align: right; }

/* ===== Approval ===== */
.approval-ring { display: flex; gap: 32px; flex-wrap: wrap; align-items: flex-start; padding: 10px 0; }
.approval-ring .legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; min-width: 200px; }
.approval-ring .legend-item { display: flex; align-items: center; gap: 8px; }
.approval-ring .legend-item .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.approval-ring .legend-item .count { font-weight: 600; margin-left: auto; min-width: 30px; text-align: right; }

.bar-chart-container { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.bar-chart-row { display: flex; align-items: center; gap: 12px; }
.bar-chart-row .label-text { min-width: 80px; font-size: 13px; font-weight: 500; }
.bar-chart-row .bar-track {
    flex: 1; height: 24px; background: #f0f0f0;
    border-radius: 4px; overflow: hidden; display: flex;
}
.bar-chart-row .bar-track .seg { height: 100%; transition: width 0.6s ease; }
.bar-chart-row .bar-track .seg-green { background: #66bb6a; }
.bar-chart-row .bar-track .seg-blue { background: #42a5f5; }
.bar-chart-row .bar-track .seg-orange { background: #ffa726; }
.bar-chart-row .bar-track .seg-red { background: #ef5350; }
.bar-chart-row .bar-track .seg-gray { background: #bdbdbd; }
.bar-chart-row .value-text { font-size: 12px; color: #666; min-width: 80px; text-align: right; }

/* ===== Overdue ===== */
.overdue-cell { color: #c62828; font-weight: 600; }
.task-cell { white-space: normal; word-break: break-word; }
.project-cell { white-space: normal; word-break: break-word; }
.overdue-table td, .overdue-table th { white-space: normal; }
.overdue-days { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 600; }
.overdue-days.critical { background: #ffebee; color: #c62828; }
.overdue-days.warning { background: #fff3e0; color: #e65100; }
.overdue-days.normal { background: #fff8e1; color: #f9a825; }

.status-text { display: inline-flex; align-items: center; gap: 4px; }
.status-text .dot-indicator { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-text .dot-green { background: #2e7d32; }
.status-text .dot-blue { background: #1565c0; }
.status-text .dot-orange { background: #e65100; }
.status-text .dot-red { background: #c62828; }
.status-text .dot-gray { background: #9e9e9e; }

/* ===== Loading / Empty ===== */
.loading { text-align: center; padding: 60px 20px; color: #999; }
.loading .spinner {
    width: 36px; height: 36px; border: 3px solid #e0e0e0;
    border-top-color: #1a73e8; border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px; color: #999; font-size: 13px; }

.fade-in { animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header { padding: 0 16px; }
    .header-left .hamburger { display: block; }
    .header-left .subtitle { display: none; }
    .header-right .time { display: none; }
    .header-right .nav-links a { font-size: 11px; padding: 4px 8px; }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 60px; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.3);
        z-index: 49;
    }
    .sidebar-overlay.show { display: block; }

    .main { margin-left: 0; padding: 16px; }
    .stats { flex-direction: column; }
    .stat-card { min-width: auto; }
    .approval-ring { flex-direction: column; }
    .content-header h2 { font-size: 17px; }
}
/* ===== Owners View: Filters ===== */
.filter-bar {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap; margin-bottom: 16px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.filter-bar label { font-size: 13px; color: #555; font-weight: 500; }
.filter-bar select, .filter-bar input {
    padding: 6px 10px; border: 1px solid #d0d0d0;
    border-radius: 4px; font-size: 13px; background: #fff;
    outline: none; transition: border-color 0.2s;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: #1a73e8; }
.filter-bar .filter-btn {
    padding: 6px 18px; background: #1a73e8; color: #fff;
    border: none; border-radius: 4px; font-size: 13px;
    cursor: pointer; transition: background 0.2s;
}
.filter-bar .filter-btn:hover { background: #1557b0; }

/* ===== Owners View: Grouped Table ===== */
.group-header-row {
    background: #e8f0fe !important;
    font-weight: 700; color: #1a73e8;
}
.group-header-row td {
    padding: 8px 12px; font-size: 13px;
    border-bottom: 2px solid #1a73e8;
}
.group-header-row td .group-badge {
    display: inline-block;
    padding: 2px 12px; border-radius: 10px;
    background: #1a73e8; color: #fff;
    font-size: 11px; margin-left: 8px;
}
table tr.clickable-row { cursor: pointer; }
table tr.clickable-row:hover td { background: #e3f2fd; }
table tr.clickable-row.active-row td { background: #bbdefb; }

/* ===== Owners View: Chart ===== */
.chart-section { margin-top: 20px; }
.chart-section .chart-header {
    display: flex; align-items: center;
    justify-content: space-between; margin-bottom: 12px;
}
.chart-section .chart-header h3 {
    font-size: 16px; font-weight: 600; color: #1a1a1a;
}
.chart-section .chart-header .chart-tips {
    font-size: 12px; color: #888;
}
.chart-container {
    background: #fff; border-radius: 10px;
    padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.chart-container #ownerChart {
    width: 100%; height: 420px;
}
.legend-row {
    display: flex; flex-wrap: wrap; gap: 8px 16px;
    margin: 8px 0 12px; padding: 8px 12px;
    background: #fafafa; border-radius: 6px;
}
.legend-row .legend-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: #555; cursor: pointer;
    padding: 2px 6px; border-radius: 4px;
    transition: background 0.15s;
}
.legend-row .legend-item:hover { background: #f0f0f0; }
.legend-row .legend-item .color-dot {
    width: 10px; height: 10px; border-radius: 50%;
}
.legend-row .legend-item.dimmed { opacity: 0.4; }

@media (max-width: 768px) {
    .filter-bar { flex-direction: column; align-items: stretch; }
    .chart-container #ownerChart { height: 300px; }
}
