:root {
    --bg: #f5f7ff; --surface: rgba(255,255,255,0.72); --line: rgba(0,0,0,0.06);
    --text: #1a1a2e; --text-soft: #6b7280; --text-muted: #9ca3af;
    --blue: #5b6cf0; --violet: #8b5cf6; --green: #22c55e; --amber: #f59e0b; --red: #ef4444;
    --radius-lg: 18px; --radius-md: 14px; --radius-sm: 10px; --shadow: 0 2px 12px rgba(0,0,0,0.04);
    --sidebar-width: 260px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7ff 0%, #f0f2fe 30%, #faf5ff 60%, #f5f0fe 100%);
    color: var(--text); min-height: 100vh; min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}
.app { display: flex; min-height: 100vh; min-height: 100dvh; position: relative; }

.sidebar {
    width: var(--sidebar-width); min-width: var(--sidebar-width);
    background: rgba(255,255,255,0.55); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--line); padding: 20px 14px;
    display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
    position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: 50; transition: transform 0.3s ease;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 40; backdrop-filter: blur(2px); }
.sidebar-overlay.show { display: block; }
.logo { padding: 0 8px 16px; font-size: 13px; font-weight: 800; color: var(--blue); letter-spacing: 1px; }
.nav-section { font-size: 10px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 12px 8px 4px; }
.nav-btn {
    width: 100%; text-align: left; border: none; cursor: pointer;
    border-radius: var(--radius-sm); padding: 11px 14px;
    background: transparent; color: var(--text-soft);
    display: flex; align-items: center; gap: 10px;
    font: inherit; font-size: 13px; font-weight: 600; transition: 0.15s;
    min-height: 44px;
}
.nav-btn:hover { background: rgba(91,108,240,0.06); color: var(--text); }
.nav-btn.active { background: var(--blue); color: #fff; }
.nav-icon { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }

.main { flex: 1; min-width: 0; padding: 20px 24px; overflow-y: auto; max-height: 100vh; max-height: 100dvh; }
.page { display: none; } .page.active { display: block; }
.page-title { font-size: clamp(18px, 3vw, 22px); font-weight: 800; margin-bottom: 4px; }
.page-subtitle { font-size: clamp(11px, 1.5vw, 13px); color: var(--text-muted); margin-bottom: 18px; }

.topbar {
    display: none; align-items: center; gap: 12px;
    padding: 12px 16px; background: rgba(255,255,255,0.7);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 30;
}
.burger-btn {
    width: 44px; height: 44px; border-radius: 12px;
    background: rgba(255,255,255,0.6); border: 1px solid var(--line);
    font-size: 22px; cursor: pointer; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 800; flex: 1; text-align: center; }

.bottombar {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: rgba(255,255,255,0.8); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--line);
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    justify-content: space-around; align-items: center;
}
.bottombar-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 12px; border-radius: 14px; cursor: pointer;
    border: none; background: transparent; font: inherit;
    color: var(--text-soft); font-size: 10px; font-weight: 600;
    transition: 0.15s; min-width: 56px;
}
.bottombar-btn.active { color: var(--blue); }
.bottombar-btn .icon { font-size: 20px; }

