* { box-sizing: border-box; }
body { font-family: -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
       margin: 0 auto; max-width: 720px; padding: 16px; color: #1a1a1a; background: #f7f7f5; }
h1 { font-size: 1.6em; margin: 12px 0; }
h2 { font-size: 1.15em; margin: 24px 0 8px; }
nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
nav a { padding: 8px 12px; background: #fff; border: 1px solid #ddd; border-radius: 8px;
        text-decoration: none; color: #1a1a1a; font-size: 0.95em; }
nav a:hover { background: #efefec; }
table { width: 100%; border-collapse: collapse; background: #fff; margin: 8px 0 16px; font-size: 0.95em; }
th, td { padding: 8px; border: 1px solid #e2e2de; text-align: left; vertical-align: top; }
th { background: #f0f0ec; }
tr.group td { background: #e8e8e2; font-weight: 600; }
tr.red td { background: #fde8e8; }
tr.yellow td { background: #fdf6e0; }
tr.green td { background: #eef8ee; }
tr.gray td { color: #888; }
.err { background: #fde8e8; padding: 10px; border-radius: 8px; }
.ok { background: #eef8ee; padding: 10px; border-radius: 8px; }
.banner { padding: 12px; border-radius: 10px; margin-bottom: 12px; }
.warn { background: #fdf6e0; border: 1px solid #eadfa8; }
input, select, textarea, button { font-size: 1em; padding: 8px; border: 1px solid #ccc; border-radius: 8px; }
button { background: #2b6cb0; color: #fff; border: none; cursor: pointer; padding: 10px 18px; }
button:hover { background: #235a94; }
a { color: #2b6cb0; }
.muted { color: #888; font-size: 0.9em; }
@media (max-width: 480px) {
    table { font-size: 0.85em; }
    th, td { padding: 5px; }
}

/* ===== TASK_2: мобильный вид таблиц ===== */
@media (max-width: 640px) {
    table { display: block; width: 100%; }
    table tr { display: block; border-bottom: 1px solid #eee; padding: 8px 4px; }
    table td { display: flex; justify-content: space-between; gap: 12px;
               padding: 4px 0; border: none; text-align: right; }
    table td::before { content: attr(data-label); font-weight: 600; color: #777; white-space: nowrap; }
    table td:first-child { text-align: left; justify-content: flex-start; font-weight: 600; }
    table th { display: none; }
    tr.group td { justify-content: center; background: #e8e8e2; border-radius: 6px; }
}

/* ===== TASK_3: карточки узлов и группы ===== */
.node-group { background: #fff; border: 1px solid #e2e2de; border-radius: 10px; margin: 8px 0; overflow: hidden; }
.node-group > summary { padding: 10px 12px; font-weight: 600; cursor: pointer; background: #f7f7f5; }
.node-group[open] > summary { border-bottom: 1px solid #eee; }
.badge { display: inline-block; min-width: 20px; text-align: center; border-radius: 10px;
         padding: 1px 8px; font-size: 0.8em; color: #fff; margin-left: 6px; }
.badge.b-red { background: #d9534f; }
.badge.b-yellow { background: #e0a800; }
.node-card { border: 1px solid #e2e2de; border-left: 4px solid #ccc; border-radius: 8px;
             margin: 10px; padding: 10px 12px; background: #fff; }
.node-card.st-red { border-left-color: #d9534f; background: #fdf1f1; }
.node-card.st-yellow { border-left-color: #e0a800; background: #fdf8ec; }
.node-card.st-green { border-left-color: #4a9a4a; background: #f1f8f1; }
.node-card.st-gray { border-left-color: #ccc; }
.nc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.nc-name { font-weight: 600; }
.nc-status { font-size: 0.85em; font-weight: 600; padding: 2px 10px; border-radius: 10px; white-space: nowrap; }
.nc-status.st-red { background: #d9534f; color: #fff; }
.nc-status.st-yellow { background: #e0a800; color: #fff; }
.nc-status.st-green { background: #4a9a4a; color: #fff; }
.nc-status.st-gray { background: #eee; color: #888; }
.nc-row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.95em; padding: 2px 0; }

/* ===== TASK_4: закрытие пробелов (только добавления) ===== */

/* Ширина контейнера по ТЗ: 600px (переопределяет 720px без правки старой строки) */
body { max-width: 600px; }

/* Блок «⚙️ Настройка интервалов» — оформление как у групп TASK_3 */
.iv-box { background: #fff; border: 1px solid #e2e2de; border-radius: 10px; margin: 8px 0 16px; overflow: hidden; }
.iv-box > summary { display: flex; align-items: center; padding: 10px 12px;
                    min-height: 48px; font-weight: 600; cursor: pointer; }
.iv-box[open] > summary { border-bottom: 1px solid #eee; }

/* Тап-зоны ≥ 48px у всех интерактивных элементов */
.node-group > summary { min-height: 48px; display: flex; align-items: center; }
nav a { min-height: 48px; display: inline-flex; align-items: center; box-sizing: border-box; }
button { min-height: 48px; box-sizing: border-box; }

/* Инпуты: шрифт ≥16px (нет iOS-зума), тап-зона 48px */
.iv-box input[type="number"] { font-size: 16px; min-height: 48px; }
@media (max-width: 640px) {
    .iv-box table td { align-items: center; }
    .iv-box input[type="number"] { width: auto !important; flex: 1; min-width: 96px; max-width: 60%; }
}

/* ===== TASK_5: кнопка «Заменено сегодня» на карточке ===== */
.nc-form { margin-top: 8px; }
.nc-form button { padding: 6px 12px; font-size: 0.9em; background: #fff;
                  color: #2b6cb0; border: 1px solid #2b6cb0; }
.nc-form button:hover { background: #eaf2fb; }

/* ===== TASK_5b: компактный мобильный вид журнала ===== */
@media (max-width: 640px) {
    /* ячейки без подписей (журнал): влево и плотнее */
    table td:not([data-label]) { text-align: left; justify-content: flex-start; }
    table td { padding: 2px 0; font-size: 0.92em; }
    table tr { padding: 6px 2px; }
}

/* ===== TASK_6: фильтр и сортировка журнала ===== */
.jfilter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.jfilter select { flex: 1; min-width: 160px; font-size: 16px; min-height: 48px; }
.jfilter button { flex: 0 0 auto; }
.sortrow { font-size: 0.95em; margin: 4px 0 8px; }

.delbtn{background:none;border:none;color:#b02020;font-size:18px;line-height:1;padding:2px 8px;cursor:pointer}
.danger{background:#b02020;color:#fff}

.setgrid{display:grid;gap:14px}
.setcard{display:block;background:#fff;border:1px solid #e3e5ea;border-radius:12px;padding:16px 18px;text-decoration:none;color:inherit}
.setcard:hover{border-color:#9aa3b2}
.setcard h2{margin:0 0 6px;font-size:18px}
.setcard p{margin:0;color:#5b6270;font-size:14px}

.editbtn{color:#1a5fb4;text-decoration:none;font-size:16px;padding:2px 6px}

/* Мигание статусов: жёлтый — спокойно, красный — настойчиво */
.st-yellow .nc-status { animation: statusPulse 1.6s ease-in-out infinite; }
.st-red    .nc-status { animation: statusPulse 0.7s ease-in-out infinite; }
@keyframes statusPulse { 50% { opacity: 0.3; } }
