:root {
  --bg-color: #f4f6f9;
  --card-bg: #ffffff;
  --border-color: #dcdfe6;
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --danger-color: #ef4444;
  --success-color: #10b981;
  --text-main: #1f2937;
  --text-muted: #6b7280;
}

* { box-sizing: border-box; margin: 0; padding: 0; touch-action: manipulation; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
body { background-color: var(--bg-color); color: var(--text-main); user-select: none; overflow: hidden; }

.app-container { display: flex; height: 100vh; width: 100%; }

.sidebar { width: 220px; background: #ffffff; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; flex-shrink: 0; position: relative; z-index: 100; transition: transform 0.3s; }
.sidebar-brand { font-size: 1.3rem; font-weight: 800; padding: 16px; border-bottom: 1px solid var(--border-color); color: #111827; text-align: center; }
.nav-menu { flex: 1; padding-top: 8px; overflow-y: auto; overflow-x: hidden; }

.nav-tab { width: 100%; padding: 12px 16px; padding-right: 24px; background: none; border: none; color: var(--text-muted); font-size: 1rem; font-weight: 600; text-align: left; cursor: pointer; border-left: 3px solid transparent; white-space: nowrap; }
.nav-tab:hover { background: #f3f4f6; color: var(--text-main); }
.nav-tab.active { color: var(--primary-color); border-left-color: var(--primary-color); background: #eff6ff; }

.btn-edit-toggle { margin: 12px; padding: 10px; border-radius: 6px; border: 2px solid var(--border-color); background: #f9fafb; font-weight: bold; cursor: pointer; color: var(--text-muted); transition: all 0.2s; white-space: normal; text-align: center; line-height: 1.2; }
.btn-edit-toggle.active { border-color: var(--danger-color); color: var(--danger-color); background: #fef2f2; }
/* мигаем замком, когда пользователь пытается тащить карточку с выключенным режимом */
.btn-edit-toggle.attention { animation: edit-toggle-pulse 0.5s ease-in-out 3; }
@keyframes edit-toggle-pulse {
  0%, 100% { transform: scale(1); border-color: var(--border-color); }
  50% { transform: scale(1.05); border-color: var(--primary-color); }
}

/* Сворачивание левого меню — освобождает ширину под доску */
.btn-sidebar-collapse {
  position: absolute; top: 18px; right: -11px; z-index: 120;
  width: 22px; height: 22px; padding: 0; line-height: 20px; text-align: center;
  border: 1px solid var(--border-color); border-radius: 50%; background: #fff;
  color: var(--text-muted); font-size: 0.95rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12); transition: color 0.2s, border-color 0.2s;
}
.btn-sidebar-collapse:hover { color: var(--primary-color); border-color: var(--primary-color); }
.sidebar { transition: width 0.2s ease; }
.sidebar.collapsed { width: 0; border-right: none; overflow: visible; }
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-menu { display: none; }
.sidebar.collapsed .btn-sidebar-collapse { right: -26px; }
/* замок редактирования остаётся достижимым и при свёрнутом меню —
   иначе перетаскивание нечем включить */
.sidebar.collapsed .btn-edit-toggle {
  position: fixed; left: 8px; bottom: 12px; width: 42px; height: 42px;
  margin: 0; padding: 0; border-radius: 50%; font-size: 1.1rem; line-height: 1;
  overflow: hidden; white-space: nowrap; text-indent: -999px; z-index: 130;
}
.sidebar.collapsed .btn-edit-toggle::before {
  content: '🔒'; position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; text-indent: 0;
}
.sidebar.collapsed .btn-edit-toggle.active::before { content: '🔓'; }

.main-content { flex: 1; display: flex; flex-direction: column; position: relative; overflow: hidden; padding: 12px; }
.tab-content { display: none; margin-top: 0; height: 100%; flex-direction: column; }
.tab-content.active { display: flex; }

.tab-content:not(#plannerView) { overflow: hidden; padding-bottom: 0; }
.tab-content:not(#plannerView) .card { display: flex; flex-direction: column; height: calc(100vh - 24px); margin-bottom: 0; overflow: hidden; }
.tab-content:not(#plannerView) .card .table-responsive { flex: 1; overflow-y: auto; }

.layout-wrapper { display: flex; width: 100%; height: 100%; overflow: hidden; align-items: stretch; gap: 12px; }

.schedule-area { flex: 1; display: flex; flex-direction: column; overflow: auto; min-width: 0; align-items: center; padding: 0; background: transparent; }
.schedule-wrapper { display: flex; flex-direction: column; width: max-content; margin: 0 auto; position: relative; }

/* Ручка растягивания доски: тянуть — менять ширину колонок-дней вместе с карточками */
.board-resizer {
  position: absolute; top: 0; bottom: 0; right: -10px; width: 10px; z-index: 20;
  cursor: col-resize; border-radius: 4px; background: transparent; transition: background-color 0.2s;
}
.board-resizer::after {
  content: ''; position: absolute; top: 50%; left: 3px; width: 4px; height: 48px;
  margin-top: -24px; border-radius: 2px; background: var(--border-color); transition: background-color 0.2s;
}
.board-resizer:hover::after, .board-resizer.resizing::after { background: var(--primary-color); }
.board-resizer.resizing { background: rgba(59, 130, 246, 0.12); }
.schedule-inner { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 0 8px 8px 8px; padding: 12px; width: max-content; position: relative; z-index: 1; }

.lines-tabs-container { display: flex; gap: 4px; margin-bottom: 0; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; position: relative; z-index: 2; }
.lines-tabs-container::-webkit-scrollbar { display: none; }
.line-tab { display: flex; align-items: center; gap: 8px; padding: 6px 16px; background: #f1f5f9; border: 1px solid var(--border-color); border-radius: 6px 6px 0 0; cursor: pointer; font-weight: 600; color: var(--text-muted); transition: background 0.2s; position: relative; top: 1px; }
.line-tab.active { background: var(--card-bg); color: var(--primary-color); border-bottom-color: var(--card-bg); }
.line-tab:hover:not(.active) { background: #e2e8f0; }

.shipment-tab { margin-left: auto; background: #e0f2fe; border-color: #bae6fd; color: #0369a1; }
.shipment-tab.active { background: var(--card-bg); color: var(--primary-color); border-color: var(--border-color); border-bottom-color: var(--card-bg); }

.btn-line-settings { background: none; border: none; cursor: pointer; font-size: 1rem; opacity: 0.5; padding: 0; display: flex; align-items: center; justify-content: center; transition: opacity 0.2s; }
.btn-line-settings:hover { opacity: 1; }
.btn-add-line { background: #e0f2fe; border: 1px dashed #7dd3fc; color: #0284c7; padding: 6px 12px; border-radius: 6px 6px 0 0; cursor: pointer; font-weight: bold; position: relative; top: 1px; border-bottom: 1px solid var(--border-color); }

.resizer { width: 6px; background-color: transparent; cursor: col-resize; flex-shrink: 0; transition: background-color 0.2s; z-index: 10; border-radius: 4px; }
.resizer:hover, .resizer.resizing { background-color: var(--primary-color); }

.right-sidebar { width: calc(var(--day-col-width, 170px) + 17px); min-width: 0; background: transparent; display: flex; flex-direction: column; gap: 12px; flex-shrink: 0; overflow-y: auto; overflow-x: hidden; }
.user-profile-block { display: flex; flex-direction: column; align-items: stretch; padding: 12px; background: #fff; border-radius: 8px; border: 1px solid var(--border-color); box-shadow: 0 2px 6px rgba(0,0,0,0.03); text-align: center; flex-shrink: 0; }
.user-name-text { font-size: 0.9rem; font-weight: 700; margin-bottom: 8px; color: #1f2937; word-break: break-word; }

.unified-sidebar-block { background: #fff; border-radius: 8px; border: 1px solid var(--border-color); box-shadow: 0 2px 6px rgba(0,0,0,0.03); display: flex; flex-direction: column; }
.native-accordion { background: transparent; border: none; border-bottom: 1px solid var(--border-color); transition: background 0.2s; }
.unified-sidebar-block .native-accordion:last-child { border-bottom: none; }
.native-accordion summary { padding: 12px 16px; font-weight: 600; font-size: 0.85rem; background: #f8fafc; cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; list-style: none; }
.native-accordion summary::-webkit-details-marker { display: none; }
.native-accordion summary::after { content: "▼"; font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s; }
.native-accordion:not([open]) summary::after { transform: rotate(-90deg); }
.accordion-content { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }

.badge-count { background: #cbd5e1; font-size: 0.85rem; padding: 2px 8px; border-radius: 12px; color: #1e293b; margin-left: auto; margin-right: 8px; font-weight: 700; transition: background 0.3s, color 0.3s; }
.badge-count.badge-buffer { background: #3b82f6; color: #ffffff; }
.badge-count.badge-unassigned { background: #ef4444; color: #ffffff; }

.drop-highlight { background-color: #f0fdf4 !important; box-shadow: inset 0 0 0 3px var(--primary-color) !important; border-radius: 0 0 8px 8px; }
.drop-highlight-summary { background-color: #f0fdf4 !important; box-shadow: inset 0 0 0 3px var(--primary-color) !important; border-radius: 8px; }

.buffer-list, .unassigned-list-vertical, .buffer-generators, .full-buffer-list, .full-unassigned-list { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 16px; align-items: flex-start; }
.week-title { font-size: 1rem; font-weight: 700; margin: 0 0 8px 0; color: #111827; }

.week-table { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; display: flex; flex-direction: row; width: max-content; min-width: max-content; overflow: hidden; }
.week-content-box { display: flex; flex-direction: column; }
.week-sidebar { width: 40px; background: #f1f5f9; border-right: 1px solid var(--border-color); display: flex; align-items: flex-start; justify-content: center; flex-shrink: 0; }
.week-sidebar-text { writing-mode: vertical-rl; transform: rotate(180deg); padding-bottom: 12px; font-size: 0.85rem; font-weight: 700; color: #334155; }

.table-header { display: flex; background: #f1f5f9; border-bottom: 1px solid var(--border-color); }
.day-header-cell { flex: 0 0 var(--day-col-width, 170px); width: var(--day-col-width, 170px); max-width: var(--day-col-width, 170px); padding: 6px 2px; text-align: center; font-weight: 700; font-size: 0.75rem; border-right: 1px solid var(--border-color); color: #334155; box-sizing: border-box; }
.day-header-cell.weekend { background-color: #e2e8f0; }
.table-body { display: flex; position: relative; }
.days-columns { display: flex; flex: 1; position: relative; }
.day-column { flex: 0 0 var(--day-col-width, 170px); width: var(--day-col-width, 170px); max-width: var(--day-col-width, 170px); position: relative; display: flex; flex-direction: column; gap: 4px; padding: 4px; min-height: 400px; border-right: 1px solid var(--border-color); background: #fdfdfd; box-sizing: border-box; }
/* The first week reserves exactly one card after its longest day. */
#week-1-table .week-sidebar { position: relative; }
#week-1-table .week-sidebar-text { position: absolute; max-height: 100%; box-sizing: border-box; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#week-1-table .day-column { min-height: 0; }
#week-1-table .day-column:not(:has(> .placement-ghost))::after {
    content: ''; display: block; flex: 0 0 100px;
}
.day-column.weekend { background-color: rgba(226, 232, 240, 0.3); }

.order-card { 
    position: relative; width: 160px !important; min-width: 160px !important; max-width: 160px !important; 
    height: 100px; min-height: 100px; max-height: 100px; flex-shrink: 0; margin: 0 !important; padding: 4px 6px; 
    background: #bbf7d0; border: 2px solid #4ade80; color: #14532d; border-radius: 4px; font-size: 0.65rem; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.08); display: flex; flex-direction: column; justify-content: space-between; 
    overflow: hidden; touch-action: none; transition: z-index 0.1s, transform 0.1s; box-sizing: border-box; 
    cursor: default; user-select: none; -webkit-user-drag: none;
}
/* Sidebar cards match the day column content width (8px padding + 1px border). */
#buffer-container .order-card,
#unassigned-container .order-card {
    width: calc(var(--day-col-width, 170px) - 9px) !important;
    min-width: calc(var(--day-col-width, 170px) - 9px) !important;
    max-width: calc(var(--day-col-width, 170px) - 9px) !important;
}
#buffer-container, #unassigned-container { overflow-x: auto; }
/* Board cards fill the day column. */
.day-column .order-card,
.day-column .standalone-break {
    width: 100% !important; min-width: 0 !important; max-width: 100% !important; margin: 0 !important;
}

.grouped-item {
    border: 2px dashed #8b5cf6 !important;
    background-color: #ede9fe !important;
}

.day-column .grouped-item {
    border: 2px dashed #22c55e !important;
    background-color: #a7f3d0 !important;
}
.day-column .grouped-item.split-order-card {
    border: none !important;
    background-color: transparent !important;
}
.day-column .grouped-item.split-order-card > .split-section {
    border: 2px dashed #22c55e !important;
    background-color: #a7f3d0 !important;
}

.unassigned-list-vertical .grouped-item, .full-unassigned-list .grouped-item {
    border: 2px dashed #ef4444 !important;
    background-color: #fecaca !important;
    color: #7f1d1d;
}

.buffer-list .grouped-item, .full-buffer-list .grouped-item {
    border: 2px dashed #38bdf8 !important;
    background-color: #bae6fd !important;
    color: #0369a1;
}

body.edit-mode-on .order-card { cursor: grab; }
body.edit-mode-on .order-card:active, .order-card.dragging-active { cursor: grabbing !important; }

body.edit-mode-on .order-card.related-hover { z-index: 30 !important; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important; }

.drag-clone-container {
    position: fixed !important;
    z-index: 999999 !important;
    pointer-events: none;
    opacity: 0.95;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4) !important;
    transform: scale(1.02);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.split-order-card { min-height: 100px; height: auto !important; max-height: none !important; padding: 0 !important; display: flex; flex-direction: column; gap: 0; background: transparent !important; border: none !important; }
.split-order-card > .split-section { background: #bbf7d0; border: 2px solid #4ade80; border-radius: 4px; padding: 4px 6px; display: flex; flex-direction: column; justify-content: space-between; box-sizing: border-box; height: 100px !important; min-height: 100px !important; max-height: 100px !important; }
.split-order-card > .sys-split-section { background: #e2e8f0; border: 2px solid #cbd5e1; color: #334155; height: 52px !important; min-height: 52px !important; max-height: 52px !important; }
.split-order-card > .split-break { height: 30px; flex-shrink: 0; background: #e2e8f0; border-left: 2px dashed #94a3b8; border-right: 2px dashed #94a3b8; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: bold; color: #475569; box-sizing: border-box; margin: 2px 0; }
.standalone-break { height: 30px; flex-shrink: 0; background: #e2e8f0; border-left: 2px dashed #94a3b8; border-right: 2px dashed #94a3b8; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: bold; color: #475569; box-sizing: border-box; margin: 0 auto; width: 160px; border-radius: 4px; }

.order-card.system-event { background: #e2e8f0; border-color: #cbd5e1; color: #334155; height: 52px !important; min-height: 52px !important; max-height: 52px !important; display: flex; flex-direction: column; align-items: stretch; justify-content: center; padding: 4px 6px; }
.sys-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.sys-top-row .gen-title { font-weight: 700; font-size: 0.9rem; }
.sys-top-row .gen-duration { font-weight: 600; font-size: 0.75rem; opacity: 0.8; }
.order-card.system-event .order-time-line { font-size: 0.75rem; text-align: left; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block !important; }

.order-card.overflow-warning { background-color: #fce7f3 !important; border-color: #f43f5e !important; color: #881337 !important; }
.unassigned-list-vertical .order-card, .full-unassigned-list .order-card { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.buffer-list .order-card, .full-buffer-list .order-card { background: #e0f2fe; border-color: #7dd3fc; color: #0369a1; }
.unassigned-list-vertical .order-time-line, .buffer-list .order-time-line, .full-unassigned-list .order-time-line, .full-buffer-list .order-time-line { display: none !important; }

.order-card.dragging-active { opacity: 0.4; z-index: 50 !important; cursor: grabbing !important; }
.order-card.drag-clone { position: fixed !important; z-index: 999999 !important; opacity: 0.95; pointer-events: none; box-shadow: 0 10px 25px rgba(0,0,0,0.3) !important; transform: scale(1.02); margin: 0 !important; }

.order-dim-line { font-size: 0.85rem; font-weight: 600; color: inherit; display: flex; justify-content: space-between; align-items: center; margin-bottom: 0; width: 100%; overflow: hidden; }
.order-dim-line > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.order-cust-line { font-size: 0.65rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; color: inherit; width: 100%; display: block; }
.order-time-line { font-size: 0.75rem; font-weight: 700; margin: 2px 0; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; width: 100%; }

.order-sub-line { 
    font-size: 0.65rem; 
    opacity: 0.9; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-top: auto; 
    padding-top: 2px; 
    width: 100%; 
    position: relative; 
}
.order-sub-line > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 4px; }
.order-sub-line > span:last-child { white-space: nowrap; flex-shrink: 0; }

.card-tooltip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: #1e293b; color: #f8fafc; padding: 10px 14px; border-radius: 8px; font-size: 0.75rem; width: 220px; box-shadow: 0 6px 16px rgba(0,0,0,0.3); pointer-events: none; opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0.2s ease; z-index: 1000; line-height: 1.4; }
.card-tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; margin-left: -6px; border-width: 6px; border-style: solid; border-color: #1e293b transparent transparent transparent; }
.order-card:not(.system-event):hover .card-tooltip { opacity: 1; visibility: visible; transition-delay: 2s; }
.tt-row { display: flex; justify-content: space-between; margin-bottom: 4px; gap: 8px; }
.tt-row span { color: #94a3b8; white-space: nowrap; }
.tt-row b { text-align: right; word-break: break-word; color: #ffffff; }

.table-responsive { width: 100%; overflow-x: auto; margin-top: 10px; }
.excel-table-wrapper { width: 100%; overflow-x: auto; }
.excel-table { width: 100%; border-collapse: collapse; margin: 0; min-width: 600px; }
.excel-table th, .excel-table td { border: 1px solid #dcdfe6; padding: 0; text-align: left; }
.excel-table th { background: #f9fafb; padding: 10px; font-size: 0.8rem; font-weight: 600; }
.excel-table input { width: 100%; height: 100%; border: none; padding: 10px; outline: none; background: transparent; font-size: 0.85rem; font-weight: 600; }
.excel-table input:focus { background: #eff6ff; box-shadow: inset 0 0 0 2px var(--primary-color); }
.excel-row-actions { display: flex; justify-content: center; align-items: center; padding: 4px; height: 100%; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.btn-action { padding: 4px 8px; border-radius: 4px; border: none; cursor: pointer; font-size: 0.95rem; display: flex; align-items: center; justify-content: center; transition: opacity 0.2s, background-color 0.2s; }
.btn-action:hover { opacity: 0.8; }
.btn-unassigned { background-color: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; }
.btn-buffer { background-color: #e0f2fe; border: 1px solid #7dd3fc; color: #0369a1; }
.btn-delete { background-color: #f1f5f9; border: 1px solid #cbd5e1; color: #334155; }

.context-menu { position: fixed; background: white; border: 1px solid #cbd5e1; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 10000; overflow: hidden; padding: 4px 0; min-width: 150px; }
.context-menu-item { padding: 8px 16px; font-size: 0.85rem; font-weight: 500; cursor: pointer; color: #1e293b; transition: background 0.1s; }
.context-menu-item:hover { background: #f1f5f9; color: var(--primary-color); }

.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1e293b; color: #fff; padding: 12px 16px; border-radius: 6px; font-size: 0.85rem; box-shadow: 0 4px 12px rgba(0,0,0,0.2); border-left: 4px solid var(--primary-color); animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.card { background: #ffffff; border-radius: 6px; padding: 16px; margin-bottom: 16px; border: 1px solid var(--border-color); }
.card h2 { margin-bottom: 12px; font-size: 1.1rem; }

table:not(.excel-table):not(.matrix-table):not(.compact-orders-table) { width: 100%; border-collapse: collapse; min-width: 600px; font-size: 0.8rem; }
table:not(.excel-table):not(.matrix-table):not(.compact-orders-table) th, 
table:not(.excel-table):not(.matrix-table):not(.compact-orders-table) td { padding: 6px 8px; border-bottom: 1px solid var(--border-color); text-align: left; }

table.compact-orders-table { width: auto !important; max-width: 100%; min-width: unset !important; border-collapse: collapse; border: 1px solid var(--border-color); }
table.compact-orders-table th, table.compact-orders-table td { padding: 6px 12px; border: 1px solid var(--border-color) !important; white-space: nowrap; font-size: 0.8rem; }
table.compact-orders-table th { background-color: #f1f5f9; font-weight: 700; color: #1e293b; }
table.compact-orders-table tbody tr:nth-child(odd) { background-color: #ffffff; }
table.compact-orders-table tbody tr:nth-child(even) { background-color: #f8fafc; }
table.compact-orders-table tbody tr:hover { background-color: #eff6ff; }

.badge-product-type { display: inline-block; padding: 2px 6px; border-radius: 4px; background: #f1f5f9; border: 1px solid #cbd5e1; font-weight: 700; font-size: 0.75rem; color: #334155; }

.matrix-table { width: auto; border-collapse: collapse; margin: 0 auto; border: 2px solid #cbd5e1; background: #ffffff; }
.matrix-table th, .matrix-table td { border: 1px solid #cbd5e1; text-align: center; padding: 0; }
.matrix-corner { background: #f1f5f9; font-weight: 800; font-size: 0.9rem; padding: 10px 16px !important; color: #1e293b; }
.matrix-group-header { background: #e2e8f0; font-weight: 800; font-size: 0.95rem; padding: 8px !important; color: #0f172a; }
#dryingHumidityHeaders th { background: #f8fafc; font-weight: 700; font-size: 0.9rem; width: 90px; padding: 8px !important; color: #334155; }
.matrix-thickness-cell { background: #f8fafc; font-weight: 800; font-size: 0.95rem; padding: 8px 16px !important; color: #334155; width: 100px; }
.matrix-table input { width: 100%; height: 100%; border: none; padding: 10px; outline: none; text-align: center; font-size: 1rem; font-weight: 600; background: transparent; transition: background-color 0.2s, color 0.2s, box-shadow 0.2s; }
.matrix-table input:focus { background: #eff6ff; box-shadow: inset 0 0 0 2px var(--primary-color); }
.matrix-table td.cell-unsaved { background-color: #dbeafe !important; }
.matrix-table td.cell-unsaved input { background-color: #dbeafe !important; color: #1d4ed8 !important; font-weight: 800 !important; }

.nowrap-cell { white-space: nowrap; }
.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group input, .input-group select { padding: 6px 8px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 0.9rem; }
.prefix-select { padding: 6px 8px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 0.85rem; }
.btn-info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; padding: 6px 12px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.btn-save { background: var(--primary-color); color: #fff; border: none; padding: 6px 14px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.btn-icon { background: none; border: none; font-size: 1rem; cursor: pointer; padding: 2px 4px; border-radius: 4px; transition: background 0.1s; }
.btn-icon:hover { background: #f3f4f6; }
.btn-pass-toggle { position: absolute; right: 6px; background: #f3f4f6; border: 1px solid var(--border-color); border-radius: 3px; padding: 2px 6px; cursor: pointer; font-size: 0.7rem; font-weight: 600; }
.badge-role { background: #e5e7eb; color: #374151; font-size: 0.7rem; padding: 2px 6px; border-radius: 12px; font-weight: bold; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal-content { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.15); max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn-modal { padding: 6px 12px; border: none; border-radius: 4px; cursor: pointer; font-weight: 600; }
.btn-cancel { background: #f3f4f6; color: #374151; }
.unsaved-row td { background-color: #d1fae5 !important; transition: background-color 0.3s; }
.unsaved-row input { font-weight: 700; color: #065f46; }

.btn-guest-login { display: none; position: fixed; top: 16px; right: 16px; z-index: 1000; background: var(--primary-color); color: #fff; border: none; padding: 10px 16px; border-radius: 6px; font-size: 0.9rem; font-weight: 600; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.15); transition: background 0.2s; }
.btn-guest-login:hover { background: var(--primary-hover); }

body.guest-mode .sidebar { display: none; }
body.guest-mode .right-sidebar { display: none !important; }
body.guest-mode .resizer { display: none !important; }
body.guest-mode .btn-guest-login { display: block; }
body.guest-mode .main-content { padding-bottom: 16px; margin-left: 0; }
body.guest-mode .tab-content { margin-top: 10px; }

.linked-multi-day-order { border-color: #8b5cf6 !important; }
.linked-multi-day-order.split-order-card > .split-section { border-color: #8b5cf6 !important; }

.humidity-badge { background: #dbeafe; color: #1e40af; padding: 1px 4px; border-radius: 3px; font-weight: 600; font-size: 0.85rem; border: 1px solid #bfdbfe; margin-left: 4px; flex-shrink: 0; line-height: 1.2; display: flex; align-items: center; }
.order-shipping-line { font-size: 0.7rem; font-weight: 700; color: #1e3a8a; margin-top: 1px; margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.manual-date-frame { border: 1px solid #3b82f6; border-radius: 4px; padding: 1px 4px; background-color: #eff6ff; color: #1e3a8a; display: inline-block; font-weight: 800; }

.telemetry-container { display: flex; flex-direction: column; gap: 16px; max-width: 1100px; margin: 0 auto; width: 100%; }
.telemetry-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--border-color); }
.telemetry-title { font-size: 1.15rem; font-weight: 700; color: #0f172a; }
.telemetry-status { font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.telemetry-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 900px) { .telemetry-grid { grid-template-columns: repeat(2, 1fr); } }
.telemetry-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 14px 16px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04); }
.telemetry-card-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #64748b; margin-bottom: 8px; }
.telemetry-card-value-row { display: flex; align-items: baseline; justify-content: space-between; }
.telemetry-card-val { font-size: 2.2rem; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; color: #0f172a; line-height: 1; }
.telemetry-card-val.accent-speed { color: #2563eb; }
.telemetry-card-unit { font-size: 0.85rem; font-weight: 600; color: #94a3b8; margin-left: 6px; }
.telemetry-meta-bar { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 12px; padding: 12px 16px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; }
@media (max-width: 900px) { .telemetry-meta-bar { grid-template-columns: repeat(2, 1fr); } }
.telemetry-meta-item { display: flex; flex-direction: column; gap: 2px; }
.telemetry-meta-item .meta-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: #64748b; }
.telemetry-meta-item .meta-value { font-size: 0.95rem; font-weight: 700; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.product-type-badge {
    border: 1px solid #94a3b8;
    border-radius: 4px;
    padding: 0 4px; 
    font-weight: 700; 
    font-size: 0.65rem; 
    text-align: center;
    background: #f8fafc;
    color: #334155;
    position: absolute; 
    left: 50%;
    transform: translateX(-50%);
    line-height: 1.2;
    white-space: nowrap;
}

/* Стили для гиперссылки номера заказа */
.order-detail-link {
  color: var(--primary-color);
  text-decoration: none;
  border-bottom: 1px dashed var(--primary-color);
  transition: all 0.2s ease;
}
.order-detail-link:hover {
  color: #1e3a8a;
  border-bottom-style: solid;
}

/* Стили для таблицы в модалке деталей, чтобы не было горизонтального скролла */
table.details-modal-table {
  table-layout: fixed;
  width: 100%;
}
table.details-modal-table th, 
table.details-modal-table td {
  white-space: normal !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Источник этапа и заявки из Bitrix */
.source-badge { background: #dbeafe; color: #1d4ed8; border-radius: 3px; padding: 0 4px; font-size: .68rem; margin-left: 4px; }
.review-badge { color: #dc2626; font-weight: 700; margin-left: 4px; }
.tt-src { white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: .72rem; color: #334155; margin-top: 4px; }
.tt-warn { color: #dc2626; }
.bx-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.bx-table th, .bx-table td { border-bottom: 1px solid var(--border-color); padding: 6px 8px; text-align: left; vertical-align: top; }
.bx-table .bx-desc { white-space: pre-wrap; color: #475569; font-size: .78rem; max-width: 520px; }
.bx-form input { width: 64px; margin-right: 4px; }
.order-card.deadline-risk { outline: 2px solid #dc2626; outline-offset: -2px; }
.order-card.deadline-risk .order-shipping-line { color: #dc2626; font-weight: 700; }

/* Неделя, источник этапа и Excel: плотный рабочий интерфейс цехового планирования. */
.planner-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 46px; margin: 0 0 6px;
  padding: 7px 9px; border: 1px solid #cbd5e1; border-left: 4px solid #f59e0b;
  background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
.week-navigation { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.week-stepper { display: inline-flex; overflow: hidden; flex: 0 0 auto; border: 1px solid #94a3b8; border-radius: 5px; background: #f8fafc; }
.week-arrow { width: 32px; min-height: 34px; padding: 0; border: 0; background: transparent; color: #334155; font-size: 1.35rem; line-height: 1; cursor: pointer; }
.week-arrow + .week-arrow { border-left: 1px solid #cbd5e1; }
.week-arrow:hover { background: #e2e8f0; }
.week-jump { position: relative; min-width: 0; }
.week-date-button { position: relative; display: grid; min-width: 230px; min-height: 34px; padding: 4px 34px 4px 10px; border: 1px solid #94a3b8; border-radius: 5px; background: #fff; color: #0f172a; text-align: left; cursor: pointer; }
.week-date-button:hover, .week-date-button[aria-expanded="true"] { border-color: #3b82f6; background: #f8fbff; }
.week-range { font-size: .82rem; line-height: 1.25; font-weight: 700; white-space: nowrap; }
.week-number-label { margin-top: 1px; color: #64748b; font-size: .68rem; line-height: 1.15; }
.week-date-caret { position: absolute; top: 50%; right: 11px; color: #64748b; font-size: .9rem; transform: translateY(-55%); }
.week-picker-native { display: none; }
.week-picker-popover { position: absolute; top: calc(100% + 7px); left: 0; z-index: 80; width: 286px; padding: 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; box-shadow: 0 12px 28px rgba(15, 23, 42, .18); }
.week-picker-popover[hidden] { display: none; }
.week-picker-fields { display: grid; grid-template-columns: 1fr; gap: 10px; }
.week-picker-fields label { display: grid; gap: 4px; color: #64748b; font-size: .72rem; font-weight: 700; }
.week-picker-fields select { width: 100%; min-height: 32px; padding: 4px 7px; border: 1px solid #94a3b8; border-radius: 4px; background: #fff; color: #0f172a; font-size: .82rem; }
.week-current { white-space: nowrap; }
.planner-excel-actions { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.toolbar-spacer { flex: 1; }

.order-card:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(245, 158, 11, .65); outline-offset: 2px;
}
.order-card[role="button"] { cursor: pointer; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 970; background: rgba(15, 23, 42, .34); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.source-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 980; width: min(920px, 94vw);
  display: flex; flex-direction: column; background: #f8fafc; border-left: 5px solid #f59e0b;
  box-shadow: -12px 0 34px rgba(15, 23, 42, .24); transform: translateX(102%); transition: transform .2s ease;
}
.source-drawer.open { transform: translateX(0); }
.source-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 14px; border-bottom: 1px solid #cbd5e1; background: #fff; }
.source-drawer-header h2 { margin: 0; color: #0f172a; font-size: 22px; line-height: 1.35; overflow-wrap: anywhere; }
.source-drawer-header { gap: 16px; }
.source-drawer-header > div { min-width: 0; }
.source-drawer-header .drawer-close { flex-shrink: 0; }
.source-kicker { font-size: .74rem; font-weight: 700; color: #b45309; }
.drawer-close { border: 0; background: transparent; color: #475569; font-size: 2rem; line-height: 1; cursor: pointer; }
.source-drawer-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 24px; padding: 20px 24px 36px; overflow: auto; user-select: text; }
.source-column { min-width: 0; }
.source-section, .source-current-task { margin-top: 22px; }
.source-section h3, .source-current-task h3, .source-origin > h3 { margin: 0 0 10px; font-size: 1rem; line-height: 1.35; color: #1e293b; }
.source-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-bottom: 12px; color: #64748b; font-size: .82rem; line-height: 1.4; }
.source-kind { padding: 2px 7px; border-radius: 3px; background: #dbeafe; color: #1d4ed8; font-weight: 700; }
.source-task-link { display: inline-block; margin: 0 0 16px; color: #1d4ed8; font-weight: 700; }
.source-text { max-height: 320px; overflow: auto; margin: 0; padding: 15px 16px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid #cbd5e1; border-radius: 5px; background: #fff; color: #1e293b; font: .9rem/1.55 "Segoe UI", sans-serif; }
.source-refresh { margin-top: 12px; }
.source-field-grid { display: grid; gap: 6px; margin: 0; }
.source-field-row { display: grid; grid-template-columns: minmax(130px, 42%) minmax(0, 1fr); gap: 10px 14px; min-width: 0; padding: 10px 12px; border-bottom: 1px solid #e2e8f0; background: #fff; }
.source-field-row dt, .source-field-row dd { min-width: 0; overflow-wrap: anywhere; }
.source-field-row dt { color: #64748b; font-size: .84rem; line-height: 1.4; }
.source-field-row dd { margin: 0; color: #0f172a; font-size: .9rem; line-height: 1.4; font-weight: 600; }
.source-current-status { margin: 0; padding: 13px 14px; border: 1px solid #cbd5e1; background: #fff; color: #64748b; font-size: .86rem; line-height: 1.45; }
.source-current-status:empty { display: none; }
.source-current-status.error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.source-item { margin-top: 7px; padding: 10px; border: 1px solid #cbd5e1; border-radius: 5px; background: #fff; }
.source-item.selected { border-color: #f59e0b; box-shadow: inset 4px 0 #f59e0b; }
.source-item h4 { margin: 0 0 6px; font-size: .82rem; }
.source-item pre { overflow: auto; white-space: pre-wrap; font-size: .72rem; user-select: text; }
.source-warning, .source-error { padding: 9px 11px; border-left: 4px solid #f59e0b; background: #fffbeb; color: #92400e; }
.source-error { border-left-color: #dc2626; background: #fef2f2; color: #991b1b; }
.source-empty, .source-loading, .help-text { color: #64748b; font-size: .8rem; }

.excel-settings { max-width: 650px; margin-top: 24px; padding-top: 20px; border-top: 1px solid #cbd5e1; }
#settingsView .card { overflow-y: auto; }
.excel-settings h3 { margin-bottom: 6px; }
.binding-mode-list { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 14px 0; }
.binding-mode-list label, .new-workbook-choice { display: flex; align-items: center; gap: 6px; font-size: .84rem; }
.binding-status { margin: 12px 0; padding: 9px 11px; border-left: 4px solid #3b82f6; background: #eff6ff; color: #1e3a8a; font-size: .82rem; }
.known-workbook-row { max-width: 520px; margin-bottom: 10px; }
.excel-workspace { width: min(1080px, 96vw); height: min(820px, 92vh); display: flex; flex-direction: column; overflow: hidden; }
.modal-title-row, .excel-action-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.excel-action-row { justify-content: flex-start; margin: 12px 0; }
.excel-status { padding: 10px 12px; border-left: 4px solid #64748b; background: #f1f5f9; font-size: .84rem; }
.excel-status.success { border-color: #059669; background: #ecfdf5; color: #065f46; }
.excel-status.error { border-color: #dc2626; background: #fef2f2; color: #991b1b; }
.excel-preview-body { flex: 1; overflow: auto; margin-top: 12px; user-select: text; }
.excel-summary { position: sticky; top: 0; z-index: 2; padding: 9px 10px; background: #0f172a; color: #fff; font-size: .8rem; }
.excel-week-preview { margin-top: 12px; padding: 12px; border: 1px solid #cbd5e1; border-radius: 5px; background: #fff; }
.excel-week-heading { font-weight: 750; color: #0f172a; }
.excel-table-wrap { overflow: auto; margin-top: 8px; }
.excel-preview-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: .77rem; }
.excel-preview-table th, .excel-preview-table td { padding: 7px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: top; }
.excel-row-fields { max-width: 420px; white-space: normal; word-break: break-word; }
.excel-resolution, .excel-stage-id { width: 150px; padding: 4px; border: 1px solid #94a3b8; border-radius: 3px; }
.excel-stage-id { display: block; margin-top: 5px; }
.excel-stage-id[hidden] { display: none; }
.excel-issues { margin: 8px 0 0 20px; color: #9a3412; font-size: .78rem; }
.excel-import-actions { position: sticky; bottom: 0; padding: 10px 0; background: rgba(248, 250, 252, .94); }
.excel-placement-summary { margin-top: 12px; padding: 10px; border-left: 4px solid #3b82f6; background: #eff6ff; }
.excel-placement-summary:empty { display: none; }
.excel-placement-summary h3 { margin: 0 0 7px; font-size: .88rem; }
.excel-placement-row { padding: 4px 0; color: #1e3a8a; font-size: .76rem; }
.excel-placement-row.unresolved { color: #9a3412; }
.excel-row-conflicts, .excel-field-conflict { margin: 7px 0; color: #92400e; font-size: .76rem; }
.excel-field-conflict { padding: 8px 10px; border-left: 4px solid #f59e0b; background: #fffbeb; }
.excel-field-conflict ul { margin: 6px 0 0; padding-left: 18px; }
.excel-conflict-action { display: block; max-width: 100%; margin-top: 6px; }
.writeback-change-list { margin: 10px 0 14px; border: 1px solid #cbd5e1; }
.writeback-change { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; background: #fff; font-size: .8rem; }

@media (max-width: 820px) {
  .source-drawer-body { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .planner-toolbar { flex-wrap: wrap; }
  .week-navigation { flex: 1 1 100%; }
  .week-jump { flex: 1; }
  .week-date-button { width: 100%; min-width: 0; }
  .toolbar-spacer { display: none; }
  .planner-excel-actions { margin-left: auto; }
  .excel-action-row { flex-wrap: wrap; }
}

@media (max-width: 520px) {
  .week-navigation { flex-wrap: wrap; }
  .week-jump { flex: 1 1 calc(100% - 74px); }
  .week-current { margin-left: 74px; }
  .week-picker-popover { right: 0; left: auto; width: min(286px, calc(100vw - 36px)); }
  .source-drawer { width: 100vw; border-left-width: 3px; }
  .source-drawer-header { padding: 15px 16px 12px; }
  .source-drawer-body { gap: 8px; padding: 16px 14px 28px; }
  .source-field-row { grid-template-columns: 1fr; gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .source-drawer, .drawer-backdrop { transition: none; }
}

.source-origin { display: flex; flex-direction: column; }
.source-origin > .stage-feedback { margin-top: auto; padding: 16px 0 8px; position: sticky; bottom: 0; z-index: 2; background: #f8fafc; flex-shrink: 0; }
.stage-feedback-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 12px; }
.stage-feedback-actions button { flex: 1 1 auto; min-height: 46px; padding: 12px 16px; font-size: 0.95rem; font-weight: 700; border-width: 2px; border-radius: 8px; transition: background-color .15s, box-shadow .15s; }
.stage-feedback-actions button:focus-visible { outline: 3px solid #0f172a; outline-offset: 3px; }
.stage-feedback-actions .stage-feedback-accept { background: #15803d; border-color: #15803d; color: #fff; }
.stage-feedback-actions .stage-feedback-accept:hover { background: #166534; border-color: #166534; }
.stage-feedback-actions .stage-feedback-comment { background: #0369a1; border-color: #0369a1; color: #fff; }
.stage-feedback-actions .stage-feedback-comment:hover { background: #075985; border-color: #075985; }
.stage-feedback-text { box-sizing: border-box; width: 100%; margin-top: 12px; padding: 10px; font: inherit; resize: vertical; }
.stage-feedback-status { font-size: 0.9rem; overflow-wrap: anywhere; }
.stage-feedback-actions .stage-feedback-reject { color: #b91c1c; background: #fff; border-color: #b91c1c; }
.stage-feedback-actions .stage-feedback-reject:hover { background: #fef2f2; }
.stage-feedback button:disabled { opacity: 0.6; cursor: wait; }

.stage-attachment-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.stage-attachment-name { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.stage-attachment-row .source-task-link { margin: 0; }

.source-text .source-position-highlight {
    background: #ffdf66;
    color: #29220b;
    border-radius: 3px;
    box-shadow: 0 2px 0 #d8ac20;
    padding: 2px 0;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    font-weight: 700;
}

/* Settings: shared type scale and spacing for ERP and workbook controls. */
#settingsView .card { padding: 24px; }
#settingsView .card > * { flex-shrink: 0; }
#settingsView h2, #settingsView h3 { margin: 0 0 20px; font-size: 18px; line-height: 26px; font-weight: 650; }
#settingsView .input-group { gap: 8px; }
#settingsView .input-group > label { font-size: 14px; line-height: 20px; font-weight: 600; }
#settingsView .settings-field { width: 100%; max-width: 320px; margin-bottom: 20px; }
#settingsView input:not([type="radio"]), #settingsView select { min-height: 38px; font-size: 14px; line-height: 20px; padding: 8px 12px; }
#settingsView button { max-width: 100%; overflow-wrap: anywhere; min-height: 36px; padding: 8px 14px; font-size: 14px; line-height: 20px; font-weight: 600; white-space: normal; }
#settingsView .card > .btn-save, #settingsView .known-workbook-row > button { align-self: flex-start; }
#settingsView .excel-settings { width: 100%; max-width: 700px; margin-top: 32px; padding-top: 28px; }
#settingsView .excel-settings h3 { margin-bottom: 8px; }
#settingsView .help-text { font-size: 13px; line-height: 20px; color: #64748b; }
#settingsView .binding-mode-list { gap: 12px 24px; margin: 20px 0; }
#settingsView .binding-mode-list label { font-size: 14px; line-height: 20px; gap: 8px; }
#settingsView .binding-status { margin: 20px 0; padding: 12px; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
#settingsView .known-workbook-row { max-width: none; margin-bottom: 20px; }
#settingsView .settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 600px) {
  #settingsView .card { padding: 16px; }
  #settingsView .binding-mode-list { flex-direction: column; align-items: flex-start; }
  #settingsView .settings-actions { align-items: flex-start; flex-direction: column; }
}

.audit-details { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 900px; max-height: 420px; overflow-y: auto; margin-top: 8px; font-size: 13px; line-height: 1.5; }
#logsView summary { cursor: pointer; line-height: 1.5; }
#logsView .help-text { margin-bottom: 16px; }
#logsMore { align-self: flex-start; flex-shrink: 0; margin-top: 12px; }

#logsView td { vertical-align: top; }

/* Hover-only placement preview, without navigation or plan mutations. */
.recommendable .card-tooltip { display: none !important; }
.order-card.placement-origin { outline: 2px solid #94a3b8; outline-offset: 1px; }
.placement-ghost { display: flex; flex-direction: column; justify-content: space-between; gap: 0; flex: 0 0 100px; height: 100px; overflow: hidden; padding: 4px 6px; box-sizing: border-box; min-width: 0; border: 2px dashed #94a3b8; border-radius: 5px; background: #eef0f3; color: #526071; opacity: .8; font: 10px/1.2 system-ui, sans-serif; pointer-events: none; }
.placement-ghost > * { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.placement-ghost-label { font-size: 10px; color: #64748b; }
.placement-ghost strong { font-size: 11px; }
.placement-hint { position: fixed; right: 22px; bottom: 26px; z-index: 800; width: 310px; max-width: calc(100vw - 24px); display: grid; gap: 5px; box-sizing: border-box; padding: 13px 15px; background: #fff; color: #334155; border: 1px solid #cbd5e1; border-radius: 9px; box-shadow: 0 5px 20px #0f172a18; font: 12px/1.45 system-ui, sans-serif; pointer-events: none; }
.placement-hint small { color: #64748b; font-size: 10px; margin-top: 4px; }
.placement-late { color: #dc2626; font-weight: 700; }
.placement-ghost-late { border-color: #dc2626; opacity: 1; }
@media (max-width: 600px) { .placement-hint { right: 12px; bottom: 14px; } }
/* Two-line week choices: a native select cannot reliably render subtitles. */
.week-number-options { margin-top: 10px; max-height: min(340px, 50vh); overflow-y: auto; padding: 4px; background: #fff; border: 1px solid #cbd5e1; border-radius: 6px; box-shadow: 0 8px 20px #0f172a26; }
.week-number-option { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 4px; background: #fff; color: #0f172a; text-align: left; font-size: .82rem; cursor: pointer; }
.week-number-option:hover, .week-number-option:focus-visible { background: #eff6ff; }
.week-number-option[aria-pressed="true"] { background: #dbeafe; color: #1d4ed8; }

.week-number-option span { display: block; }
.week-number-option small { display: block; margin-top: 3px; color: #64748b; font-size: .69rem; font-weight: 400; line-height: 1.3; }

.planner-toolbar .lines-tabs-container { align-self: stretch; align-items: center; }
.planner-toolbar .line-tab { top: 0; min-height: 34px; border-radius: 5px; }
.planner-toolbar .line-tab.active { border-bottom-color: var(--border-color); }

.source-meta { align-items: center; }
.source-meta .source-task-link { margin: 0; }

.right-sidebar .native-accordion summary { gap: 4px; padding: 12px 8px; overflow-wrap: anywhere; }
.right-sidebar .badge-count { flex-shrink: 0; margin-right: 0; }

.planning-preview-table { width:100%; border-collapse:collapse; font-size:.78rem; }
.planning-preview-table th,.planning-preview-table td { padding:6px; vertical-align:top; border-bottom:1px solid #cbd5e1; text-align:left; overflow-wrap:anywhere; }
.planning-preview-move { padding:10px 0; border-bottom:1px solid #cbd5e1; }
.planning-preview-move p { font-size:.82rem; margin:6px 0; }
.planning-preview details { margin:12px 0; }