.card {
    background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-lg); padding: clamp(14px, 2vw, 18px);
    border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 14px;
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: clamp(13px, 1.8vw, 15px); font-weight: 700; word-break: break-word; }
.card-clickable { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.card-clickable:active { transform: scale(0.98); }

.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 18px; }
.kpi-card { text-align: center; }
.kpi-card .icon { font-size: clamp(16px, 2vw, 20px); }
.kpi-card .value { font-size: clamp(18px, 2.5vw, 24px); font-weight: 800; }
.kpi-card .label { font-size: clamp(9px, 1.2vw, 10px); color: var(--text-muted); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.grid-responsive { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

.badge {
    display: inline-block; padding: 4px 10px; border-radius: 8px;
    font-size: clamp(9px, 1.1vw, 10px); font-weight: 700; white-space: nowrap;
}
.badge-done { background: #e8f5e9; color: #2e7d32; }
.badge-work { background: var(--blue); color: #fff; }
.badge-planned { background: #e0f0ff; color: #2563eb; }
.badge-critical { background: var(--red); color: #fff; }
.badge-high { background: var(--amber); color: #fff; }
.badge-dev { background: #ede9fe; color: #7c3aed; }
.badge-test { background: #fef3c7; color: #92400e; }
.badge-prod { background: #e8f5e9; color: #2e7d32; border: 1px solid #2e7d32; }
.badge-online { background: #e8f5e9; color: #2e7d32; }
.badge-offline { background: #f3f4f6; color: #6b7280; }
.badge-synced { background: #e8f5e9; color: #2e7d32; }
.badge-desynced { background: #fff8e1; color: #92400e; }
.badge-conflict { background: #ffebee; color: #b91c1c; }
.badge-tag { background: #eef1ff; color: #4a5de0; font-size: 9px; padding: 2px 8px; border-radius: 6px; }
.badge-release-ready { background: var(--green); color: #fff; font-size: 13px; padding: 6px 16px; }
.badge-release-almost { background: var(--amber); color: #fff; font-size: 13px; padding: 6px 16px; }
.badge-release-no { background: var(--red); color: #fff; font-size: 13px; padding: 6px 16px; }

.btn {
    border: none; cursor: pointer; border-radius: var(--radius-sm);
    padding: 10px 16px; font: inherit; font-size: clamp(11px, 1.3vw, 12px);
    font-weight: 700; transition: 0.15s; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-ghost { background: rgba(0,0,0,0.04); color: var(--text-soft); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 11px; min-height: 36px; }
.btn-block { width: 100%; }
.btn:active { transform: scale(0.96); }

.list-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: clamp(12px, 1.5vw, 13px); gap: 10px; flex-wrap: wrap;
}
.list-item .title { font-weight: 700; word-break: break-word; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: clamp(11px, 1.3vw, 12px); font-weight: 700; color: var(--text-soft); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px 14px; border-radius: 10px;
    border: 1px solid var(--line); font: inherit; font-size: clamp(13px, 1.5vw, 14px);
    background: rgba(255,255,255,0.8); min-height: 48px;
}

.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    z-index: 100; justify-content: center; align-items: flex-end;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff; border-radius: 24px 24px 0 0;
    padding: 24px 20px max(24px, env(safe-area-inset-bottom));
    width: 100%; max-height: 85vh; max-height: 85dvh;
    overflow-y: auto; box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
}
.modal h3 { font-size: clamp(16px, 2vw, 18px); font-weight: 800; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; min-width: 100px; }

.toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    z-index: 200; background: var(--text); color: #fff;
    padding: 12px 24px; border-radius: 14px; font-size: 13px; font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    opacity: 0; transition: 0.3s ease; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-10px); }

.diff-container { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 14px; }
.diff-unified {
    font-family: 'SF Mono', 'Fira Code', monospace; font-size: clamp(9px, 1.1vw, 11px);
    line-height: 1.7; padding: 14px; background: #fdfdfd;
    max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.diff-line { padding: 1px 8px; margin: 0 -8px; border-radius: 3px; }
.diff-line.added { background: #e6ffec; color: #137333; }
.diff-line.removed { background: #ffebe9; color: #b91c1c; }
.diff-stats { display: flex; gap: 16px; font-size: clamp(10px, 1.2vw, 12px); margin-bottom: 12px; flex-wrap: wrap; }
.diff-stats .added { color: var(--green); font-weight: 700; }
.diff-stats .removed { color: var(--red); font-weight: 700; }

.check-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    border-radius: 14px; margin-bottom: 8px; font-size: clamp(12px, 1.4vw, 13px);
}
.check-pass { background: #e8f5e9; color: #2e7d32; }
.check-fail { background: #ffebee; color: #b91c1c; }
.check-warn { background: #fff8e1; color: #92400e; }
.check-icon { font-size: 20px; flex-shrink: 0; }

.progress-bar { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--blue), var(--violet)); }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.online { background: var(--green); }
.status-dot.offline { background: #ccc; }

@media (max-width: 1024px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .topbar { display: flex; }
    .main { padding: 16px; padding-bottom: 80px; }
    .kpi-grid { grid-template-columns: repeat(2,1fr); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .bottombar { display: flex; }
}
@media (min-width: 1025px) {
    .sidebar { position: sticky; top: 0; transform: translateX(0) !important; }
    .sidebar-overlay { display: none !important; }
    .topbar { display: none; }
    .main { padding: 20px 24px 24px; }
    .bottombar { display: none; }
    .modal { border-radius: var(--radius-lg); max-width: 680px; margin: auto; }
    .modal-overlay { align-items: center; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .card { padding: 14px; margin-bottom: 10px; }
    .btn { width: 100%; }
    .btn-sm { width: auto; }
}
